SpeechRecognizerUI in WP8 leading to the big crash?

I am working on a note-taking application and I have enabled SpeechRecognizerUI so that the user can take notes directly from speech. After putting this app on the store, I noticed a very high failure rate. I also have several complaints from a user saying that the application crashes accidentally. I tried this a lot but it didn't crash for me. So I exported the stack traces from the Dev Center website.

All crashes are related to SpeechRecognizerUI. Does anyone know how to fix this?

Here is the code that I used in the page: -

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 too fast");

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

    else if (args.Problem == SpeechRecognitionAudioProblem.TooNoisy)
        await synth.SpeakTextAsync("There 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");
}

      

+3


source to share


1 answer


You need to check this before using recoResult.RecognitionResult.Text.



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

      

0


source







All Articles