Windows语音识别对话

时间:2020-08-12 07:11:57

标签: c# windows uwp speech-recognition

如何在UWP应用程序中使用Windows语音识别进行对话?目前,它只能识别我的声音,而不能识别同一对话中其他讲话者的声音。也许,为此存在另一个API吗?

这是我的原始代码:

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);
        }
}

1 个答案:

答案 0 :(得分:1)

SpeechRecognizer不能具体识别人的声音。它将分析当前的输入声音,并通过相应的语法将其转换为文本输出。

因此SpeechRecognizer的理想对话场景是两个人离麦克风不远,说话清晰,并且只有一个人同时讲话。

SpeechRecognizer提供的是一种简单的语音识别服务,它没有提供用于区分两个人的声音并分别识别输出的API。