|
1. 要在C#中進行中文語音播放,需要安裝微軟的Speech Application SDK(SASDK),可以在這里下載: http://www.microsoft.com/speech/download/sdk51/,需要安裝這兩個文件Speech SDK 5.1和5.1 2. 在C#程序中添加如下引用,并在代碼中添加using System.Speech.Synthesis;
3. 對于機器人運行狀態(tài)的訂閱,可以在上位機登錄上機器人系統(tǒng)后,添加如下訂閱 void subscribe() { controller.Rapid.ExecutionStatusChanged += new EventHandler<ExecutionStatusChangedEventArgs>(exe_StateChanged); //添加對運行模式的訂閱 } 4. 在對應(yīng)響應(yīng)事件中,添加語音輸出 private void UpdateGUIexe_state(object sender, System.EventArgs e) { this.label18.Text = controller.Rapid.ExecutionStatus.ToString(); string s1 = ''; if (label18.Text == 'Running') { s1 = '機器人啟動'; } if (label18.Text == 'Stopped') { s1 = '機器人停止運動'; } textBox2.Text = s1; SpeechSynthesizer speech = new SpeechSynthesizer(); speech.Volume = 100; //音量 speech.Rate = 1; //朗讀速度 speech.SelectVoice('Microsoft Simplified Chinese'); speech.SpeakAsync(s1); } 5. 對于其他變量/語句的語音輸出,方法類似,可以通過以下代碼進行訂閱 rd = controller.Rapid.GetRapidData('T_ROB1', 'm1', 'count'); rd.ValueChanged += new EventHandler<DataValueChangedEventArgs>(valueChanged); 如何成為優(yōu)秀的電氣工程師?
|
|
|