gpt4 book ai didi

c# - WP8 中的 SpeechRecognizerUI 导致高崩溃次数?

转载 作者:行者123 更新时间:2023-11-30 18:28:10 25 4
gpt4 key购买 nike

我一直在开发一个笔记应用程序,我已经包含了 SpeechRecognizerUI,这样用户就可以直接从语音中做笔记。将此应用程序上架后,我注意到崩溃次数非常高。我也收到了一些用户的投诉,说应用程序随机崩溃。我尝试了很多,但它并没有为我崩溃。所以我从开发中心网站导出了堆栈跟踪。

所有崩溃都与 SpeechRecognizerUI 有关。有人知道如何解决这个问题吗?

这是我在页面中使用的代码:-

SpeechRecognizerUI recoWithUI;  //Speech to text
SpeechSynthesizer synth; //Text to speech

public NoteView()
{
InitializeComponent();
recoWithUI = new SpeechRecognizerUI();
synth = new SpeechSynthesizer();
recoWithUI.Recognizer.AudioProblemOccurred += Recognizer_AudioProblemOccurred;
}

private async void RecordButton_Click(object sender, EventArgs e)
{
try
{
SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();

if (NoteBox.Text == "")
NoteBox.Text = recoResult.RecognitionResult.Text;
else
NoteBox.Text = NoteBox.Text + " " + recoResult.RecognitionResult.Text;
}

catch (Exception ex)
{

}
}

async void Recognizer_AudioProblemOccurred(SpeechRecognizer sender, SpeechAudioProblemOccurredEventArgs args)
{
if (args.Problem == SpeechRecognitionAudioProblem.NoSignal)
await synth.SpeakTextAsync("I can't hear you");

else if (args.Problem == SpeechRecognitionAudioProblem.TooFast)
await synth.SpeakTextAsync("That's too fast");

else if (args.Problem == SpeechRecognitionAudioProblem.TooLoud)
await synth.SpeakTextAsync("That's too loud.");

else if (args.Problem == SpeechRecognitionAudioProblem.TooNoisy)
await synth.SpeakTextAsync("There's too much noise");

else if (args.Problem == SpeechRecognitionAudioProblem.TooQuiet)
await synth.SpeakTextAsync("Try speaking louder");

else if (args.Problem == SpeechRecognitionAudioProblem.TooSlow)
await synth.SpeakTextAsync("Try speaking faster");
}

最佳答案

您需要在使用 recoResult.RecognitionResult.Text 之前检查此项。

if (recoResult.RecognitionResult != null)
{
//...
}

关于c# - WP8 中的 SpeechRecognizerUI 导致高崩溃次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25541151/

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