This is my code for Chinese TTS which is failing in the speak function although Chinese TTS engine is installed successfully
using Microsoft.Speech.Synthesis;
using System.Globalization;
namespace TTS3
{
class Program
{
static void Main(string[] args)
{
//CultureInfo=new CultureInfo("zh-CN");
SpeechSynthesizer synth = new SpeechSynthesizer();
// Output information about all of the installed voices.
foreach (InstalledVoice voice in synth.GetInstalledVoices(new CultureInfo("zh-CN")))
{
synth.SelectVoice(voice.VoiceInfo.Name);
//Console.WriteLine(synth.Voice.Description);
synth.SetOutputToWaveFile("C:\\Users\\surabhi\\Desktop\\yes.wav");
synth.Speak("你好世界");
break;
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
Exception that the code is throwing is
Unhandled Exception: System.InvalidOperationException: Speak error '80004005'. -
--> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been r
eturned from a call to a COM component.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 e
rrorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode
)
at Microsoft.Speech.Internal.Helpers.ExceptionFromSapiError(SAPIErrorCodes er
rorCode)
--- End of inner exception stack trace ---
at Microsoft.Speech.Synthesis.SpeechSynthesizer.SpeakPrompt(Prompt prompt, Bo
olean async)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(String textToSpeak)
at TTS3.Program.Main(String[] args) in c:\Users\surabhi\Documents\Visual Stud
io 2013\Projects\TTS3\TTS3\Program.cs:line 23
Please help me in resolving this issue