欢迎光临
我们一直在努力

dotnet语音技术实现_asp.net实例

建站超值云服务器,限时71元/月

语音实现


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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » dotnet语音技术实现_asp.net实例
分享到: 更多 (0)

相关推荐

  • 暂无文章