gpt4 book ai didi

C# UWP SpeechRecognizer 问题

转载 作者:行者123 更新时间:2023-11-30 15:23:46 29 4
gpt4 key购买 nike

我正在开发 UWP 并想使用 SpeechRecognizer。它应该只对“Next”和“Back”这两个词使用react。但通常,它会将“NExt”识别为“Back”。我的代码如下。如何解决?

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;
}
});
}

最佳答案

不幸的是,您在使用语音识别方面遇到了困难,有时它无法准确识别您所说的内容。

我会推荐的一件事是利用 Confidence level你得到的结果的一部分。使用置信度,您可以决定是要接受结果还是尝试让用户重复他们所说的话。

关于C# UWP SpeechRecognizer 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33965615/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com