找传奇、传世资源到传世资源站!

C# 语音播报中文汉字软件源码(可将声音保存wav文件·)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

输入任意文字,语音朗读这些文字,并可以将朗读的声音 保存成 wav文件
C# 语音播报中文汉字软件源码(可将声音保存wav文件·) C#语言基础-第1张
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 partial class Form1 :Form { public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // this.Hide(); } private void button1_Click_1(object sender, EventArgs e) { try { DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync; DotNetSpeech.SpVoice vo = new SpVoiceClass(); vo.Speak(this.textBox2.Text, SSF); } catch (System.Exception ec) { MessageBox.Show(ec.ToString(), "SpeechApp", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } private void button2_Click_1(object sender, 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.textBox2.Text, SSF); vo.WaitUntilDone(System.Threading.Timeout.Infinite); SFS.Close(); } else { MessageBox.Show("对不起,无法生成"); } } catch (System.Exception ec) { MessageBox.Show(ec.ToString(), "SpeechApp", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复