关于C#的speechLib使用,我怎么根据电脑已安装的语音库,按照名字选择我需要的语音?

lzhongs 2016-06-19 12:48:01
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选择中英文,都是乱抄袭,根本没搞懂那些下标对应的发音者,我也是醉了...
...全文
1098 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
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); //赋值 } } }
  • 打赏
  • 举报
回复
楼主解决了吗? 42637690qq 如果解决麻烦联系我 感谢!
格拉 2016-06-20
  • 打赏
  • 举报
回复
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {   
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(comboBox1.SelectedIndex);
          
        }
格拉 2016-06-20
  • 打赏
  • 举报
回复
  foreach (ISpeechObjectToken Token in voice.GetVoices(string.Empty, string.Empty))
            {
               comboBox1.Items.Add(Token.GetDescription(49));
            }

111,116

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧