I have ASP.Net MVC project and I am trying to call some methods from System.Speech. In my local all is working as expected but when I'm publishing it in Windows Azure it throws NullReferenceException. This my code which throws exception(in line 9):
1 public async static Task<byte[]> ToSpeech(string text)
2 {
3 byte[] bytes;
4 var stream = new MemoryStream();
5 await Task.Run(() =>
6 {
7 using (var speech = new SpeechSynthesizer())
8 {
9 speech.SetOutputToWaveStream(stream);
10 speech.Speak(text);
11 }
12 });
13 bytes = ConvertWavToMP3(stream);
14 return bytes;
15 }
Edit1
The problem is in SpeechSynthesizer , In my local when calling SpeechSynthesizer constructor the fields of speech property initializes normally but when I'm debugging the publish version after calling cosntructor they already thrown exception.