Ali
Ali

Reputation: 11

Want voice input into a TextBox, this code do but only once, (UWP C#)

I tried using this code

SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeAsync();
textBox1.Text = speechRecognitionResult.Text;

But it provide output only 1 time but i want to get output continuous till i close it myself. Please help me how i can do that.

I tried this method but its providing nothing.

await speechRecognizer.CompileConstraintsAsync();
speechRecognizer.ContinuousRecognitionSession.ResultGenerated += async (s, e1) =>
{
    if ((e1.Result != null))
    {
        await this.Dispatcher.RunAsync(CoreDispatcherPriority.Low,() =>
        {
            var result = e1.Result.Text;
            textBox1.Text = result;
        });
        speechRecognizer.ContinuousRecognitionSession.Resume();
    }
};
await speechRecognizer.ContinuousRecognitionSession.StartAsync(SpeechContinuousRecognitionMode.PauseOnRecognition);

please help,Thanks and must reply. :)

Upvotes: 0

Views: 405

Answers (1)

Jay Zuo
Jay Zuo

Reputation: 15758

To get continuous speech recognition result, you can refer to Continuous dictation. This document describes how to capture and recognize long-form, continuous dictation speech input. You can follow the steps in this document to implement your own. And also, there is an official Speech recognition and synthesis sample in GitHub that might help you.

To start the recognition, you can just call StartAsync() method as you need speech recognizer continues listening for and processing speech input after a recognition result is generated. And then there will be no need to use speechRecognizer.ContinuousRecognitionSession.Resume(); in ResultGenerated event handler, you can safely remove it form your code.

Upvotes: 2

Related Questions