Guest User

Untitled

a guest
Feb 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using Microsoft.Speech.Synthesis;
  2.  
  3. static SpeechSynthesizer voice;
  4. static SoundPlayer player = new SoundPlayer();
  5.  
  6. public Form1()
  7. {
  8. InitializeComponent();
  9. voice = new SpeechSynthesizer();
  10. foreach (InstalledVoice speech in voice.GetInstalledVoices())
  11. {
  12. VoiceInfo info = speech.VoiceInfo;
  13. label1.Text = info.Name;
  14. }
  15. }
  16.  
  17. private static void tts_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
  18. {
  19. player.Stream.Position = 0;
  20. player.Play();
  21. }
  22.  
  23. public static void Speak(string text)
  24. {
  25. player.Stream = new System.IO.MemoryStream();
  26. voice.SetOutputToWaveStream(player.Stream);
  27. voice.SpeakAsync(text);
  28. }
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. using (voice = new SpeechSynthesizer())
  32. {
  33. voice.SelectVoice("Microsoft Server Speech Text to Speech Voice (ko-KR, Heami)");
  34.  
  35.  
  36. voice.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(tts_SpeakCompleted);
  37. Speak("안녕하세요. 제 이름은 황정우입니다. 잘부탁합니다.");
  38. }
  39. }
Add Comment
Please, Sign In to add comment