用C#實現語音技術
2007/1/27 15:22:39
“電腦朗讀”(英文)一個很好的觸發點,通過它可以實現電子小說閱讀、英文聽力測試、英文單詞學習...
下面的Speech已對MSTTS作了簡單封裝。
1.安裝好MSTTS(如果你有裝金山詞霸,系統就已經安裝了),可以在winnt\speech中打到vtxtauto.tlb文件;
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
如果用vs.net開發,可直接生成項目就可以了。
5.發音實現
//========================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;
///
/// 必需的設計器變量。
///
private System.ComponentModel.Container components = null;
public demo()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
//
}
///
/// 清理所有正在使用的資源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 23);
this.label1.TabIndex = 0;
this.label1.Text = "輸入要朗讀的文字:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(24, 48);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(248, 21)
下一頁
返回列表
返回首頁
主站蜘蛛池模板:
黄色片在线播放|
中文亚洲av片不卡在线观看|
狠狠色综合网站久久久久久久|
国产不卡视频在线|
2022男人天堂|
女人18毛片水最多|
中文字幕无线码免费人妻|
机机对机机的30分钟免费软件|
亚洲精品人成无码中文毛片|
精品无人区一区二区三区|
国产亚洲精品国产福利在线观看|
亚洲欧美日韩人成|
国产麻豆天美果冻无码视频|
公的大龟慢慢挺进我的体内视频|
韩国男男腐啪GV肉视频|
国产精品亚洲专区一区|
99久久人妻无码精品系列|
思思99热在线观看精品|
久久久久久夜精品精品免费啦
|
国产精品久久福利网站|
999精品在线|
奇米色在线视频|
一本大道香蕉视频在线观看|
欧美军同性videosbest|
人人婷婷色综合五月第四人色阁|
精品欧美军人同性videos|
国产一级淫片免费播放|
香蕉视频国产在线观看|
国产成人精品一区二区秒拍|
六月婷婷中文字幕|
国产老熟女网站|
9999热视频|
夜夜高潮夜夜爽夜夜爱爱|
rewrewrwww63625a|
妖精视频免费网站|
两个人看的www视频免费完整版|
护士们的放荡交换全文|
久久亚洲精品视频|
日本高清免费一本视频无需下载|
九九视频高清视频免费观看|
欧美va亚洲va在线观看|