C# 语音识别

本文介绍了如何在C#桌面程序中实现语音识别,重点使用了百度的语音识别API。作者将关键代码封装为类,并依赖json.net进行JSON解析。要使用这个功能,开发者需要先申请百度语音识别的token和apikey。
摘要由CSDN通过智能技术生成

C#桌面程序希望使用语音识别 将语音转成文字有很多方法

使用讯飞变得比较麻烦,主要是因为所有平台都需要用sdk,不知道是不是不能用web调用(没有研究委屈,按道理应该有。。。)

下面在使用百度的语音识别来完成这个工作,主要代码来自网友,我写成了类(具体从哪里来的我忘了,在此感谢)


找到原作者 http://www.cnblogs.com/bfyx/p/3915297.html


下面是我改写的音频转文字的类,由于返回json,所以用了json.net来解析返回结果,类前面的token和apikey需要自己去申请百度语音识别

传送门 http://yuyin.baidu.com

using System;
using System.Text;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;

namespace TestBaiDuAudio2Txt
{
    public class AudioToString
    {
        string token = "";//你自己注册百度语音识别所建立的app给的
        string apiKey = "";//同上
        string secretKey = "";<span style="font-family: Arial, Helv
Speech Recognition This sample demonstrates the capabilities of the Speech API, which comes standard with Microsoft Windows XP Tablet PC Edition 2005. Although SAPI is less programmed for than other APIs, it's extremely rich and similar enough to the handwriting recognition APIs that it can be easily learned by those programming Microsoft Windows XP Tablet PC Edition 2005. You must create an Interop wrapper for the SAPI DLL. This can be done by using the "Add Reference..." capability, selecting the COM tab, and selecting the "Microsoft Speech Object Library." Once that's done, and the SpeechLib namespace is imported, things are quite similar to programming handwriting recognition using the Tablet PC Platform SDK. A recognizer is created (in this case, an in-process SpInProcRecognizer) and generates a context (type SpInProcRecoContext) that is associated with the particular recognition. Events associated with the recognition process are the Hypothesis, Recognition, and EndStream events. A large number of Hypothesis events will be generated while only one Recognition and EndStream events will be associated with a particular recognition attempt. The sample provides a standard file dialog to open a user-supplied .WAV file. Recognition occurs against this file, with the results placed in a RichTextEdit box. The technique for iterating over alternative possibilities is also shown, although that output is directed to the Debug console. This sample requires: Visual Studio 2005 Microsoft Windows XP Tablet PC Edition 2005
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值