声音转换成文字
来源:互联网 发布:南宁java招聘亿阳信通 编辑:程序博客网 时间:2024/04/29 16:14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib;
namespace tryreco
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SpRecognition cc = new SpRecognition();
cc.MessageBegin();
cc.BeginRec(textBox1); //Fan:把内容输入textbox1
}
private void button2_Click(object sender, EventArgs e)
{
SpRecognition cc = new SpRecognition();
cc.MessageEnd();
cc.CloseRec();
}
public class SpRecognition
{
private static SpRecognition _Instance = null;
private SpeechLib.ISpeechRecoGrammar isrg;
private SpeechLib.SpSharedRecoContextClass ssrContex = null;
private System.Windows.Forms.Control cDisplay; //fan:用来显示语音转化后的文本
public System.Windows.Forms.TextBox textbox; //fan:增加textbox在SpRecognition 类
public SpRecognition()
{
ssrContex = new SpSharedRecoContextClass();
isrg = ssrContex.CreateGrammar(1);
SpeechLib._ISpeechRecoContextEvents_RecognitionEventHandler recHandle =
new _ISpeechRecoContextEvents_RecognitionEventHandler(ContexRecognition);
ssrContex.Recognition += recHandle;
}
public void BeginRec(Control tbResult)
{
isrg.DictationSetState(SpeechRuleState.SGDSActive);
cDisplay = tbResult;
//cDisplay.Text = "dddddddddd"; 测试,可以成功在textbox1那里显示出来
}
public static SpRecognition instance()
{
if (_Instance == null)
_Instance = new SpRecognition();
return _Instance;
}
public void CloseRec()
{
isrg.DictationSetState(SpeechRuleState.SGDSInactive);
}
private void ContexRecognition(int iIndex, object obj, SpeechLib.SpeechRecognitionType type, SpeechLib.ISpeechRecoResult result)
{
cDisplay.Text += result.PhraseInfo.GetText(0, -1, true);
}
public void MessageBegin()
{
textbox =new TextBox() ;
textbox.Text = "Notice :this time ,it Begin recoginse";
MessageBox.Show(textbox.Text);
}
public void MessageEnd()
{
textbox = new TextBox();
textbox.Text = "Notice :this time ,it End recoginse";
MessageBox.Show(textbox.Text);
}
}
}
}
- 声音转换成文字
- 将声音转换成文字
- 语音转换成文字
- 扫描件转换成文字
- 时间参数转换成文字
- 图片转换成文字的方法介绍
- 图片转换成文字的方法介绍
- 手机图片转换成文字怎么办
- 怎么把图片文字转换成文字
- 如何将视频转换成文字
- 扫描图片转换成文字怎么转
- 数字图像处理 图像转换成文字(bmp2txt)
- 图片转换成文字的在线转换方法
- 图像转换成文本
- 图像转换成文本
- 金额数字(小写)转换成文字(大写)
- 仿心有灵犀将语音转换成文字的Demo
- 扫描图片转换成文字的软件哪个最好
- 对于调试相当有用的一句话
- Professional XNA Game Programming Chapter1 的例子
- Professional XNA Game Programming Chapter2 的例子
- 用C#读取数码相片的EXIF信息(一)
- 推荐一个很小的但是功能比较全的数据库系统:MS SQL ADMIN
- 声音转换成文字
- 如何编写高质量的程序 命名规则
- 颓废不一定人生无味
- 清除sybase 日志文件的过程
- c++ 异常处理与错误号之间的选择
- VC入门的一条路
- uClinux如何添加reboot命令
- 烧写S3C2410 linux成功,小小庆祝一下
- 如何在uClinux上添加用户程序