private void button1_Click(object sender, EventArgs e)
{
SoundPlayer win = new SoundPlayer(Application.StartupPath + "\\dog.wav"); //
win = null;
string str = this.textBox1.Text;
// MessageBox.Show(n.ToString());
for (int i = 0; i < str.Length; i++)
{
int keyAscii = int.Parse(str.Substring(i, 1)); //截取从i开始的1位字符
//MessageBox.Show(keyAscii.ToString());
switch (keyAscii)
{
case 1:
win = new SoundPlayer(Application.StartupPath + "\\1.wav"); //取语音值
break;
case 2:
win = new SoundPlayer(Application.StartupPath + "\\2.wav");
break;
case 3:
win = new SoundPlayer(Application.StartupPath + "\\3.wav");
break;
case 4:
win = new SoundPlayer(Application.StartupPath + "\\4.wav");
break;
case 5:
win = new SoundPlayer(Application.StartupPath + "\\5.wav");
break;
case 6:
win = new SoundPlayer(Application.StartupPath + "\\6.wav");
break;
case 7:
win = new SoundPlayer(Application.StartupPath + "\\7.wav");
break;
case 8:
win = new SoundPlayer(Application.StartupPath + "\\8.wav");
break;
case 9:
win = new SoundPlayer(Application.StartupPath + "\\9.wav");
break;
case 0:
win = new SoundPlayer(Application.StartupPath + "\\0.wav");
break;
default:
break;
VBS脚本
Set objVoice = CreateObject("SAPI.SpVoice")
Do while TRUE
Input = InputBox("请输入要讲的话","语音合成器")
if Input = "" then
WScript.Quit
elseif Input = " " then
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
board = objIE.document.parentwindow.clipboardData.GetData("text")
objIE.Quit
Str = replace(board,chr(10),"。。")
objVoice.Speak Str
else
objVoice.Speak Input
end if
loop