1
1
1SLY22020-06-11 11:13:43
Speech recognition
1SLY2, 2020-06-11 11:13:43

Application throws InvalidOperationException?

Hello, when trying to recognize speech, an InvalidOperationException is thrown.
Code:

public class SpeechEngine : IDisposable
    {
        public string RecognizedText;
        Windows.Media.SpeechRecognition.SpeechRecognizer speechRecognizer;
        Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult;
        public SpeechEngine()
        {
            speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer();
        }
        public async void StartRecognizing()
        {
            await speechRecognizer.CompileConstraintsAsync();

            speechRecognitionResult = await speechRecognizer.RecognizeAsync();
        }
        public async void StopRecognizing()
        {
            await speechRecognizer.StopRecognitionAsync();

            RecognizedText = speechRecognitionResult.Text;
        }

        public void Dispose()
        {
            speechRecognizer.Dispose();
        }
    }

The manifest has permission to use the microphone. UWP Project
5ee1e82861aed749896350.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-06-11
@freeExec

So I opened the article and there the first thing they do is capture the microphone, but you don’t.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question