public SpeechRecognizerServer(string moduleName) { System.Collections.ObjectModel.ReadOnlyCollection<RecognizerInfo> installedRecognizers = SpeechRecognitionEngine.InstalledRecognizers(); //Synchronous Recognition m_reco = new System.Speech.Recognition.SpeechRecognitionEngine(myLanguage); Network.init(); m_moduleName = moduleName; //TTS m_tts = new System.Speech.Synthesis.SpeechSynthesizer(); m_portISpeak = new Port(); m_portISpeak.open("/" + moduleName + "/tts/iSpeak:o"); Network.connect("/" + moduleName + "/tts/iSpeak:o", "/iSpeak"); //Grammars GrammarBuilder dictation = new GrammarBuilder(); dictation.Culture = myLanguage; dictation.AppendDictation(); m_grammar_dictation = new Grammar(dictation); GrammarBuilder spelling = new GrammarBuilder(); spelling.Culture = myLanguage; spelling.AppendDictation("spelling"); m_grammar_dictation_spelling = new Grammar(spelling); m_grammar_continuous = new GrammarBuilder("For sure this non empty grammar will never be recognized."); m_reco.SetInputToDefaultAudioDevice(); m_reco.LoadGrammar(m_grammar_dictation); //Continuous Recognition m_reco_continuous = new SpeechRecognitionEngine(); m_reco_continuous.SetInputToDefaultAudioDevice(); m_portContinuousRecognition = new Port(); m_portContinuousRecognition.open("/" + moduleName + "/recog/continuous:o"); m_reco_continuous.LoadGrammar(new Grammar(m_grammar_continuous)); m_reco_continuous.RecognizeCompleted += onContinuousRecognitionResult; m_reco_continuous.RecognizeAsync(); m_grammarManager = new RobotGrammarManager(); m_grammarManager.InitialiseVocabulories(); SetLanguage("EN-us"); //SetLanguage("fr-fr"); Console.WriteLine("#########################"); Console.WriteLine("# Speech Recognizer #"); Console.WriteLine("#########################"); Network.init(); m_rpcPort = new Port(); m_rpcPort.open("/" + m_moduleName + "/rpc"); m_rpcThread = new System.Threading.Thread(HandleRPC); m_rpcThread.Start(); }
public Form1() { CL = new List<City>(); var converter = new XmlSerializer(typeof(List<City>)); var file = File.OpenText(".\\Cityes"); CL = (List<City>)converter.Deserialize(file); file.Close(); W = new Weather(); button1 = new Button(); InitializeComponent(); Voice = new System.Speech.Synthesis.SpeechSynthesizer(); this.Voice.SpeakCompleted += new System.EventHandler<System.Speech.Synthesis.SpeakCompletedEventArgs>(Comp); }
//Show a list of installed languages for both System and Microsoft static void ShowInstalledLanguage() { using (System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer()) { try { foreach (System.Speech.Synthesis.InstalledVoice voice in synth.GetInstalledVoices()) { System.Speech.Synthesis.VoiceInfo info = voice.VoiceInfo; Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(); } } catch (Exception e) { } } using (Microsoft.Speech.Synthesis.SpeechSynthesizer synth = new Microsoft.Speech.Synthesis.SpeechSynthesizer()) { try { foreach (Microsoft.Speech.Synthesis.InstalledVoice voice in synth.GetInstalledVoices()) { Microsoft.Speech.Synthesis.VoiceInfo info = voice.VoiceInfo; Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(); } } catch (Exception e) { } } }
void sre_SpeechRecognized(object sender, recog.SpeechRecognizedEventArgs e) { synth.SpeechSynthesizer synthesizer = new synth.SpeechSynthesizer(); output_data output = new output_data(); output.uid = "*****@*****.**"; Console.WriteLine(e.Result.Text); bool matchingQuery = dictionary.Any(e.Result.Text.Contains); if (matchingQuery) { output.query = e.Result.Text; output.reset = "false"; SendSpeechRequest(output); } }
private void SendSpeechRequest(output_data data) { WebClient webClient = new WebClient(); webClient.QueryString.Add("query", data.query); webClient.QueryString.Add("uid", data.uid); webClient.QueryString.Add("reset", data.reset); string result = webClient.DownloadString("http://marko-backend.herokuapp.com/handle_voice"); synth.SpeechSynthesizer synthesizer = new synth.SpeechSynthesizer(); synthesizer.SpeakAsync(result); }
//Validate whether the string entered for voice selection is valid static Tuple<string, string> ValidateVoiceSelection(string inputVoiceString) { using (System.Speech.Synthesis.SpeechSynthesizer msftSynth = new System.Speech.Synthesis.SpeechSynthesizer()) { try { foreach (System.Speech.Synthesis.InstalledVoice voice in msftSynth.GetInstalledVoices()) { if (inputVoiceString.Equals(voice.VoiceInfo.Id) || inputVoiceString.Equals(voice.VoiceInfo.Name)) { synthesizerChoice = 1; return new Tuple<string, string>(voice.VoiceInfo.Name, voice.VoiceInfo.Culture.ToString()); } } } catch (Exception e) { } } using (Microsoft.Speech.Synthesis.SpeechSynthesizer sysSynth = new Microsoft.Speech.Synthesis.SpeechSynthesizer()) { try { foreach (Microsoft.Speech.Synthesis.InstalledVoice voice in sysSynth.GetInstalledVoices()) { if (inputVoiceString.Equals(voice.VoiceInfo.Id) || inputVoiceString.Equals(voice.VoiceInfo.Name)) { synthesizerChoice = 2; return new Tuple<string, string>(voice.VoiceInfo.Name, voice.VoiceInfo.Culture.ToString()); } } } catch (Exception e) { } } return null; }