SpVoice spVoice = new SpVoice();
spVoice.Voice = spVoice.GetVoices().Item(7);
spVoice.Speak("你好", SpeechVoiceSpeakFlags.SVSFDefault);
這段代碼可以正常運行,因為我電腦安裝了7種語音庫,但我怎么根據語音庫的名字,比如“Microsoft Sam”,“Microsoft Simplified Chinese”或者“VW Wang”,按照名字選擇voice?而不是像上面代碼或者網上所說的0或1選擇中英文,都是亂抄襲,根本沒搞懂那些下標對應的發音者,我也是醉了...
uj5u.com熱心網友回復:
foreach (ISpeechObjectToken Token in voice.GetVoices(string.Empty, string.Empty))
{
comboBox1.Items.Add(Token.GetDescription(49));
}
uj5u.com熱心網友回復:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(comboBox1.SelectedIndex);
}
uj5u.com熱心網友回復:
樓主解決了嗎? 42637690qq 如果解決麻煩聯系我 感謝!uj5u.com熱心網友回復:
public void setDescription(string name) //傳語音名字 Microsoft Lili{
for (int i = 0; i < spVoice.GetVoices().Count;i++ ) //遍歷語音庫
{
string desc = spVoice.GetVoices().Item(i).GetDescription(); // 獲取名字
if (desc.Equals(name)) //判斷
{
spVoice.Voice = spVoice.GetVoices().Item(i); //賦值
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/141490.html
標籤:C#
上一篇:webApi 使用Owin 實作Oauth2.0認證,token要如何存入資料庫并驗證?
下一篇:如何用C#改音頻檔案的采樣率?
