C# 如何在UWP Windows 10上语音识别电话号码?

C# 如何在UWP Windows 10上语音识别电话号码?,c#,grammar,speech,C#,Grammar,Speech,我有一个问题: 我可以使用语音识别和语法列表来识别特定的命令,但当我需要捕获电话号码或zipcode时,只能捕获第一个号码 我知道我可以使用听写语法,但如果你的应用程序没有互联网会发生什么?右撞车!!! 我正在寻找一个使用ListGrammar或SRGSGrammar.XML的方法,在这个方法中我可以识别同一个方法中的许多数字 private async void Capturar_Click(object sender, RoutedEventArgs e) {

我有一个问题:

我可以使用语音识别和语法列表来识别特定的命令,但当我需要捕获电话号码或zipcode时,只能捕获第一个号码

我知道我可以使用听写语法,但如果你的应用程序没有互联网会发生什么?右撞车!!! 我正在寻找一个使用ListGrammar或SRGSGrammar.XML的方法,在这个方法中我可以识别同一个方法中的许多数字

    private async void Capturar_Click(object sender, RoutedEventArgs e)

    {
        SpeechRecognizer reco = new SpeechRecognizer(language);
        string[] responses = { "1", "2", "3", "4", "5", };



        var listConstraint = new Windows.Media.SpeechRecognition.SpeechRecognitionListConstraint(responses, "Comandos");

        reco.Constraints.Add(listConstraint);

        await reco.CompileConstraintsAsync();
        IAsyncOperation<SpeechRecognitionResult> op = reco.RecognizeAsync();

        reco.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(1.2);
                op.Completed += HandleCompilationCompleted;



    }

    public async void HandleCompilationCompleted(IAsyncOperation<SpeechRecognitionResult> asyncInfo, AsyncStatus status)
    {

        var result = asyncInfo.GetResults();
        string caso = result.Text;


        if (result.Confidence != SpeechRecognitionConfidence.Rejected)
        {

            {
                string recognizedText = result.Text;

                // var dialog2 = new Windows.UI.Popups.MessageDialog(result.Text);

                // await dialog2.ShowAsync();
               resp = resp+ result.Text;
                reco.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(1.2);
            };
            var dialog2 = new Windows.UI.Popups.MessageDialog(resp);

            await dialog2.ShowAsync();
        }
        //  }
    }
private async void Capturar\u单击(对象发送方,路由目标)
{
SpeechRecognizer reco=新的SpeechRecognizer(语言);
字符串[]响应={“1”、“2”、“3”、“4”、“5”、};
var listConstraint=new Windows.Media.SpeechRecognition.SpeechRecognitionListConstraint(响应,“Comandos”);
记录约束。添加(listConstraint);
等待reco.CompileConstraintsAsync();
IAsyncOperation op=reco.RecognizeAsync();
reco.Timeouts.endsilenetimeout=从秒开始的时间跨度(1.2);
op.Completed+=手工合成完成;
}
公共异步无效HandleCompilationCompleted(IAsyncOperation asyncInfo,AsyncStatus状态)
{
var result=asyncInfo.GetResults();
字符串caso=result.Text;
if(result.Confidence!=SpeechRecognitionConfidence.Rejected)
{
{
字符串recognizedText=result.Text;
//var dialog2=newwindows.UI.Popups.MessageDialog(result.Text);
//等待对话框2.ShowAsync();
resp=resp+result.Text;
reco.Timeouts.endsilenetimeout=从秒开始的时间跨度(1.2);
};
var dialog2=newwindows.UI.Popups.MessageDialog(resp);
等待对话框2.ShowAsync();
}
//  }
}

这段代码在uwp(通用Windows 10应用程序)中是的,但如果您只实现了一个数字,它不像听写语法,但我需要一个类似的功能,但不使用互联网。。(口述动作语法使用搜索网页)