110,534
社区成员
发帖
与我相关
我的任务
分享
public static readonly SpeechSynthesizer Talker = new SpeechSynthesizer();
Talker.Rate = -2;
Talker.Volume = 100;
Talker.SelectVoiceByHints( VoiceGender.Male, VoiceAge.Child, 2, System.Globalization.CultureInfo.CurrentCulture );
Talker.SpeakAsync("hello world");
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Audio Files (.wav)|*.wav";
if (dialog.ShowDialog() == DialogResult.OK)
{
string path = dialog.FileName;
playSound(path);
}
}
private void playSound(string path)
{
System.Media.SoundPlayer player =
new System.Media.SoundPlayer();
player.SoundLocation = path;
player.Load();
player.Play();
}