C# 如何在C语言中更改语音合成器的性别和年龄?
我想改变性别和年龄的声音系统。例如,一个10岁的女孩,但找不到任何简单的例子来帮助我调整参数。C# 如何在C语言中更改语音合成器的性别和年龄?,c#,speech,synthesizer,C#,Speech,Synthesizer,我想改变性别和年龄的声音系统。例如,一个10岁的女孩,但找不到任何简单的例子来帮助我调整参数。 您看了吗?首先,通过枚举类的方法检查您安装了哪些语音,然后使用选择其中一种: using (SpeechSynthesizer synthesizer = new SpeechSynthesizer()) { // show installed voices foreach (var v in synthesizer.GetInstalledVoices().Select(v =&g
您看了吗?首先,通过枚举类的方法检查您安装了哪些语音,然后使用选择其中一种:
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);
}
这些年龄和性别实际上是没有用的。如果在windows中安装了许多语音,则可以通过这些参数调用特定的语音。否则,它简直就是假的
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是更好的选择,因为当Speak函数执行/运行时,其他函数在完成个人推荐的工作之前都不会工作
首先,您需要使用添加引用来初始化引用语音 然后为已启动的会话创建一个事件处理程序,然后可以编辑该处理程序中的参数 在处理程序中,您可以使用
synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult);
为什么没有喜欢的按钮我不知道,但它有一个[+1]按钮!:Pspeaker.VoiceGender 2,VoiceAge 10;未设置成员名称、儿童、青少年等,为什么要尝试VoiceAge 10?@Pabloonzalez:您可能只安装了一个语音Microsoft Anna,一个女性成年人。如果演讲者是女性,意味着我的系统中没有男性语音,所以我需要下载它?@Pablo:没错,不过,说实话,我不知道从哪里下载。看起来它有一些额外的声音,但我从来没有使用过。好吧,更改声音属性只是我很久以前的一个问题,因为我想知道更多关于语音名称空间的信息。如果真的存在,我会去找一个小女孩的声音哈哈,再次感谢