Is it possible to listen only user's input and ignore TextToSpeech?

Thamotharan 21 Reputation points
2021-10-13T09:47:28.403+00:00

I have implemented speech recognition in Xamarin with dependency service.

Meanwhile I am using TextToSpeech. If user spoke anything then TextToSpeech need to stop. I have trying it but sometime TextToSpeech string is became a output of speech recognition.

 public void speak(string text)
        {
            Task.Run(async () =>
            {
                textToSpeechCancellationToken = new CancellationTokenSource();                
                await TextToSpeech.SpeakAsync(text, textToSpeechCancellationToken.Token);
            });
        }

I am textToSpeechCancellationToken.Cancel() on EndOfSpeech in SpeechRecognitionListener. But I got which is input of speak function.

Example

speak("hello");
//I am starting speech recognition but I am getting output for speech recognition is "hello"

Please help me.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,340 questions
{count} votes

Your answer

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