緣由https://bbs.csdn.net/topics/604357098?DotNetSpeech.dll下載_DotNetSpeech.dll免費版下載 - 系統之家?dotnetspeech.dll 64下載-dotnetspeech.dll下載 v10.2 官方版-IT貓撲網
下載了一個DotNetSpeech.dll,放到 \bin\Debug里,添加引用,然后直接DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();朗讀速度(-10,10)
private void 朗讀文本(string text){DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();DotNetSpeech.SpeechVoiceSpeakFlags sFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;sp.Speak(text, sFlags);}朗讀文本("解答 專用 窗體.演示 朗讀 文本");
C++?
#using "..\Debug\農歷引用.dll"
using namespace 農歷引用;string 返回月歷(int 年, int 月, int 日, bool 選 = true)
{系統農歷^ 農歷 = gcnew 系統農歷();string aa = ((CT2A)(CString)(農歷->月歷加載(年, 月, 日))), aaa = "";aaa.push_back(aa[8]); aaa.push_back(aa[9]); aaa.push_back(aa[10]); aaa.push_back(aa[11]);return (選 ? aa : aaa);
}
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;namespace 文本朗讀轉音頻
{public partial class Form1 : Form{TextBox 錄入框 = new TextBox();ToolTip 控件說明 = new ToolTip();Button[] 按鈕集 = { };ImageList 圖標集 = new ImageList();StatusBar 狀態欄 = new StatusBar();public Form1(){InitializeComponent();this.ResizeRedraw = true;}private void Form1_Resize(object sender, EventArgs e){尺寸();}private void Form1_Load(object sender, EventArgs e){初值(); 布局(); 尺寸(); 停靠(); 跟隨(); 注明(); 圖標(); 事件();}private void 動態文本框_DragDrop(object sender, DragEventArgs e){錄入框.Text += (System.String)e.Data.GetData(typeof(System.String));}private void 動態文本框_DragEnter(object sender, DragEventArgs e){e.Effect = (e.Data.GetDataPresent(typeof(System.String))) ? DragDropEffects.Copy : DragDropEffects.None;}private void 朗讀文本單擊(object sender, EventArgs e) { 朗讀文本(錄入框.Text); }private void 朗讀文本(string text){DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();DotNetSpeech.SpeechVoiceSpeakFlags sFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;sp.Speak(text, sFlags);//朗讀效果不滿意不復再編寫}void 友情提示(string 內容) { MessageBox.Show(內容, "友情提示:"); }void 控件異步處理(Action 無返回事件){Parallel.Invoke(delegate(){this.BeginInvoke(new Action(delegate(){無返回事件();}));});}void 圖標(){this.Invoke(new Action(() =>{int 循環 = 0;//ICOhttps://sc.chinaz.com/tubiao/180520455660.htmhttps://sc.chinaz.com/tubiao/948547132.htmhttps://sc.chinaz.com/tubiao/954045391.htmwhile (循環 < 11)圖標集.Images.Add(Image.FromFile(@System.Environment.CurrentDirectory + "\\ICO\\BF" + 循環++.ToString() + ".ico"));}));}void 尺寸(){錄入框.Size = new Size(this.Width - 24, this.Height - (狀態欄.Height) - 68);}void 停靠(){狀態欄.Parent = 錄入框.Parent = this;按鈕集.Select(按鈕 => 按鈕.Parent = this).ToArray();}void 跟隨(){錄入框.Anchor = (AnchorStyles.Top | AnchorStyles.Left);}void 布局(){錄入框.Location = new Point(4, 24);按鈕集.Select((按鈕, 序號) => 按鈕.Location = new Point(47 * 序號, 1)).ToArray();}void 注明(){控件說明.SetToolTip(錄入框, "請輸入數據文本以便進行朗讀語音數據保存。");}void 初值(){this.BackColor = Color.Red;錄入框.AllowDrop = true;錄入框.Multiline = true;錄入框.AcceptsReturn = true;錄入框.ScrollBars = ScrollBars.Both;錄入框.ImeMode = System.Windows.Forms.ImeMode.OnHalf;錄入框.MaxLength = int.MaxValue;string[] 按鈕名 = new string[] { "朗讀", "暫停", "繼續", "停止", "錄制" };按鈕集 = Array.ConvertAll(按鈕名, 控件 => new Button()).ToArray();按鈕集.Select((按鈕, 序號) => 按鈕.Text = 按鈕名[序號]).ToArray();按鈕集.Select(按鈕 => 按鈕.Size = new Size(47, 24)).ToArray();}void 事件(){按鈕集[0].Click += new EventHandler(朗讀文本單擊);//按鈕集[1].Click += new EventHandler(暫停單擊);//按鈕集[2].Click += new EventHandler(繼續單擊);//按鈕集[3].Click += new EventHandler(停止單擊);//按鈕集[4].Click += new EventHandler(輸出WAV單擊);錄入框.DragDrop += new DragEventHandler(動態文本框_DragDrop);錄入框.DragEnter += new DragEventHandler(動態文本框_DragEnter);}}
}