我愛我的家園!

          成功在于你是否努力,希望在于你是否相信自己!

           

          用C#實現(xiàn)語音技術(shù)

          “電腦朗讀”(英文)一個很好的觸發(fā)點,通過它可以實現(xiàn)電子小說閱讀、英文聽力測試、英文單詞學(xué)習(xí)...

          下面的Speech已對MSTTS作了簡單封裝。

          1.安裝好MSTTS(如果你有裝金山詞霸,系統(tǒng)就已經(jīng)安裝了),可以在winnt\speech中打到vtxtauto.tlb文件;

          2.用.Net SDK自帶的tlbimp工具把vtxtauto.tlb轉(zhuǎn)換成.dll格式:

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

          這時的mstts.dll已成為.net framework運(yùn)行庫的一個類。

          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); //發(fā)音

          專業(yè)的3S站 3s8.cn



          }

          }

          }

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


          4.編譯Bedlang.Speech

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

          如果用vs.net開發(fā),可直接生成項目就可以了。

          5.發(fā)音實現(xiàn)

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

          分別加入Label,TextBox,Button控件各一個到windows Form中,修改它們的屬性,源代碼如下:

          using System;

          using System.Drawing;

          using System.Collections;

          using System.ComponentModel;

          using System.Windows.Forms;

          using System.Data;

          namespace Bedlang

          {

          ///

          /// Form1 的摘要說明。

          ///

          public class demo : System.Windows.Forms.Form

          {

          private System.Windows.Forms.Label label1;

          private System.Windows.Forms.TextBox textBox1;

          private System.Windows.Forms.Button button1;

          專業(yè)的3S站 3s8.cn



          ///

          /// 必需的設(shè)計器變量。

          ///

          private System.ComponentModel.Container components = null;

          public demo()

          {

          //

          // Windows 窗體設(shè)計器支持所必需的

          //

          InitializeComponent();

          //

          // TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼

          //

          }

          ///

          /// 清理所有正在使用的資源。

          ///

          protected override void Dispose( bool disposing )

          {

          if( disposing )

          {

          if (components != null)

          {

          components.Dispose();

          }

          }

          base.Dispose( disposing );

          }

          posted on 2008-09-04 15:02 死神 閱讀(406) 評論(0)  編輯  收藏 所屬分類: 音頻開發(fā)


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計

          公告

          歡迎大家來到我的個人世界!

          常用鏈接

          留言簿(3)

          隨筆分類(5)

          隨筆檔案(9)

          文章分類(37)

          文章檔案(41)

          相冊

          語音技術(shù)

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 廊坊市| 望谟县| 从化市| 吴堡县| 高密市| 左贡县| 长汀县| 许昌县| 榆林市| 科技| 泰兴市| 上林县| 尖扎县| 靖远县| 宜丰县| 荣昌县| 惠来县| 江津市| 沾化县| 嘉定区| 玉林市| 吉木萨尔县| 呼图壁县| 云南省| 三亚市| 盐山县| 达孜县| 郓城县| 双城市| 社会| 徐汇区| 大同县| 新安县| 安平县| 凭祥市| 罗甸县| 新竹县| 泸溪县| 长泰县| 吉木乃县| 蓬莱市|