System.Speech
c#の声の性別と年齢を変更したいと思います。たとえば、10歳の女の子ですが、パラメータを調整するのに役立つ簡単な例が見つかりません。
54529 次
5 に答える
24
まず、クラスのGetInstalledVoices
メソッドを列挙してインストールしたボイスを確認し、 を使用してそのうちの 1 つを選択します。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);
}
于 2012-06-04T12:50:14.477 に答える
12
http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voiceage.aspx http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voicegender.aspx
これを見ましたか?
于 2012-06-04T12:38:36.627 に答える
4
最初に、参照の追加を使用して参照音声を初期化する必要があります。
次に、話し始めたイベントハンドラーを作成し、そのハンドラー内のパラメーターを編集できます。
ハンドラーでは、を使用して声と年齢を変更できます。
synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult);
于 2015-03-16T10:12:25.153 に答える
1
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」関数が実行中/実行中は、動作が完了するまで他の関数が動作しないためです (個人的には推奨)。
于 2015-02-17T15:15:41.247 に答える