Share via

How to implement speakcompleted in uwp ?

Shay Wilner 1,746 Reputation points
2020-08-12T09:10:47.643+00:00

Hi

I have a click button event in which i use speech synthesizer to generate a speech.
When the narrator achieved speaking i would like to start a dispatchertimer.
How can i know when the speak is completed ?

Thanks

Developer technologies | Universal Windows Platform (UWP)
0 comments No comments

Answer accepted by question author

Richard Zhang-MSFT 6,936 Reputation points Microsoft Employee Moderator
2020-08-12T09:32:19.38+00:00

Hello,

Welcome to Microsoft Q&A.

We can judge whether it has completed the recognition by the state change of SpeechRecognizer

private SpeechRecognizer speechRecognizer;
public MainPage()
{
    this.InitializeComponent();
    this.speechRecognizer = new SpeechRecognizer();
    speechRecognizer.StateChanged += SpeechRecognizer_StateChanged;
}

private void SpeechRecognizer_StateChanged(SpeechRecognizer sender, SpeechRecognizerStateChangedEventArgs args)
{
    if(args.State== SpeechRecognizerState.SoundEnded)
    {
        // The subsequent input of audio is not detected, 
        // which can be understood as the speaker has finished speaking, 
        // but SpeechRecognizer has not stopped audio monitoring
    }
    else if(args.State==SpeechRecognizerState.Idle)
    {
        // SpeechRecognizer stops listening
    }
    else if (args.State == SpeechRecognizerState.Paused)
    {
        // (Used for continuous recognition state) SpeechRecognizer pause is recognition
    }
}

You can modify the above code according to your needs, and start DispatcherTimer in the state you need.

Thanks.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.