本文整理汇总了C#中SpeechSynthesizer.SelectVoiceByHints方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechSynthesizer.SelectVoiceByHints方法的具体用法?C# SpeechSynthesizer.SelectVoiceByHints怎么用?C# SpeechSynthesizer.SelectVoiceByHints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpeechSynthesizer
的用法示例。
在下文中一共展示了SpeechSynthesizer.SelectVoiceByHints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: speak
public void speak(string word)
{
try
{
SpeechSynthesizer voice = new SpeechSynthesizer();
switch (cmbbox.SelectedIndex)
{
case 0:
voice.SelectVoiceByHints(VoiceGender.NotSet);
break;
case 1:
voice.SelectVoiceByHints(VoiceGender.Male);
break;
case 2:
voice.SelectVoiceByHints(VoiceGender.Female);
break;
case 3:
voice.SelectVoiceByHints(VoiceGender.Neutral);
break;
default:
voice.SelectVoiceByHints(VoiceGender.NotSet);
break;
}
voice.SpeakAsync(word);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例2: BuildSynth
private SpeechSynthesizer BuildSynth(string gender)
{
var synth = new SpeechSynthesizer();
if (!string.IsNullOrEmpty(gender) && gender.ToUpper() == "BOY")
{
synth.SelectVoiceByHints(VoiceGender.Male);
}
else
{
synth.SelectVoiceByHints(VoiceGender.Female);
}
return synth;
}
示例3: SpeechOutput
private SpeechOutput()
{
_synth = new SpeechSynthesizer();
_synth.SelectVoiceByHints(VoiceGender.Female);
_synth.Rate = 1;
_synth.Volume = 90;
}
示例4: Voice
// read text
private static void Voice(string toSpeak)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SelectVoiceByHints(VoiceGender.Female);
synth.Rate = 1;
synth.Speak(toSpeak);
}
示例5: Speech
public void Speech(String source)
{
SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.SelectVoiceByHints(VoiceGender.Female);
speaker.Volume = 100;
speaker.Rate = 0;
speaker.Speak(source);
}
示例6: Speakthread
private void Speakthread(object text)
{
SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.Rate = -3;
speaker.Volume = 100;
speaker.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child);
speaker.Speak((string)text);
}
示例7: Tts
/*
* Text to Speech
*/
public Tts()
{
//create speech synthesizer
tts = new SpeechSynthesizer();
tts.SetOutputToDefaultAudioDevice();
//set voice
tts.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT"));
}
示例8: Form1
public Form1()
{
InitializeComponent();
speaker = new SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
initialize();
}
示例9: Text2Speech
public Text2Speech()
{
synthesizer = new SpeechSynthesizer();
synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
synthesizer.Rate = 0;
AllVoices = new List<VoiceInfo>();
}
示例10: Main
static void Main(string[] args)
{
Console.WriteLine("Enter text to speak:");
string TextToSpeak = Console.ReadLine();
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.Volume = 100; //1 to 100
ss.Rate = -3; // -10 to +10
ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
ss.SpeakAsync(TextToSpeak);
Console.Read();
}
示例11: Play
public void Play()
{
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SelectVoiceByHints(VoiceGender, VoiceAge, VoicePosition, new CultureInfo(CultureInfo));
synth.SetOutputToDefaultAudioDevice();
synth.Volume = Volume;
synth.Rate = Rate;
synth.Speak(Text);
}
}
示例12: Server
public Server()
{
Form = new CustomPerPixelAlphaForm();
FormSetProperties();
FormDock();
Form.Show();
var clientBuildDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\..\\..\\Reflecta.Client\\bin";
var clientStartInfo = new ProcessStartInfo
{
FileName = clientBuildDirectory + "\\Client.exe",
WorkingDirectory = clientBuildDirectory,
WindowStyle = ProcessWindowStyle.Minimized
};
Client = Process.Start(clientStartInfo);
OpenPipes();
SpeechSynthesizer = new SpeechSynthesizer();
SpeechSynthesizer.SelectVoiceByHints(VoiceGender.Female);
SpeechSynthesizer.SpeakStarted += SpeechSynthesizer_SpeakStarted;
SpeechSynthesizer.VisemeReached += SpeechSynthesizer_VisemeReached;
SpeechSynthesizer.SpeakCompleted += SpeechSynthesizer_SpeakCompleted;
SpeechRecognitionEngine = new SpeechRecognitionEngine();
SpeechRecognitionEngine.UnloadAllGrammars();
SpeechRecognitionEngine.LoadGrammar(new Grammar(new GrammarBuilder(KnownCommands)));
SpeechRecognitionEngine.SpeechRecognized += SpeechRecognitionEngine_SpeechRecognized;
SpeechRecognitionEngine.SetInputToDefaultAudioDevice();
SpeechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
KinectSensor = KinectSensor.GetDefault();
KinectSensor.Open();
BodyFrameSource = KinectSensor.BodyFrameSource;
BodyFrameReader = BodyFrameSource.OpenReader();
BodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived;
Bodies = null;
BodyDESP = new DESPQuaternion[(int) MoCapKinectBone.Count];
for (var i = 0; i < (int) MoCapKinectBone.Count; i++)
BodyDESP[i] = new DESPQuaternion();
HighDefinitionFaceFrameSource = new HighDefinitionFaceFrameSource(KinectSensor);
HighDefinitionFaceFrameSource.TrackingQuality = FaceAlignmentQuality.High;
HighDefinitionFaceFrameReader = HighDefinitionFaceFrameSource.OpenReader();
HighDefinitionFaceFrameReader.FrameArrived += HighDefinitionFaceFrameReader_FrameArrived;
FaceAlignment = new FaceAlignment();
FaceDESP = new DESPQuaternion();
FaceExpressionDESP = new DESPFloat[(int) MoCapKinectFacialExpression.Count];
for (var i = 0; i < (int) MoCapKinectFacialExpression.Count; i++)
FaceExpressionDESP[i] = new DESPFloat();
}
示例13: Speaker
//static constructor of the Class, which initialises the SpeechSynthesizer , and registers the several events
static Speaker()
{
mainSynthesizer=new SpeechSynthesizer();
mainSynthesizer.SelectVoiceByHints(DataStore.CurrentUser.SynthesizerVoiceGender);
mainSynthesizer.SetOutputToDefaultAudioDevice();
DataStore.VoiceGenderChanged += DataStore_VoiceGenderChanged; //DataStore's VoiceGenderChanged event which occurs when the gender of the TTS engine has changed
MainWindow.VolumeChanged += MainWindow_VolumeChanged; //MainWindow VolumeChanged event which occurs when Volume of the TTS engine changes
MainWindow.RateChanged += MainWindow_RateChanged; //MainWindow RateChanged event which occurs when Synthesis Rate of the TTS engine changes
//mainSynthesizer.SpeakStarted += MainSynthesizer_SpeakStarted;
//mainSynthesizer.SpeakCompleted += MainSynthesizer_SpeakCompleted;
}
示例14: VocalSynthesis
public static void VocalSynthesis(string text, string culture, string filename, string voice)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SelectVoiceByHints(VoiceGender.Neutral, VoiceAge.NotSet, 1, new CultureInfo(culture));
if (!string.IsNullOrEmpty(filename))
synth.SetOutputToWaveFile(filename);
if (!string.IsNullOrEmpty(voice))
synth.SelectVoice(voice);
synth.Speak(text);
}
示例15: Speak
public static void Speak(string message)
{
// Initialize a new instance of the SpeechSynthesizer.
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
// Speak a string synchronously.
synth.Speak(message);
}
}