基本信息
源码名称:C# 语音合成例子源码(TTS微软库)
源码大小:0.45M
文件格式:.zip
开发语言:C#
更新时间:2019-02-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SpVoiceDemo
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
SpVoiceUtil SpVoiceUtil = new SpVoiceUtil();
private void frmMain_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
List<string> list = SpVoiceUtil.getDescription();
foreach (var item in list)
{
comboBox1.Items.Add(item);
}
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SpVoiceUtil.setDescription(this.Text);
}
//暂停
private void button2_Click(object sender, EventArgs e)
{
SpVoiceUtil.Pause();
}
//继续
private void button5_Click(object sender, EventArgs e)
{
SpVoiceUtil.Resume();
}
//停止
private void button3_Click(object sender, EventArgs e)
{
SpVoiceUtil.Stop();
}
//设置语速
private void trackBar1_Scroll(object sender, EventArgs e)
{
lab_Rate.Text = trackBar1.Value.ToString();
SpVoiceUtil.setRate(trackBar1.Value);
}
//设置音量
private void trackBar2_Scroll(object sender, EventArgs e)
{
lab_Volume.Text = trackBar2.Value.ToString();
SpVoiceUtil.setVolume(trackBar2.Value);
}
//开始朗读
private void button1_Click(object sender, EventArgs e)
{
SpVoiceUtil.Speak(txt_str.Text, CallBack);
}
//写出WAV
private void button4_Click(object sender, EventArgs e)
{
bool isTrue = false;
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
dialog.Title = "保存WAV文件";
dialog.FilterIndex = 2;
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
isTrue = SpVoiceUtil.WreiteToWAV(dialog.FileName, txt_str.Text, DotNetSpeech.SpeechAudioFormatType.SAFT11kHz16BitMono);
}
if (isTrue)
{
MessageBox.Show("输出成功");
}
else {
MessageBox.Show("输出失败");
}
}
//回调信息
private void CallBack(bool b, int InputWordPosition, int InputWordLength)
{
textBox1.AppendText("是否读完:" b.ToString() "\r\n");
textBox1.AppendText("朗读长度:" InputWordPosition.ToString() "\r\n");
textBox1.AppendText("朗读位置:" InputWordLength.ToString() "\r\n");
}
}
}