code_junkie

Question SpeechSynthesizer.SetOutputToAudioStream audio format problem

Nov 12th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. System.Speech.AudioFormat.SpeechAudioFormatInfo synthFormat =
  2. new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm,
  3. 8000, 16, 1, 16000, 2, null);
  4.  
  5. SpeechSynthesizer synthesizer = new SpeechSynthesizer();
  6. waveStream = new MemoryStream();
  7.  
  8. PromptBuilder pbuilder = new PromptBuilder();
  9. PromptStyle pStyle = new PromptStyle();
  10.  
  11. pStyle.Emphasis = PromptEmphasis.None;
  12. pStyle.Rate = PromptRate.Fast;
  13. pStyle.Volume = PromptVolume.ExtraLoud;
  14.  
  15. pbuilder.StartStyle(pStyle);
  16. pbuilder.StartParagraph();
  17. pbuilder.StartVoice(VoiceGender.Male, VoiceAge.Teen, 2);
  18. pbuilder.StartSentence();
  19. pbuilder.AppendText("This is some text.");
  20. pbuilder.EndSentence();
  21. pbuilder.EndVoice();
  22. pbuilder.EndParagraph();
  23. pbuilder.EndStyle();
  24.  
  25. synthesizer.SetOutputToAudioStream(waveStream, synthFormat);
  26. synthesizer.Speak(pbuilder);
  27. synthesizer.SetOutputToNull();
  28.  
  29. pbuilder.StartStyle(pStyle);
  30. pbuilder.StartParagraph();
  31. pbuilder.StartVoice(VoiceGender.Male, VoiceAge.Teen, 2);
  32. pbuilder.StartSentence();
  33. pbuilder.AppendText("Checking current weather.");
  34. pbuilder.EndSentence();
  35. pbuilder.EndVoice();
  36. pbuilder.EndParagraph();
  37. pbuilder.EndStyle();
  38. ss.SpeakAsync(pbuilder);
  39.  
  40. ss.SpeakAsync("Checking current weather");
Add Comment
Please, Sign In to add comment