DotNetSpeech.dll的使用
语音是人类最自然的交互方式,也是现阶段软件用户界面发展的最高目标。微软公司一直积极推动语音技术的发展,并且公布了语音开发平台Speech SDK帮助开发人员实现语音应用。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using DotNetSpeech;
namespace SpeechApp
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button ButtonSynthesis;
private System.Windows.Forms.Button ButtonTTStoWave;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.ButtonSynthesis = new System.Windows.Forms.Button();
this.ButtonTTStoWave = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(272, 144);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "请输入要合成的文本";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 24);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(256, 112);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "欢迎光临Lion互动网络";
//
// ButtonSynthesis
//
this.ButtonSynthesis.CausesValidation = false;
this.ButtonSynthesis.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.ButtonSynthesis.Location = new System.Drawing.Point(24, 160);
this.ButtonSynthesis.Name = "ButtonSynthesis";
this.ButtonSynthesis.TabIndex = 1;
this.ButtonSynthesis.Text = "朗 读";
this.ButtonSynthesis.Click += new System.EventHandler(this.ButtonSynthesis_Click);
//
// ButtonTTStoWave
//
this.ButtonTTStoWave.CausesValidation = false;
this.ButtonTTStoWave.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.ButtonTTStoWave.Location = new System.Drawing.Point(128, 160);
this.ButtonTTStoWave.Name = "ButtonTTStoWave";
this.ButtonTTStoWave.Size = new System.Drawing.Size(136, 23);
this.ButtonTTStoWave.TabIndex = 2;
this.ButtonTTStoWave.Text = "生成声音文件(WAV)";
this.ButtonTTStoWave.Click += new System.EventHandler(this.ButtonTTStoWave_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 191);
this.Controls.Add(this.ButtonTTStoWave);
this.Controls.Add(this.ButtonSynthesis);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form1";
this.Text = "欢迎光临Lion互动网络";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
/// <summary>
/// 朗读
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSynthesis_Click(object sender, System.EventArgs e)
{
try
{
DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
DotNetSpeech.SpVoice vo = new SpVoiceClass();
vo.Speak(this.textBox1.Text,SSF);
}
catch(System.Exception ec)
{
MessageBox.Show(ec.ToString(),"SpeechApp",MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
}
}
/// <summary>
/// 生成声音文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonTTStoWave_Click(object sender, System.EventArgs e)
{
try
{
DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
DotNetSpeech.SpVoice vo = new SpVoiceClass();
System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog();
SFD.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
SFD.Title = "Save to a wav file";
SFD.FilterIndex = 2;
SFD.RestoreDirectory = true;
if(SFD.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
DotNetSpeech.SpeechStreamFileMode SSFM = DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite;
DotNetSpeech.SpFileStream SFS = new DotNetSpeech.SpFileStreamClass();
SFS.Open(SFD.FileName,SSFM,false);
vo.AudioOutputStream = SFS;
vo.Speak(this.textBox1.Text,SSF);
vo.WaitUntilDone(System.Threading.Timeout.Infinite);
SFS.Close();
}
}
catch(System.Exception ec)
{
MessageBox.Show(ec.ToString(),"SpeechApp",MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
}
}
}
}
- PC官方版
- 安卓官方手机版
- IOS官方手机版















下载
下载
下载
下载
下载
下载
oelove婚恋交友系统v8.1 十周年版
sqltoy-orm框架v4.18.13最新版
flutter聊天源码开源完整版
最新版抖商精灵源码4.1暖场升级版
完整版经典C#WinForm实例源码共200个
android5使用poi读取excel源代码
香程互赞宝源码免授权版
百度小程序转微信小程序1.0 最新免费版
BCM文件转换工具(BCM源码格式化)2.7.2 简体中文版
易语言资源网源码下载工具1.0 中文免费版
缩狗图床源码免费版
24个c++游戏源码完整版
嵌入式图像处理C语言源码免费下载
腾讯AI语音合成源码最新免费版
DSShop单用户B2C开源PHP商城系统TP框架1.6 最新版
易之源(最好的源码解析工具)v1.0 免费版
妖气山视频管理系统源码免费下载
魔性机器人网页代码免费下载
净网小助手源码2.2.1 最新完整版
易语言源码误删恢复器1.0 官方版
微擎微赞一物一码抽奖模块源码最新完整版
微信小程序模板源码50个实用程序
Android poi 操作doc excel pdf
Amoli私有云4.2.2 2019.08.08 最新版
LaySNS轻社区系统2.55 最新版
可可网络验证系统9.5 官方版
源码编辑器软件3.4.13 电脑版
Activiti(开源bpm软件)6.0.0 官方最新版
悟空crm系统源码9.0_20191202 官方最新版
帝国网站管理系统7.5.0 官网正式版





Android Studio 源码2.4 免费下载
浮梦QQ工具箱易语言源码1.0免费版
易语言电脑开机自动拍照发指定邮箱源码5.5
ECSHOP家居网上商城模块源码2.7.2免费畅享版
CF狄克改枪源码免费打包下载
仿腾讯新闻门户网站管理系统模板源码v2.0 正
mpycQQ机器人插件源码2016 最新版
似水年华同学录破解版2.2 正式版php源码
UCKeFu客户支持服务平台源码1.2.0 免费下载