DefaultDeviceOut() error for SpeechSynthesizer in System.Speech.Synthesis namespace in C# when published
<p>I am using SpeechSynthesizer of System.Speech.Speech namespace in c# to convert a text to speech for my web application. When I run the application in my local machine, I am getting the desired output. But when the application is published, I am unable to get the speech output. The stack trace at the exception gives the following error:</p>

<blockquote>
  <p>at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut() at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer) at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer() at System.Speech.Synthesis.SpeechSynthesizer.SetOutputToNull() at System.Speech.Synthesis.SpeechSynthesizer.SetOutputStream(Stream stream, SpeechAudioFormatInfo formatInfo, Boolean headerInfo, Boolean closeStreamOnExit) at Project_test.EchoDialog.text2speech(String str)</p>
</blockquote>

<p>and the TargetSite for the exception gives following information:<strong>DefaultDeviceOut()</strong></p>

<p>I believe this error is due to the application not able to get the audio device information. Can anyone please provide some help in resolving this error and enabling audio output at client side for the web application.</p>