Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My text-to-speech program doesn't detect languages other than English, why?

What I have tried:

public static SpeechLib.SpVoice SP = new SpVoice();


foreach (SpeechLib.ISpeechObjectToken v in SP.GetVoices())
{
    comboBoxVoice.Items.Add(v.GetDescription(49));
}
Posted
Updated 9-Jan-19 1:40am

1 solution

Please, read this: c# - Text To Speech with SAPI: Custom Language - Stack Overflow[^]

[Update]
According to the discussion in comments, i'd suggest to read this:
Use SSML to Create Prompts and Control TTS (Microsoft Speech Platform) | Microsoft Docs[^]
SpVoice Interface (SAPI 5.3) | Microsoft Docs[^]

[Update #2]
c# - Using SAPI is there a way to enter pinyin for Chinese pronunciation? - Stack Overflow[^]
Based on example provided by above link:
C#
private void btnSpeakPhonems_Click(object sender, EventArgs e)
{
    if (comboBox1.SelectedIndex > 0)
    {
        SpVoice voice = new SpVoice();
        voice.Voice = voice.GetVoices().Item(comboBox1.SelectedIndex);
        voice.Speak("<pron sym=\"ang 1 zang 1\">变脏</pron>", SpeechVoiceSpeakFlags.SVSFlagsAsync);

    }
}


Good luck!
 
Share this answer
 
v5
Comments
john1990_1 9-Jan-19 10:30am    
This isn't what I'm looking for, my Windows Forms App program detects the presses Ctrl+C twice fast and speaks text in clipboard when they're pressed, it currently works only in English, I want the user to choose a language from the combobox (each language that its text-to-speech is installed in Windows), when the user chooses a language and a name of a person (for example "Microsoft Asaf" for Hebrew), the voice property of the SpeechLib.SpVoice gets changed, and speech is done in this language for the text in clipboard, the problem is that SP.GetVoices() should detect also non English language!
Maciej Los 10-Jan-19 2:49am    
Not sure i understand you well, but when you change a language in the combobox, you need to pass an xml node to the Speak(Xml_data_here) method. That's all.
john1990_1 10-Jan-19 7:27am    
When the user changes the text in the combobox, the SpeechLib.SpObjectToken which exists in SP.GetVoices() is done with SP.Voice=v;. I just want SP.GetVoices() to get non English voices too in Windows Forms App C#.
Maciej Los 10-Jan-19 7:38am    
If GetVoices method doesn't work, why don't you try to change langauge within Speak method?
As far as i understand MSDN documentation, the only way to change language ad hoc is to use Speak method.
See updated answer (new links).
john1990_1 10-Jan-19 7:41am    
I want it to work with any language chosen by the user in the combobox and for any text in his clipboard.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900