Pergunta

I have an application that reads a text file into byte array, then I convert this array to string and send it as an input to the speak method of the SpeechSynthesizer but the SPEAK method doen't speak..

if I just send a regular temp string it works fine.. but when I convert the byte array to string it doesn't work.

what I did is when I read the line from the text file I use this lines of code

UTF8Encoding temp = new UTF8Encoding(true);
string whatToSay = temp.getString(b);
speech.Speak(whatToSay); // it doesn't work even though the above line returns the  
                            correct string

so I wonder what is the difference if I write just this:

spech.Speak("hello"); // this works perfect

is there any difference between those strings? the speak method doesn't get UTF8 ?

Foi útil?

Solução

I couldn't see any problem with your code but maybe your variable b is something different. I am not sure what is wrong but you can also try saving the audio file somewhere and checking it if it is playing something or not:

 using (SpeechSynthesizer synth = new SpeechSynthesizer()) {
     synth.SetOutputToWaveFile(@"C:\temp\Sample.wav");
     PromptBuilder builder = new PromptBuilder();
     builder.AppendText("Hello World !"); //You can send a variable here also.
     synth.Speak(builder); 
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top