none
speech voice visual studio c# RRS feed

  • Question

  • Hi,

    so I'm developping a text-to-speech c# app with a male voice in windows 10,

    somhow I only have female voice even though I used:

    speech.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult)

    ps: I'm using french language, I have "Hortense" and I need "Paul"'s voice

    thank u

    Wednesday, February 26, 2020 4:34 PM

All replies

  • I have Paul listed in this test (on french Windows too...) =>

    // Add reference to : Microsoft Speech Object Library
    // Add : using SpeechLib;
    SpVoice voice = new SpVoice();
    SpObjectTokenCategory otc = new SpObjectTokenCategory();
    //otc.SetId(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices");
    otc.SetId(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices");
    
    ISpeechObjectTokens tokenEnum = otc.EnumerateTokens();
    int nTokenCount = tokenEnum.Count;
    foreach (ISpeechObjectToken sot in tokenEnum)
    {
       Console.WriteLine(sot.GetDescription());
       voice.Voice = (SpObjectToken)sot;
       voice.Speak("Hello ! How are you ?");
    }

    • Proposed as answer by simonb549 Thursday, February 27, 2020 7:50 AM
    Wednesday, February 26, 2020 5:30 PM
  • Hi Emmm1997,
    First, make sure that you have installed the french Text-to-Speech language in Windows.
    Here is a document you can refer to.
    Then you check which voices you have installed by enumerating the GetInstalledVoices method of the SpeechSynthesizer class, and then use SelectVoiceByHints to select one of them:

    using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
    {
        // show installed voices
        foreach (var v in synthesizer.GetInstalledVoices().Select(v => v.VoiceInfo))
        {
            Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
                v.Description, v.Gender, v.Age);
            Console.ReadKey();
        }
    
        // select male senior (if it exists)
        synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);
    
        // select audio device
        synthesizer.SetOutputToDefaultAudioDevice();
    
        // build and speak a prompt
        PromptBuilder builder = new PromptBuilder();
        builder.AppendText("Found this on Stack Overflow.");
        synthesizer.Speak(builder);
    }

    More details you can refer to this link.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 27, 2020 6:20 AM
  • Hi Emmm1997,
    Has your problem been solved? If it is resolved, we suggest that you mark it as the answer. So it can help other people who have the same problem find a solution quickly. If not solved, what problem did you encounter?
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 28, 2020 9:52 AM
  • Who would have thought it was that simple? I've been trying for days to find how to access the Windows 10 Narrator voices. I finally found out they're stored in a different registry location, and then find out that all I have to do is change where my SpEnumTokens call is pointed to - Speech_OneCore instead of Speech (aka SPCAT_VOICES).

    Everything after that just works.

    Thanks @simonb549 - this is awesome.

    Thursday, March 26, 2020 2:41 AM
  • Then mark Castorix31'  answer to help other people who can have the same problem
    Thursday, March 26, 2020 7:40 AM