private void InitRecognizer() { var assembly = Assembly.GetExecutingAssembly(); var engineName = _config.Recognition.Engine; var recognizerName = $"AutoCaption.Recognizers.{engineName}SpeechRecognizer"; var recognizerType = assembly.GetType(recognizerName); if (recognizerType == null || !typeof(ISpeechRecognizer).IsAssignableFrom(recognizerType)) { throw new ArgumentException($"No recognition engine found for configured engine \"{engineName}\"."); } var constructor = recognizerType.GetConstructor(Type.EmptyTypes); if (constructor == null) { throw new ArgumentException($"Recognition engine for configured engine \"{engineName}\" does not have a suitable constructor."); } _speechRecognizer = (ISpeechRecognizer)constructor.Invoke(null); _speechRecognizer.SpeechCancelled += OnSpeechCancelled; _speechRecognizer.SpeechCompleted += OnSpeechCompleted; _speechRecognizer.SpeechPartial += OnSpeechPartial; _speechRecognizer.Start(_config.Recognition); }
void Record_Pressed(object sender, EventArgs e) { if (recognizer == null) { recognizer = speechService.CreateRecognizer(); recognizer.SpeechRecognized += SpeechReceived; recognizer.Start(); } }
void RecordingThread() { recognizer.Start(); }
void RecordingThread() { this.RecordedText.Text = "Starting"; recognizer.Start(); }