PC6下载站

分类分类

DotNet语音技术实现

关注+2004-10-08作者:蓝点

语音实现


    “电脑发音”(英文)一个很好的触发点,通过它可以实现电子小说阅读、英文听力测试、英文单词学习...
    下面的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
  程序发音啦.


展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消