首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >连续语音识别UWP

连续语音识别UWP
EN

Stack Overflow用户
提问于 2017-07-10 06:20:14
回答 2查看 536关注 0票数 1

我正在使用UWP创建一个智能镜像应用程序,我尝试将应用程序与连续语音识别集成起来,这样用户就可以使用语音来控制它。但是Bing语音REST不支持连续语音识别,所以我还可以使用其他什么吗?如果你有源代码,那就更好了。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-12 09:02:21

我从这段代码中找到了一些想法,希望它也能对你有所帮助。

代码语言:javascript
运行
复制
    public sealed partial class MainPage : Page
{      public MainPage()
    {
        this.InitializeComponent();
    }

    //連続音声認識のためのオブジェクト
    private SpeechRecognizer contSpeechRecognizer;
    private CoreDispatcher dispatcher;


    protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
        //ハックグラウンドスレッドからUIスレッドを呼び出すためのDispatcher
        dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

        //初期化
        contSpeechRecognizer =
            new Windows.Media.SpeechRecognition.SpeechRecognizer();
        await contSpeechRecognizer.CompileConstraintsAsync();

        //認識中の処理定義
        contSpeechRecognizer.HypothesisGenerated +=
            ContSpeechRecognizer_HypothesisGenerated;
        contSpeechRecognizer.ContinuousRecognitionSession.ResultGenerated +=
            ContinuousRecognitionSession_ResultGenerated;


        // 音声入力ないままタイムアウト(20秒位)した場合の処理
        contSpeechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed;

        //認識開始
        await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync();
    }

    private async void ContinuousRecognitionSession_Completed(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionCompletedEventArgs args)
    {
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            textBlock1.Text = "Timeout.";
        });

        // 音声を再度待ち受け
        await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync();
    }

    private async void ContSpeechRecognizer_HypothesisGenerated(
        SpeechRecognizer sender, SpeechRecognitionHypothesisGeneratedEventArgs args)
    {
        //認識途中に画面表示
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            textBlock1.Text = args.Hypothesis.Text;
        });
    }

    private async void ContinuousRecognitionSession_ResultGenerated(
        SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args)
    {
        //認識完了後に画面に表示
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            textBlock1.Text = "Waiting ...";
            output.Text += args.Result.Text + "。\n";
        });
    }
}
票数 2
EN

Stack Overflow用户

发布于 2017-07-10 13:03:34

Windows.Media.SpeechRecognition支持连续​识别​。Microsoft在他们的语音识别与合成样本中有一个这样的例子,或者查看MicrosoftDocsforWindows.​媒体.​语音​识别

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45004966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档