国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

在C#中使用微軟AGENT之TTS

2024-07-21 02:26:35
字體:
來源:轉載
供稿:網友
微軟agent簡介 

微軟agent api能夠提供卡通角色的顯示,另外,它還可以支持語音識別,因此應用軟件可以對語音命令作出反應,而卡通角色可以通過合成的語音、錄制好的音頻信號或文字對命令作出反應。

使用微軟agent的要求

要使用該技術,我們必須有下面的組件: 

·微軟agent核心組件 

·微軟agent中的卡通角色━━genie、merlin、robby和peedy 

·微軟speech api 4.0a運行時間庫 

·微軟語音識別引擎 

·lernout和hauspie文字-語音引擎 

上面的所有這些組件都可以從http://microsoft.com/products/msagent/downloads.htm下載。 

語音技術簡介 

文字-語音轉換指的是計算機將文字信息轉換為合成語音進行輸出,語音識別是指計算機能夠識別出說話者所說的話,接受說話者的命令和輸入的數據。 

語音識別和文字-語音轉換都需要用到相關的引擎,幾乎所有的語音識別引擎都是將輸入的語音數據轉換為與特定引擎相關的音素,然后這些音素被轉換為應用程序能夠使用的文字。 

文本-語音轉換的二種方式: 

1、合成文本-語音轉換 

2、連續文本-語音轉換 

合成文本-語音轉換方式: 

在合成的發音方式中,引擎處理每個單詞,并產生該單詞的發音音素,然后這些音素被轉入一個復雜的算法中,模仿人類的發聲方式,生成語音。 

連續文本-語音轉換方式: 

在連續文本-語音轉換方式中,引擎對文本信息進行處理,從一個預先錄制好的語音庫中找出句子、單詞和短語,在這種方式中,生成的語音是連續的。

語音應用程序的編程接口 

微軟語音應用程序編程接口在win32(windows 95、windows nt)下使用了ole組件對象模式(com)架構,微軟的agent架構在合成語音輸出中使用了微軟語音應用程序編程接口(sapi),還使用sapi支持語音輸入(語音識別sr或文本-語音轉換tts)。微軟的agent定義了讓應用程序訪問其服務的接口,使得應用程序能夠控制角色動畫、支持用戶輸入事件,指定輸出方式。 

角色窗口 

在微軟agent應用程序中,卡通角色是在它們各自的窗口中被顯示的,這些窗口總是出現在z軸順序的最頂端。用戶可以通過鼠標左鍵拖動角色移動角色所在的窗口,角色的圖像隨著指針而移動。 

說話汽球圈 

除了語音輸出外,動畫角色還支持以卡通類型說話汽球圈形式的文字字幕,角色說話時,所說的文字就出現在汽球圈兒中,當說完時,汽球圈也就不見了。 

在互聯網網頁中使用微軟agent 



要在互聯網網頁中使用微軟agent服務,可以在網頁中的或元素中使用html標記,指定控制的clsid(類標識符),另外,還需要使用codebase參數指定微軟agent的安裝文件的位置和版本號。 

我們可以使用vbscript、javascript和jscript在互聯網網頁中使用微軟agent。

600){this.height=this.height*600/this.width;this.width=600;}" border=0>

在.net架構中使用微軟agent 

微軟agent不是以activex控制dll的形式提供的。要在.net中使用它,可以使用由.net框架sdk提供的aximp.exe工具: 

aximp -->> activex控制-win窗體組合體生成器  

  syntax: aximp [/? | [[/source] ocxname]] 

aximp agentctl.dll 

上面的命令生成二個文件:axagentobjects.dll和agentobjects.dll。通過使用這二個文件,我們就可以在.net中使用agent了。


c#中的微軟agent: 

要在c#中使用微軟agent,我們必須在程序中添加二個dll文件:axagentobjects.dll和agentobjects.dll。加載動畫角色的代碼是相當簡單的:

axagent.characters.load("genie",(object)"c:/windows/msagent/chars/genie.acs"); 

character = axagent.characters["genie"]; 

file://將語言設置為美國英語 

character.languageid = 0x409; 

file://該行代碼顯示角色 

character.show(null);  


讓角色說話的代碼如下所示: 

  character.speak ("welcome you sir visit www.onlinecsharpteach.netfirms.com ",null); 

下面我們來看一個例子: 

the example:  




using system;  

using system.drawing;  

using system.winforms;  

using agentobjects;  

public class hello: form  

{  

private system.componentmodel.container components;  

private system.winforms.button button2;  

private system.winforms.button button1;  

private system.winforms.textbox textbox1;  

private axagentobjects.axagent axagent;  

private iagentctlcharacterex character;  

public hello()  

{  

initializecomponent();  

}  

public static void main(string[] args)  

{  

application.run(new hello());  

}  

private void initializecomponent()  

{  

this.components = new system.componentmodel.container();  

this.button1 = new system.winforms.button();  

this.button2 = new system.winforms.button();  

this.textbox1 = new system.winforms.textbox();  

this.axagent = new axagentobjects.axagent();  

axagent.begininit();  

button2.click += new system.eventhandler(button2_click);  

button1.location = new system.drawing.point(88, 208);  

button1.backcolor =  

(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);  

button1.size = new system.drawing.size(152, 32);  

button1.tabindex = 1;  

button1.text = "load character";  

button2.location = new system.drawing.point(120, 240);  

button2.backcolor =  

(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);  

button2.size = new system.drawing.size(96, 24);  

button2.tabindex = 2;  

button2.text = "speak";  

textbox1.location = new system.drawing.point(48, 8);  

textbox1.text = " ";  

textbox1.multiline = true;  

textbox1.tabindex = 0;  

textbox1.size = new system.drawing.size(248, 200);  

textbox1.backcolor =  

(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)128, (byte)128);  

this.text = "msagent demo";  

this.autoscalebasesize = new system.drawing.size(5, 13);  

this.windowstate = system.winforms.formwindowstate.maximized;  

this.backcolor =  

(system.drawing.color)system.drawing.color.fromargb((byte)255, (byte)192, (byte)192);  

this.clientsize = new system.drawing.size(344, 301);  

this.controls.add(button2);  

this.controls.add(button1);  

this.controls.add(textbox1);  

this.controls.add(axagent);  

button1.click += new system.eventhandler(button1_click);  

axagent.endinit();  

}  

protected void button2_click(object sender, system.eventargs e)  

{  

if(textbox1.text.length == 0)  

return;  

character.speak(textbox1.text, null);  

}  

protected void button1_click(object sender, system.eventargs e)  

{  

openfiledialog openfiledialog = new openfiledialog();  

openfiledialog.addextension = true;  

openfiledialog.filter = "microsoft agent characters (*.acs)|*.acs";  

openfiledialog.filterindex = 1 ;  

openfiledialog.restoredirectory = true ;  

if(openfiledialog.showdialog() != dialogresult.ok)  

return;  

try { axagent.characters.unload("characterid"); }  

catch { }  

axagent.characters.load("characterid", (object)openfiledialog.filename);  

character = axagent.characters["characterid"];  

character.languageid = 0x409;  

character.show(null);  

character.play ("announce");  

character.speak ("welcome you sir",null);  

}

 }  


 
輸出: 

600){this.height=this.height*600/this.width;this.width=600;}" border=0>

600){this.height=this.height*600/this.width;this.width=600;}" border=0>

結束語: 

微軟的agent api提供了支持動畫角色顯示的服務,被配置為ole automation(com)服務器時,它能夠使多個被稱為客戶或客戶端應用軟件的應用程序同時托管或使用其動畫、輸入、輸出服務。 
 

菜鳥學堂:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵丘县| 濉溪县| 布拖县| 自贡市| 青州市| 山西省| 乐业县| 梅河口市| 龙海市| 梨树县| 南溪县| 清镇市| 保靖县| 惠州市| 郑州市| 静安区| 河西区| 广元市| 南丹县| 天长市| 贵南县| 永新县| 静海县| 江津市| 金湖县| 崇仁县| 东台市| 大安市| 铁力市| 东莞市| 东方市| 陆河县| 黄骅市| 绥中县| 彩票| 岳池县| 六枝特区| 类乌齐县| 长岛县| 陕西省| 错那县|