SpeechSynthesizer.SpeakAsync method not immediately speaking

.net, c#, text-to-speech

Solution

It's because `Speak` is a blocking call which keeps the program running. Since you're running this as a console application add `Console.ReadKey();` at the end of your code to ensure that the application remains running until the user presses a key.

Otherwise, the main thread will exit because `SpeakAsync` returns immediately so your program is flying through all those lines and then exiting which is why you don't hear anything.

Update based on comments -

The `using` block is disposing the `SpeechSynthesizer` almost immediately which is why nothing can be heard. You can either place `Console.ReadKey();` just before the closing brace of the `using` block or remove the `using` block and dispose of it manually later on.

Problem

I am trying to use the SpeakAsync() method to speak some text. However, it doesn't start speaking anything until I call Speak(). I don't want to call Speak(). If I remove the Speak() method from this code nothing gets called at all: ``` using (SpeechSynthesizer synth = new SpeechSynthesizer()) { synth.SelectVoice("ScanSoft Emily_Dri20_22kHz"); synth.Rate = 10; synth.Volume = 100; synth.SpeakAsync("oh, i'm a lumberjack and i'm okay! I sleep all night and I work all day!"); synth.SpeakAsync("If he was dying he wouldn't bother writing ah! He'd just say it!"); synth.Speak("i don't want to go on the cart."); synth.SpeakAsync("We don't have a lord. We're an anarcho-syndicalist commune."); synth.SpeakAsync("If you do not show us the grail, we shall take your castle by force!"); synth.Speak("what do you mean, an african swallow or a european swallow?"); ``` UPDATE: It appears other people are having this problem but no solution has been found yet: other people having this problem

Original source