Search code examples
c#windowsuwpspeech-recognition

Windows Speech Recognition for conversations


How can I use Windows Speech Recognition in UWP application for conversations? For now, it recognizes my voice only, but not voice of another speakers in the same conversation. Maybe, does an another API exist for this?

It's my primitive code:

public sealed partial class MainPage : Page
    {
        private SpeechRecognizer speechRecognizer;

        public MainPage()
        {
            this.InitializeComponent();
            this.speechRecognizer = new SpeechRecognizer();

            Init();
        }

        private async void Init()
        {
            //Compile predifined grammar
            SpeechRecognitionCompilationResult result = await speechRecognizer.CompileConstraintsAsync();

            speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated;

            if (speechRecognizer.State == SpeechRecognizerState.Idle)
            {
                await speechRecognizer.ContinuousRecognitionSession.StartAsync();
            }
        }

        private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender,
                                                                        SpeechContinuousRecognitionResultGeneratedEventArgs args)
        {
            Console.WriteLine(args.Result.Text);
        }
}

Solution

  • SpeechRecognizer does not specifically recognize a person's voice. It will analyze the current input sound and convert it into text output through the corresponding grammar.

    So the ideal conversation scene of SpeechRecognizer is that two people are not far from the microphone, speak clearly, and only one person is talking at the same time.

    What SpeechRecognizer provides is a simple speech recognition service, it does not provide an API to separate the voices of two people and recognize the output separately.