win7 C# 利用windows自带语音类库读书 spvoice,电脑端 读书-摘自网络
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using SpeechLib; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private SpeechVoiceSpeakFlags _spFlags; private SpVoice _voice; public Form1() { InitializeComponent(); } private void Form1_Load( object sender, EventArgs e) { _voice = new SpVoice(); _spFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; _voice.Rate = 2; _voice.Voice.GetDescription(comboBox2.SelectedIndex); } private void button1_Click( object sender, EventArgs e) { //if(_voice.Status.RunningState == SpeechRunState.SRSEIsSpeaking) _voice.Speak(textBox1.Text, _spFlags); } private void comboBox1_SelectedIndexChanged( object sender, EventArgs e) { //其中3为中文,024为英文 //_voice.Voice = _voice.GetVoices(string.Empty, string.Empty).Item(comboBox1.SelectedIndex == 0 ? 3 : 24); } /// <summary> /// Stop /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click( object sender, EventArgs e) { _voice.Speak( string .Empty, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } private void Pause_Click( object sender, EventArgs e) { _voice.Pause(); } private void Resume_Click( object sender, EventArgs e) { _voice.Resume(); } private void comboBox2_SelectedIndexChanged( object sender, EventArgs e) { _voice.Rate = int .Parse(comboBox2.SelectedIndex+ "" ); } } } |
-摘自网络
2 摘自网络
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | using System.Windows.Forms; using System.Speech; using System.Speech.Synthesis; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private SpeechSynthesizer ss; public Form1() { InitializeComponent(); } private void Form1_Load( object sender, EventArgs e) { ss = new SpeechSynthesizer(); } private void buttonRead_Click( object sender, EventArgs e) { ss.Rate = trackBarSpeed.Value; ss.Volume = trackBarVolumn.Value; ss.SpeakAsync(txtMsg.Text); } private void buttonPause_Click( object sender, EventArgs e) { ss.Pause(); } private void buttonContinue_Click( object sender, EventArgs e) { ss.Resume(); } private void buttonRecord_Click( object sender, EventArgs e) { SpeechSynthesizer ss = new SpeechSynthesizer(); ss.Rate = trackBarSpeed.Value; ss.Volume = trackBarVolumn.Value; SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Wave Files|*.wav" ; ss.SetOutputToWaveFile(sfd.FileName); ss.Speak(txtMsg.Text); ss.SetOutputToDefaultAudioDevice(); MessageBox.Show( "完成录音~~" , "提示" ); } private void buttonClose_Click( object sender, EventArgs e) { Application.Exit(); } } } |
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
2015-03-23 加一个 时间戳 TimeStamp 可以解决 重复提交问题 SqlServer
2009-03-23 自尊心洒了一地的原因