EduardoGomez-1870 avatar image
0 Votes"
EduardoGomez-1870 asked EduardoGomez-1870 commented

use button for dictation

 Hello @RoyLiWicresoftNorthAmericaLtd-0833  I am using continues dictation in my app, but I have a problem, even though I put the silence time out to 1 day, it will still timeout after a while.

What I am trying to do, is that the user press the button and I start speaking, and If I hit the button again it will stop listening. For some reason. I also want the app to type, while I am speaking

      case "0":
                     dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
                     speechRecognizer = new SpeechRecognizer();
                     await speechRecognizer.CompileConstraintsAsync();
                     speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated;
                     speechRecognizer.ContinuousRecognitionSession.AutoStopSilenceTimeout = TimeSpan.FromDays(1);
                     speechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed;
                     await speechRecognizer.ContinuousRecognitionSession.StartAsync();
                     textToSpeech.Background = (SolidColorBrush)Resources[ON];
                 case "1":
                     if (richEbitBox.Document.Selection.CharacterFormat.Bold == FormatEffect.On) {
                         richEbitBox.Document.Selection.CharacterFormat.Bold = FormatEffect.Off;
                         FormatBoltText.Background = (SolidColorBrush)Resources[OFF];
                     } else {
                         richEbitBox.Document.Selection.CharacterFormat.Bold = FormatEffect.On;
                         FormatBoltText.Background = (SolidColorBrush)Resources[ON];
                 case "2":
                     if (richEbitBox.Document.Selection.CharacterFormat.Italic == FormatEffect.On) {
                         richEbitBox.Document.Selection.CharacterFormat.Italic = FormatEffect.Off;
                         formatItalicText.Background = (SolidColorBrush)Resources[OFF];
                     } else {
                         richEbitBox.Document.Selection.CharacterFormat.Italic = FormatEffect.On;
                         formatItalicText.Background = (SolidColorBrush)Resources[ON];
                 case "3":
                     if (richEbitBox.Document.Selection.CharacterFormat.Underline == UnderlineType.Single) {
                         richEbitBox.Document.Selection.CharacterFormat.Underline = UnderlineType.None;
                         formatUnderlineText.Background = (SolidColorBrush)Resources[OFF];
                     } else {
                         richEbitBox.Document.Selection.CharacterFormat.Underline = UnderlineType.Single;
                         formatUnderlineText.Background = (SolidColorBrush)Resources[ON];
                 case "4":
                     if (Ink_cnvas.Visibility == Visibility.Collapsed) {
                         formatDraw.Background = (SolidColorBrush)Resources[ON];
                         Ink_cnvas.Visibility = Visibility.Visible;
                         richEbitBox.Visibility = Visibility.Collapsed;
                     } else if (Ink_cnvas.Visibility == Visibility.Visible) {
                         Ink_cnvas.Visibility = Visibility.Collapsed;
                         formatDraw.Background = (SolidColorBrush)Resources[OFF];
                         richEbitBox.Visibility = Visibility.Visible;
         private async void ContinuousRecognitionSession_Completed(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionCompletedEventArgs args) {
             await speechRecognizer.ContinuousRecognitionSession.StartAsync();
         private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args) {
             await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => {
                     richEbitBox.Document.GetText(TextGetOptions.AdjustCrlf, out string value);
                     richEbitBox.Document.SetText(TextSetOptions.None, value + args.Result.Text);
                     textToSpeech.Background = (SolidColorBrush)Resources[OFF]; // This will indicate that my button is off
                     await speechRecognizer.ContinuousRecognitionSession.StopAsync();    
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you explain For some reason. I also want the app to type, while I am speaking ?

1 Vote 1 ·


I am trying to dictate to the computer when I press the button and continue listening until I press the button again. I want to see if the computer is typing what I say correctly, so I need to be able to see what is being typed in real-time. For example, if you use Cortana, and say hello, you can see what is being typed, in other words, I wan to provide feedback to the user in real-time.@NicoZhu-MSFT

0 Votes 0 ·

1 Answer

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ answered EduardoGomez-1870 commented

For your requirement, you could refer SpeechRecognitionAndSynthesis official code sample, and Scenario_ContinuousDictation could meet your need.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello thank you for your answer, I tried to implement it, and dispose of the synthesizer but I got this error

{"The text associated with this error code could not be found

This is the code that I have

link text

0 Votes 0 ·