您的位置:首页 > 其它

语音播报

2015-12-25 14:29 302 查看
相关: http://blog.sina.com.cn/s/blog_45c379c001016d7u.html
DLL :


备注:

1、运行TTSrepair.exe,修护系统语音功能。(确保系统语音相关组件能正常使用)

2、添加 Interop.SpeechLib.dll 和 SpeechLib.dll
3、如无语音库,请安装“girl_xialkun.exe”(为一种语音库)
下载地址:http://download.iciba.com/pwpe/girl_xiaokun.exe

注:win7系统默认语音库为microsoft lily chinese,阉割版的系统没有相关功能

using SpeechLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SAMPLETTSENGLib;

namespace 语音播报
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

//检查
if (comboBox1.SelectedIndex < 0)
{
MessageBox.Show("请选择语音库!", "Message", MessageBoxButtons.OK);
return;
}
if (textBox1.Text == "")
{
MessageBox.Show("请在文本中输入将要读取的信息!", "Message", MessageBoxButtons.OK);
return;

}

//执行朗读
SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
SpVoice sv = new SpVoice();
//用第3个语音库,根据系统所安装语音库进行选择
sv.Voice = sv.GetVoices().Item(comboBox1.SelectedIndex);
sv.Speak(textBox1.Text, flag);//播放

}

private void Form1_Load(object sender, EventArgs e)
{
//将所有语音库加载到combox
List<string> lst = new List<string>();
ISpeechObjectTokens obj = new SpVoice().GetVoices();
for (int i = 0; i < obj.Count; i++)
{
comboBox1.Items.Add(obj.Item(i).GetDescription());

}

}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: