为项目添加语音 [英] add voice to a project

查看:141
本文介绍了为项目添加语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为C#项目添加特定的语音,以便它可以在另一台PC上运行?


speechSynth.SelectVoice(" Microsoft Server Speech Text语音(nl-NL,Hanna)");只有当声音安装在另一台电脑上时才会工作。


我在哪里可以找到关于此的教程?

解决方案

嗨Han Brouwer,


感谢您在此发帖。


对于您的问题,您可以使用  < a href ="https://msdn.microsoft.com/en-us/library/system.speech.synthesis.installedvoice(v=vs.110).aspx"> InstalledVoice Class &
得到什么 
Windows中安装的语音合成语音。


< p style ="font-size:13.3333px"> 然后使用  SpeechSynthesizer.SelectVoice
方法(字符串)
 按名称选择特定的语音。


这是一个供你参考的简单示例。

 static void Main( string [] args)
{
//初始化SpeechSynthesizer的新实例。
using(SpeechSynthesizer synth = new SpeechSynthesizer())
{

//配置音频输出。

//选择美国英语语音。
synth.SelectVoice(" Microsoft Zira Desktop");

//建立一个提示。
PromptBuilder builder = new PromptBuilder();
builder.AppendText(" That is a big pizza!");

//说出提示。
synth.Speak(建造者);
}

}




最好的问候,


温迪


Is it possible to add a specific voice to a C# project so that it can be heart on an other pc?

speechSynth.SelectVoice("Microsoft Server Speech Text to Speech Voice (nl-NL, Hanna)"); wil only work when the voice is installed on the other pc.

Where can I find a tutorial about this?

解决方案

Hi Han Brouwer,

Thank you for posting here.

For your question, you could use InstalledVoice Class to get what speech synthesis voice installed in Windows.

And then use SpeechSynthesizer.SelectVoice Method (String) to select the a specific voice by name.

Here is a simple example for your reference.

   static void Main(string[] args)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                // Configure the audio output.

                // Select the US English voice.
                synth.SelectVoice("Microsoft Zira Desktop");

                // Build a prompt.
                PromptBuilder builder = new PromptBuilder();
                builder.AppendText("That is a big pizza!");

                // Speak the prompt.
                synth.Speak(builder);
            }

        }


Best Regards,

Wendy


这篇关于为项目添加语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆