我正在开发UWP并希望使用SpeechRecognizer。 它应该只对单词“Next”和“Back”做出反应。 但通常,它将“NExt”识别为“返回”。 我的代码如下。 怎么解决这个?
var defaultLanguage = SpeechRecognizer.SystemSpeechLanguage; _speechRecognizer = new SpeechRecognizer(defaultLanguage); _coreDispatcher = CoreWindow.GetForCurrentThread().Dispatcher; var constraintList = new SpeechRecognitionListConstraint(new List<string>() { "Next", "Back" }); _speechRecognizer.Constraints.Add(constraintList); var result = await _speechRecognizer.CompileConstraintsAsync(); if (result.Status == SpeechRecognitionResultStatus.Success) { _speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated; _speechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; await _speechRecognizer.ContinuousRecognitionSession.StartAsync(); }这是ResultGeneratedEvent:
private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args) { { await _coreDispatcher.RunAsync(CoreDispatcherPriority.High, () => { string command = args.Result.Text; Messenger.Default.Send(new VoiceReactMessage(command)); switch (command) { case "Next": SetHorizontalOffset(-ItemsPanelRoot.ActualWidth); break; case "Back": SetHorizontalOffset(ItemsPanelRoot.ActualWidth); break; } }); }I am developing UWP and want to use SpeechRecognizer. It should react only to words "Next" and "Back". But often, it recognizes "NExt" as "Back". My code is below. How to solve this?
var defaultLanguage = SpeechRecognizer.SystemSpeechLanguage; _speechRecognizer = new SpeechRecognizer(defaultLanguage); _coreDispatcher = CoreWindow.GetForCurrentThread().Dispatcher; var constraintList = new SpeechRecognitionListConstraint(new List<string>() { "Next", "Back" }); _speechRecognizer.Constraints.Add(constraintList); var result = await _speechRecognizer.CompileConstraintsAsync(); if (result.Status == SpeechRecognitionResultStatus.Success) { _speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated; _speechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; await _speechRecognizer.ContinuousRecognitionSession.StartAsync(); }Here is ResultGeneratedEvent:
private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args) { { await _coreDispatcher.RunAsync(CoreDispatcherPriority.High, () => { string command = args.Result.Text; Messenger.Default.Send(new VoiceReactMessage(command)); switch (command) { case "Next": SetHorizontalOffset(-ItemsPanelRoot.ActualWidth); break; case "Back": SetHorizontalOffset(ItemsPanelRoot.ActualWidth); break; } }); }最满意答案
不幸的是,你已经遇到了使用语音识别的困难,有时候它无法准确识别出你所说的内容。
我建议的一件事就是利用您获得的置信水平作为结果的一部分。 使用置信度,您可以决定是否要接受结果或尝试要求用户重复他们所说的内容。
Unfortunately you've hit the struggles of working with speech recognition and there will be times when it can't recognize exactly what you've said.
One of the things I would recommend is taking advantage of the the Confidence level which you get as part of the result. Using the confidence, you can decide whether you want to accept the result or attempt to ask the user to repeat what they said.
更多推荐
发布评论