uwp 之语音识别
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 之语音识别的更多相关文章
- uwp 自定义语音识别规则
xml code ---------------------------------------------------- <Page x:Class="MyApp.MainPage ...
- Win10/UWP开发—使用Cortana语音指令与App的前台交互
Win10开发中最具有系统特色的功能点绝对少不了集成Cortana语音指令,其实Cortana语音指令在以前的wp8/8.1时就已经存在了,发展到了Win10,Cortana最明显的进步就是开始支持调 ...
- 提供给Android和iOS开发人员的UWP移植向导
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:前几天微软发布了一个针对Android和iOS开发人员理解Windows Apps概念 ...
- Win10/UWP开发—使用Cortana语音指令启动前台App
这两天进群(53078485)找大咖的童鞋比较多,只是大咖比较忙,目前Demo还没有要到,这里先给大家转载一篇Aran大咖的博客学习下,以下是原文: Win10开发中最具有系统特色的功能点绝对少不了集 ...
- Windows 10 IoT Serials 5 - 如何为树莓派应用程序添加语音识别与交互功能
都说语音是人机交互的重要手段,虽然个人觉得在大庭广众之下,对着手机发号施令会显得有些尴尬.但是在资源受限的物联网应用场景下(无法外接鼠标键盘显示器),如果能够通过语音来控制设备,与设备进行交互,那还是 ...
- UWP 手绘视频创作工具技术分享系列 - 有 AI 的手绘视频
AI(Artificial Intelligence)正在不断的改变着各个行业的形态和人们的生活方式,图像识别.语音识别.自然语言理解等 AI 技术正在自动驾驶.智能机器人.人脸识别.智能助理等领域中 ...
- 老周发布 UWP 应用的隐私策略(通用)
UWP 应用隐私策略 前注 本声明通用于老周所发布的所有 UWP 应用,下文简称“应用”.开发者全称:周家安,下文简称“老周”. 1.免责声明 您在使用应用过程中,请遵守<中华人民共和国宪法& ...
- C#的语音识别 using System.Speech.Recognition;
using System; using System.Collections.Generic; using System.Linq; using System.Speech.Recognition; ...
- UWP 律师查询 MVVM
APP简介 律师查询是基于聚合数据的律师查询接口做的,这个接口目前处于停用状态,但是,由于我是之前申请的,所以,还可以用,应该是无法再申请了. 效果图 开发 一.HttpHelper 既然是请求接口的 ...
随机推荐
- 一文搞懂一致性hash的原理和实现
在 go-zero 的分布式缓存系统分享里,Kevin 重点讲到过一致性hash的原理和分布式缓存中的实践.本文来详细讲讲一致性hash的原理和在 go-zero 中的实现. 以存储为例,在整个微服务 ...
- PYTHON2.7安装 pyinstaller出错,不能正常安装
解决方法: pip2.7 install pyinstaller==3.4
- vmare下克隆一台linux
第一步:点击"克隆"按钮,注意,克隆之前选择的机器需要关机 第二步:接下来需要改一下新机器的mac地址,选中新机器,右键"设置"-->"网络适配 ...
- Spring RestTemplate 之exchange方法
●exchange方法提供统一的方法模板进行四种请求:POST,PUT,DELETE,GET (1)POST请求 String reqJsonStr = "{\"code\&quo ...
- bash shell 遍历一个数组
var[@] 数组的一个元素 var=("first" "second" "three") for str in ${var[@]}; d ...
- React中组件之间通信的方式
一.是什么 我们将组件间通信可以拆分为两个词: 组件 通信 回顾Vue系列的文章,组件是vue中最强大的功能之一,同样组件化是React的核心思想 相比vue,React的组件更加灵活和多样,按照不同 ...
- odoo12动作里添加向导
在odoo12的 动作里添加向导例子1:只会在tree视图里显示,不会在form里显示 <act_window id="action_change_stage_ttest" ...
- Python自动化测试面试题-经验篇
目录 Python自动化测试面试题-经验篇 Python自动化测试面试题-用例设计篇 Python自动化测试面试题-Linux篇 Python自动化测试面试题-MySQL篇 Python自动化测试面试 ...
- Visual Studio2019下载最新离线安装包
首先可以参考微软官方的离线安装说明-->点击这里打开 =================================================================== 1. ...
- k8s系列文章第五篇(docker-compose)
更多精彩内容,猛搓这里 目录 一.Docker Compose 1.前言 2.官方介绍 1.Compose 中有两个重要的概念 2.三步骤 3.Compose是Docker官方的开源项目,需要安装! ...