//系统需要引用microsoftspeechlibobject.DLL
//此例子需要在窗口中添加一个button和一个textbox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib; //系统要先引用microsoftspeechlibobject.DLL文件
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_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());
SpeechLib.SpVoiceClass voice = new SpVoiceClass(); //定义一个语音对象,网上很多例子,没有这个对象的说明
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(2);
// 选用的语音库编号,系统的语音库可以通过“控制面板”---“语音”来查看
voice.Speak(textBox1.Text.Trim(), flag);
//发音,需要在窗口中添加 一个button和一个textbox,利用box来输入文本
//经过试验能够连读中文和英文
//但是还有点问题,主要是语速、音调不知道如何调节
//本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/marvinhong/archive/2008/06/25/2586232.aspx
}
}
}