private void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Microsoft.Speech.Synthesis.SpeechSynthesizer ms = new Microsoft.Speech.Synthesis.SpeechSynthesizer(); ms.SetOutputToDefaultAudioDevice(); ms.SelectVoice("Microsoft Server Speech Text to Speech Voice (ko-KR, Heami)"); switch (e.Result.Text) { case "마마고": { MaMaState(true); ms.Speak("네 말씀하세요"); sre2 = new SpeechRecognitionEngine(new CultureInfo("ko-KR")); Choices c = new Choices(); c.Add(new string[] { "입력해줘", "아니야", "영어로번역해줘", "한국어로번역해줘", "일본어로번역해줘", "독일어로번역해줘", "스페인어로번역해줘", "프랑스어로번역해줘", "러시아어로번역해줘", "이탈리아어로번역해줘", "중국어번체로번역해줘", "중국어간체로번역해줘" }); Microsoft.Speech.Recognition.Grammar g = new Microsoft.Speech.Recognition.Grammar(new GrammarBuilder(c)); sre2.LoadGrammar(g); sre2.RequestRecognizerUpdate(); sre2.SpeechRecognized += doWhat; sre2.SetInputToDefaultAudioDevice(); sre2.RecognizeAsync(RecognizeMode.Multiple); break; } } ms.Dispose(); return; }
private void TextSpeak() { if (radioButton1.Checked == false && radioButton2.Checked == false) { if (selectLanguage == true) { MessageBox.Show("Please select a language"); } else if (selectLanguage == false) { MessageBox.Show("언어를 선택해주세요"); } return; } ButtonSet(false); button5.Text = "말하는중"; sSyn.Speak(textBox4.Text); ButtonSet(true); button5.Text = "음성"; }
private void VoiceSpeak() { Microsoft.Speech.Synthesis.SpeechSynthesizer tts = new Microsoft.Speech.Synthesis.SpeechSynthesizer(); tts.SetOutputToDefaultAudioDevice(); string str = textBox2.Text; button3.Enabled = false; if (selectLanguage == true) { button3.Text = "Speaking"; } else if (selectLanguage == false) { button3.Text = "말하는중"; } if (t.Lang.Equals("ko") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (ko-KR, Heami)"); tts.Speak(str); } else if (t.Lang.Equals("ja") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (ja-JP, Haruka)"); tts.Speak(str); } else if (t.Lang.Equals("en") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, Helen)"); tts.Speak(str); } else if (t.Lang.Equals("de") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (de-De, Hedda)"); tts.Speak(str); } else if (t.Lang.Equals("es") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (es-ES, Helena)"); tts.Speak(str); } else if (t.Lang.Equals("fr") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (fr-FR, Hortense)"); tts.Speak(str); } //else if (t.Lang.Equals("zh-TW") == true) //{ // ts.SelectVoice("Microsoft Server Speech Text to Speech Voice (zh-TW, HanHan)"); // ts.Speak(str); //} //else if (t.Lang.Equals("zh-CN") == true) //{ // ts.SelectVoice("Microsoft Server Speech Text to Speech Voice (zh-CN, HuiHui)"); // ts.Speak(str); //} else if (t.Lang.Equals("ru") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (ru-RU, Elena)"); tts.Speak(str); } else if (t.Lang.Equals("it") == true) { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (it-IT, Lucia)"); tts.Speak(str); } else { tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, Helen)"); tts.Speak(str); } tts.Dispose(); button3.Enabled = true; if (selectLanguage == true) { button3.Text = "Voice"; } else if (selectLanguage == false) { button3.Text = "음성"; } }
private void doWhat(object sender, SpeechRecognizedEventArgs e2) { Microsoft.Speech.Synthesis.SpeechSynthesizer tts = new Microsoft.Speech.Synthesis.SpeechSynthesizer(); tts.SetOutputToDefaultAudioDevice(); tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (ko-KR, Heami)"); switch (e2.Result.Text) { case "입력해줘": { tts.Speak("네 입력할게요"); RecognizeSpeechAsync().Wait(); MaMaState(false); RecogStop(); break; } case "아니야": { tts.Speak("알겠습니다"); MaMaState(false); RecogStop(); break; } case "한국어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } ts.Speak("한국어로 번역해드릴게요"); ComboSet("한국어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "영어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("영어로 번역해드릴게요"); ComboSet("영어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "일본어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("일본어로 번역해드릴게요"); ComboSet("일본어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "독일어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("독일어로 번역해드릴게요"); ComboSet("독일어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "스페인어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("스페인어로 번역해드릴게요"); ComboSet("스페인어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "프랑스어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("프랑스어로 번역해드릴게요"); ComboSet("프랑스어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "러시아어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("러시아어로 번역해드릴게요"); ComboSet("러시아어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "이탈리아어로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("이탈리아어로 번역해드릴게요"); ComboSet("이탈리아어"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "중국어간체로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("중국어간체로 번역해드릴게요"); ComboSet("중국어간체"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } case "중국어번체로번역해줘": { if (textBox1.Text.Equals(string.Empty)) { tts.Speak("번역할 문장을 먼저 입력해주세요"); break; } tts.Speak("중국어번체로 번역해드릴게요"); ComboSet("중국어번체"); TranslateAtForm1(); MaMaState(false); RecogStop(); break; } } tts.Dispose(); return; }