/// <summary> /// 关闭所有语音报警 /// </summary> public void CloseAlarm() { try { SmartReader.Close(); if (ClientAlarmConfigCache.showDataSound != null) { ClientAlarmConfigCache.showDataSound.Clear(); } } catch (Exception ex) { LogHelper.Error(ex); } }
private void frmSound_Load(object sender, EventArgs e) { try { this.Visible = false; //传入文件控件的句柄,当播放完声音后,会触发文件控件的text change事件 SmartReader.Handler = this.textBox1.Handle.ToInt32(); SmartReader.Handler2 = this.textBox2.Handle.ToInt32(); SmartReader.InitialAuth(); this.timerPlay.Enabled = false; this.timerPlay.Enabled = true; } catch (Exception ex) { LogHelper.Error(ex); } }
private void Play() { try { string sw = ""; if (bIsPlaying) { return; } if (ClientAlarmConfigCache.showDataSound == null || ClientAlarmConfigCache.showDataSound.Count < 1) { return; } if (palyIndex >= ClientAlarmConfigCache.showDataSound.Count) { palyIndex = 0; } if (ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay == "逻辑分析报警") { sw = string.Format("{0}{1}{2}", Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz), ClientAlarmConfigCache.showDataSound[palyIndex].Ssz, ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); } else if (ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay == "定义异常报警") { sw = string.Format("{0}{1}{2}", Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz), ClientAlarmConfigCache.showDataSound[palyIndex].Ssz, ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); } else if (ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay == "倍数报警" || ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay == "风机局扇停报警" || ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay == "电源箱放电提醒") { sw = string.Format("{0}{1}{2}{3}", Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Point) , Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz), ClientAlarmConfigCache.showDataSound[palyIndex].Ssz, ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); } else { float tempFloat = 0; float.TryParse(ClientAlarmConfigCache.showDataSound[palyIndex].Ssz, out tempFloat);//是数值的时候才播报单位 20170715 if (tempFloat != 0) { // sw = string.Format("{0} {1} {2}{3} {4}" //, Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Point) //, Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz) //, ClientAlarmConfigCache.showDataSound[palyIndex].Ssz //, Unit2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Unit) //, ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); sw = string.Format("{0} {1} {2}{3}" , Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz) , ClientAlarmConfigCache.showDataSound[palyIndex].Ssz , Unit2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Unit) , ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); } else { //sw = string.Format("{0} {1} {2}{3} " // , Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Point) // , Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz) // , ClientAlarmConfigCache.showDataSound[palyIndex].Ssz // , ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); sw = string.Format("{0} {1} {2}" , Number2Chn(ClientAlarmConfigCache.showDataSound[palyIndex].Wz) , ClientAlarmConfigCache.showDataSound[palyIndex].Ssz , ClientAlarmConfigCache.showDataSound[palyIndex].TypeDisplay); } } //加是否有声卡的判断 20170401 if (Voice.SmartRead_GetVoiceDeviceNum() > 0) { if (!SmartReader.isReading) { //Basic.Framework.Logging.LogHelper.Debug(sw); SmartReader.Read(sw, 0);//智能语音报警(男声) //SmartReader.Read(sw, 4);//智能语音报警(女声) //SmartReader.Read(sw, 13);//智能语音报警(真人女声) //SmartReader.Read(sw, 11);//智能语音报警(微软真人女声) //ClientAlarmConfigCache.showDataSound.RemoveAt(0); } } } catch (Exception ex) { LogHelper.Error("报警语音播放发生异常 " + ex.Message); } }