xml code

----------------------------------------------

<Page

x:Class="MyApp.MainPage"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="using:MyApp"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d"

Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel>

<TextBox Name="txtInput" Height="100" TextWrapping="Wrap"/>

<Button Margin="0,15,0,10" Content="点击这里,开始识别" Click="onClick" HorizontalAlignment="Stretch"/>

<TextBlock Name="tbDisplay" FontSize="16" Margin="3,13,0,0" Foreground="Yellow"/>

</StackPanel>

</Page>

C#  code

-----------------------------------------------------

public sealed partial class MainPage : Page

{

public MainPage()

{

this.InitializeComponent();

this.NavigationCacheMode = NavigationCacheMode.Required;

}

/// <summary>

/// Invoked when this page is about to be displayed in a Frame.

/// </summary>

/// <param name="e">Event data that describes how this page was reached.

/// This parameter is typically used to configure the page.</param>

protected override void OnNavigatedTo(NavigationEventArgs e)

{

// TODO: Prepare page for display here.

// TODO: If your application contains multiple pages, ensure that you are

// handling the hardware Back button by registering for the

// Windows.Phone.UI.Input.HardwareButtons.BackPressed event.

// If you are using the NavigationHelper provided by some templates,

// this event is handled for you.

}

private async void onClick(object sender, RoutedEventArgs e)

{

Button btn = sender as Button;

btn.IsEnabled = false;

using (SpeechRecognizer recognizer = new SpeechRecognizer())

{

try

{

// 编译所有语法协定

SpeechRecognitionCompilationResult compilationResult = await recognizer.CompileConstraintsAsync();

if (compilationResult.Status == SpeechRecognitionResultStatus.Success)

{

// 开始识别

SpeechRecognitionResult recogResult = await recognizer.RecognizeAsync();

// 显示识别结果

if (recogResult.Status == SpeechRecognitionResultStatus.Success)

{

tbDisplay.Text = "识别完成。";

txtInput.Text = recogResult.Text;

}

}

}

catch (Exception ex)

{

tbDisplay.Text = "异常:" + ex.Message;

}

}

btn.IsEnabled = true;

}

}

uwp 之语音识别的更多相关文章

  1. uwp 自定义语音识别规则

    xml  code ---------------------------------------------------- <Page x:Class="MyApp.MainPage ...

  2. Win10/UWP开发—使用Cortana语音指令与App的前台交互

    Win10开发中最具有系统特色的功能点绝对少不了集成Cortana语音指令,其实Cortana语音指令在以前的wp8/8.1时就已经存在了,发展到了Win10,Cortana最明显的进步就是开始支持调 ...

  3. 提供给Android和iOS开发人员的UWP移植向导

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:前几天微软发布了一个针对Android和iOS开发人员理解Windows Apps概念 ...

  4. Win10/UWP开发—使用Cortana语音指令启动前台App

    这两天进群(53078485)找大咖的童鞋比较多,只是大咖比较忙,目前Demo还没有要到,这里先给大家转载一篇Aran大咖的博客学习下,以下是原文: Win10开发中最具有系统特色的功能点绝对少不了集 ...

  5. Windows 10 IoT Serials 5 - 如何为树莓派应用程序添加语音识别与交互功能

    都说语音是人机交互的重要手段,虽然个人觉得在大庭广众之下,对着手机发号施令会显得有些尴尬.但是在资源受限的物联网应用场景下(无法外接鼠标键盘显示器),如果能够通过语音来控制设备,与设备进行交互,那还是 ...

  6. UWP 手绘视频创作工具技术分享系列 - 有 AI 的手绘视频

    AI(Artificial Intelligence)正在不断的改变着各个行业的形态和人们的生活方式,图像识别.语音识别.自然语言理解等 AI 技术正在自动驾驶.智能机器人.人脸识别.智能助理等领域中 ...

  7. 老周发布 UWP 应用的隐私策略(通用)

    UWP 应用隐私策略 前注  本声明通用于老周所发布的所有 UWP 应用,下文简称“应用”.开发者全称:周家安,下文简称“老周”. 1.免责声明 您在使用应用过程中,请遵守<中华人民共和国宪法& ...

  8. C#的语音识别 using System.Speech.Recognition;

    using System; using System.Collections.Generic; using System.Linq; using System.Speech.Recognition; ...

  9. UWP 律师查询 MVVM

    APP简介 律师查询是基于聚合数据的律师查询接口做的,这个接口目前处于停用状态,但是,由于我是之前申请的,所以,还可以用,应该是无法再申请了. 效果图 开发 一.HttpHelper 既然是请求接口的 ...

随机推荐

  1. 学生信息管理系统--基于jsp技术和MySQL的简单增删改查

    web实现增删改查的方式有很多啊,对于初学者来说当然是要先了解各部分的传值的方式.本篇博客从jsp技术的最基础方面进行说明. 一.什么是jsp技术 首先,我们要了解什么是jsp技术. jsp技术是基于 ...

  2. 【论文阅读】Socially aware motion planning with deep reinforcement learning-annotated

    目录 摘要部分: I. Introduction 介绍 II. Background 背景 A. Collision Avoidance with DRL B. Characterization of ...

  3. Day7 break continue goto 以及打印三角形练习.

    break break在任何循环语句中的主体部分,均可以用break控制循环流程.break用于强行退出循环,不执行循环中剩余的语句. (break语句也在switch中使用) package com ...

  4. Spring总结之IOC

    一.Spring IOC 简介 IOC(Inverse of control):控制反转,又称作依赖注入,主要是把创建对象和查找依赖对象的控制权交给IOC容器,由IOC容器管理对象的生命周期,是一种重 ...

  5. python + pytest基本使用方法(断言)

    #pytest 的基本用法# 安装: pip install pytest#在当前目录下运行 : 输入 pytest# 1.断言#功能:用于计算a与b相加的和def add(a,b): return ...

  6. LeetCode通关:听说链表是门槛,这就抬脚跨门而入

    分门别类刷算法,坚持,进步! 刷题路线参考:https://github.com/youngyangyang04/leetcode-master       https://github.com/ch ...

  7. 网络损伤仪WANsim的带宽限制功能

    带宽限制功能 带宽限制功能是网络损伤仪WANsim的第一项损伤功能.进入WANsim的报文首先会经过报文过滤器的处理,随后,就会进入带宽限制. 点击虚拟链路,就可以进入网络损伤界面,对报文进行带宽限制 ...

  8. THE MINTO PYRAMID PRINCIPLE

    金字塔原理:(重点突出,逻辑清晰.层次分明,简单易懂的思考方式.沟通方式.规范的动作.) 结构:结论先行,以上统下,归类分组,逻辑递进.先重要后次要,先总结后具体,先框架后细节,先结论后原因,先结果后 ...

  9. 定时任务quartz

      pom引入 <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>qua ...

  10. Tr0ll靶机

    一.主机探测 二.信息收集 进入21端口 发现文件并下载 下载文件 作为字典进行登录爆破 用字典爆破 ssh登录 查找信息   /etc/init.d/ssh start scp root@192.1 ...