繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> 数据库应用 >> DotNet语音技术实现

DotNet语音技术实现

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:46  文字大小:【】【】【
简介:语音实现 “电脑发音”(英文)一个很好的触发点,通过它可以实现电子小说阅读、英文听力测试、英文单词学习... 下面的Speech已对MSTTS作了简单封装。 1.安装好MSTTS,可以在windows\speech中打到vtxtau...
关键字:语音 DotNet 技术

语音实现

“电脑发音”(英文)一个很好的触发点,通过它可以实现电子小说阅读、英文听力测试、英文单词学习...

下面的Speech已对MSTTS作了简单封装。

1.安装好MSTTS,可以在windows\speech中打到vtxtauto.lib文件

2.用.Net SDK自带的tlbimp工具把vtxtauto.tlb转换成.dll格式:

tlbimp vtxtauto.tlb /silent /namespace:mstts /out:mstts.dll

这时的mstts.dll已成为.net framework运行库的一个类。

3.编写一个封装vtxtauto的简单类:Speech .

//========================Speech.cs======================

using System;

using mstts; //MSTTS名称空间

namespace Bedlang{ //定义名称空间

public class Speech{

private VTxtAuto VTxtAutoEx;

public Speech(){

VTxtAutoEx = new VTxtAuto();

VTxtAutoEx.Register(" "," "); //注册COM组件

}

public void Speak(String text){

VTxtAutoEx.Speak(text, 0); //发音

}

}

}

//========================Speech.cs======================

4.编译Bedlang.Speech

csc /target:library /out:Bedlang.dll speech.cs /r:mstts.dll

5.发音实现

//========================demo.cs======================

using System;

using System.Windows.Forms;

using Bedlang; //引用名称空间

public class demo : Form {

public static void Main() {

Application.Run( new demo() );

}

public demo(){

Speech s = new Speech(); //创建一个Speech对象

s.Speak("Bedlang"); //发音

}

}

//========================demo.cs======================

6.编译demo.cs

csc demo.cs /r:bedlang.dll

7.运行demo.exe

程序发音啦.

转自:动态网制作指南 www.knowsky.com

责任编辑:admin
相关文章