using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib;
using System.Threading;
private void button2_Click(object sender, EventArgs e)
{
SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
//Item(0)单词男声Sam
//Item(1)单词男声Mike
//Item(2)单词女声Mary
//Item(3)中文发音,如果是英文,就依单词字母一个一个发音
//Speach.instance().AnalyseSpeak(txtContent.Text.Trim());
SpVoiceClass voice=new SpVoiceClass();
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(2);
SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
SpFileStream SpFileStream = new SpFileStream();
string mypath=Application.StartupPath; //应用程序的当前路径
SpFileStream.Open(mypath+@"/voice.wav", SpFileMode, false);
voice.AudioOutputStream = SpFileStream;//设定voice的输出为Stream
voice.Speak(textBox1.Text.Trim(), flag);
voice.WaitUntilDone(Timeout.Infinite);//Using System.Threading; 添加系统的头文件system.THreeding
SpFileStream.Close();
//本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/marvinhong/archive/2008/06/30/2599530.aspx
}
}
}