-->

我如何改变在C#中的语音合成性别和年龄?我如何改变在C#中的语音合成性别和年龄?(how I can

2019-05-17 06:38发布

我想改变的声音的性别和年龄System.Speech在C#。 例如,一个女孩10年却无法找到任何简单的例子来帮我调整参数。

Answer 1:

首先,检查其呼声已通过枚举安装GetInstalledVoices的方法SpeechSynthesizer类,然后用SelectVoiceByHints来选择其中的一种:

using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
    // show installed voices
    foreach (var v in synthesizer.GetInstalledVoices().Select(v => v.VoiceInfo))
    {
        Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
          v.Description, v.Gender, v.Age);
    }

    // select male senior (if it exists)
    synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);

    // select audio device
    synthesizer.SetOutputToDefaultAudioDevice();

    // build and speak a prompt
    PromptBuilder builder = new PromptBuilder();
    builder.AppendText("Found this on Stack Overflow.");
    synthesizer.Speak(builder);
}


Answer 2:

http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voiceage.aspx http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voicegender.aspx

你看看这个?



Answer 3:

首先你需要使用添加引用intialise参考讲话。

然后创建一个事件处理程序,开始说话,那么你可以编辑处理程序中的paramemters。

在处理程序是,你可以改变声音,并使用年龄

synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult);


Answer 4:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Synthesis; // first import this package

    namespace textToSpeech
    {
        public partial class home : Form
        {
            public string s = "pran"; // storing string (pran) to s

            private void home_Load(object sender, EventArgs e)
                {
                    speech(s); // calling the function with a string argument
                }

            private void speech(string args) // defining the function which will accept a string parameter
                {
                    SpeechSynthesizer synthesizer = new SpeechSynthesizer();
                    synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult); // to change VoiceGender and VoiceAge check out those links below
                    synthesizer.Volume = 100;  // (0 - 100)
                    synthesizer.Rate = 0;     // (-10 - 10)
                    // Synchronous
                    synthesizer.Speak("Now I'm speaking, no other function'll work");
                    // Asynchronous
                    synthesizer.SpeakAsync("Welcome" + args); // here args = pran
                }       
         }
    }
  • 这将是更好的选择使用“SpeakAsync”,因为当“说话”功能正在执行/运行让利功能会工作,直到它完成的工作(个人推荐)

更改VoiceGender
VoiceAge公司变更



Answer 5:

这些年龄和性别居然没有用的是。 如果您已经安装在你的窗户很多声音,那么你就可以调用这些参数的具体声音。 否则,它只是假的!



文章来源: how I can change the voice synthesizer gender and age in C#?