VladislavAntonyuk/MauiSamples

suggestion for continues recognition

vovanb opened this issue · 5 comments

Glory to Ukraine!
many thanks Vladislav for you example MauiSpeech.
I have few questions about:

  1. I need continues loop with speech recognition in application, so user can say some command to app and application will confirm and will continue to listen. What is recommended approach?
  2. In your blog https://vladislavantonyuk.github.io/articles/Speech-recognition-with-.NET-MAUI/, you provide example to use speechRecognizer.StartListening(CreateSpeechIntent(culture));
    but in this example you use await speechToText.ListenAsync
    Could you explain what is difference and what purpose of using Intent?
  3. What is purpose of OpenAI button in sample application?

Glory to heroes! Thank you for the support!

StartListening is listening until you call StopListening

ListenAsync is listening until you cancel the token.
Both methods use Continuous listening, but some platforms have silence timeout, so listening is stopped after some time.

OpenAI here is just an example how to integrated it in app. You can start the button and say Open paint. Paint will be executed.

Thanks a lot Vladislav for your response. Could you please also explain what is purpose of Intent(RecognizerIntent.ActionRecognizeSpeech)?

In Android Intent is used to pass some parameters. the type of Intent here is Recognize speech. You also pass the culture (language) and other parameters to the SpeechRecognition.

As for the article, it describes how I created this service. It is now available in .NET MAUI CommunityToolkit, so it's better to use this package

I tried to move content of Listen method to run in background :
await Task.Run(async () => { // Now on background thread. await startSpeechRecognition(); });
but received error that "SpeechRecogniser should be used only from application main thread"
as I mentioned from beginning I need that application will listen all the time to user's speech and will perform some operation depends from user commands.
do you think it possible?

The application must be in foreground, otherwise it will not work, because it can be treated as a spyware