public bool DtmfHit(Int32 wChnlNo) { lock (syncObj) { return(D160X.DtmfHit(wChnlNo)); } }
/// <summary> /// Plays the message. /// </summary> /// <param name="channel">The channel.</param> /// <param name="text">The text.</param> /// <param name="allowBreak">if set to <c>true</c> [allow break].</param> /// <param name="playType">Type of the play.</param> /// <returns></returns> public override SwitchStatus PlayMessage(IChannel channel, string text, bool allowBreak, TTSPlayType playType) { if (!canWork) { Logger.Warn("因TTS引擎初始化失败或其它原因造成不可用,不能进行TTS放音"); return(SwitchStatus.FAILURE); } if (channel == null) { Logger.Warn("传入通道参数未初始化不能进行TTS放音"); return(SwitchStatus.FAILURE); } lock (D160X.SyncObj) { Logger.Info(string.Format("通道 {0} 准备TTS放音,放音内容为:{1}", channel.ChannelID, text)); Int32 Playflag = TTS3.DJTTS3_StartPlayText(channel.ChannelID, Encoding.UTF8.GetBytes(text), TTS3.INFO_TEXT_BUFFER, 0, 45, 50, XmlTag ? TTS3.INFO_USE_LABLE : TTS3.INFO_NOTUSE_LABLE); Logger.Debug("TTS放音结果为:" + Playflag.ToString()); D160X.InitDtmfBuf(channel.ChannelID); } // 在放音后就要不断的检查其是否已经播放完毕 Int32 Playend = TTS3.INFO_PLAY_NOT_COMPLATE; while (Playend == TTS3.INFO_PLAY_NOT_COMPLATE) { lock (D160X.SyncObj) { D160X.PUSH_PLAY(); } System.Threading.Thread.Sleep(Defaultdelay); bool dtmfHited = false; lock (D160X.SyncObj) { dtmfHited = D160X.DtmfHit(channel.ChannelID); } if (allowBreak && dtmfHited) { lock (D160X.SyncObj) { TTS3.DJTTS3_StopPlayText(channel.ChannelID); } Logger.Info(string.Format("通道 {0} TTS放音过程被对方按键中断", channel.ChannelID)); return(SwitchStatus.BREAK); } if (channel.HangUpDetect()) { lock (D160X.SyncObj) { TTS3.DJTTS3_StopPlayText(channel.ChannelID); } Logger.Info(string.Format("通道 {0} TTS放音过程被对方挂机中断", channel.ChannelID)); channel.ResetChannel(); return(SwitchStatus.BREAK); } lock (D160X.SyncObj) { Playend = TTS3.DJTTS3_CheckPlayTextEnd(channel.ChannelID); } } lock (D160X.SyncObj) { TTS3.DJTTS3_StopPlayText(channel.ChannelID); } Logger.Info(string.Format("通道 {0} TTS放音结束", channel.ChannelID)); return(SwitchStatus.SUCCESS); }