/// <summary> /// 通过<seealso cref="ITTSEngine"/>引擎实现从文本内容到语音文件的转换,转换时根据提供的文件扩展名实现相应格式的自动支持 /// </summary> /// <param name="text">待转换的文本内容</param> /// <param name="fileName">转换后的语音文件名</param> /// <param name="voiceResource">语音资源类型用于指定转换的语种,详细信息请参考<seealso cref="VoiceResource"/></param> /// <returns> /// 转换操作的结果状态,详细信息请参考<seealso cref="PlayResult"/> /// </returns> /// <seealso cref="PlayFile"/> /// <seealso cref="PlayMessage"/> /// <seealso cref="PlayNumber"/> public virtual SwitchStatus PlayToFile(string text, string fileName, VoiceResource voiceResource) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// ͨ��<seealso cref="ITTSEngine"/>����ʵ�ִ��ı����ݵ������ļ���ת����ת��ʱ�����ṩ���ļ���չ��ʵ����Ӧ��ʽ���Զ�֧�� /// </summary> /// <param name="text">��ת�����ı�����</param> /// <param name="fileName">ת����������ļ���</param> /// <param name="voiceResource">������Դ��������ָ��ת�������֣���ϸ��Ϣ��ο�<seealso cref="VoiceResource"/></param> /// <returns> /// ת�������Ľ��״̬����ϸ��Ϣ��ο�<seealso cref="PlayResult"/> /// </returns> /// <seealso cref="PlayFile"/> /// <seealso cref="PlayMessage"/> /// <seealso cref="PlayNumber"/> public override SwitchStatus PlayToFile(string text, string fileName, VoiceResource voiceResource) { if (CurrentStatus == ChannelStatus.HANGUP) return SwitchStatus.BREAK; ITTSEngine tts = CurrentTTS(); tts.PlayToFile(this as IChannel, text, TTSPlayType.MESSAGES, fileName); return SwitchStatus.SUCCESS; }
private void RecordPrompts() { TerminationCode tc; bool responseReceived = false; string userInput = string.Empty; string fileToPlay = string.Empty; string recordFile = string.Empty; bool inRecordingLoop = true; bool deleteFile = false; m_VoiceResource = managedChannel.ChannelResource.VoiceResource; try { for (int i = 0; i < 3; i++) // Play intro, get a 1 to confirm they want to record now. { fileToPlay = Path.Combine(m_PromptPath, "FileIntro.wav"); m_VoiceResource.MaximumTime = 10; m_VoiceResource.MaximumDigits = 1; m_VoiceResource.InterDigitTimeout = 5; m_VoiceResource.TerminationDigits = "@"; m_VoiceResource.Play(fileToPlay); tc = m_VoiceResource.GetDigits(); userInput = m_VoiceResource.DigitBuffer; Log.Write("Prompt recorder user input: '{0}'", userInput); if (userInput == "1") { responseReceived = true; break; } } if (!responseReceived) { EndCall(); return; } while (inRecordingLoop) { responseReceived = false; for (int i = 0; i < 3; i++)// Get numeric file name. { fileToPlay = Path.Combine(m_PromptPath, "RecFileNum.wav"); m_VoiceResource.MaximumTime = 40; m_VoiceResource.MaximumDigits = 15; m_VoiceResource.InterDigitTimeout = 8; m_VoiceResource.TerminationDigits = "#"; m_VoiceResource.Play(fileToPlay); tc = m_VoiceResource.GetDigits(); userInput = m_VoiceResource.DigitBuffer; Log.Write("Prompt recorder user input (filename): '{0}'", userInput); if (userInput.Length > 0) { responseReceived = true; break; } } if (!responseReceived) { EndCall(); return; } recordFile = Path.Combine(m_RecordPath, string.Format("{0}.wav", userInput)); if (File.Exists(recordFile)) { // file exists, prompt to delete for (int i = 0; i < 3; i++)// Play intro, get a 1 to confirm they want to record now. { fileToPlay = Path.Combine(m_PromptPath, "RecIntro.wav"); m_VoiceResource.MaximumTime = 10; m_VoiceResource.MaximumDigits = 1; m_VoiceResource.InterDigitTimeout = 5; m_VoiceResource.TerminationDigits = "@"; m_VoiceResource.Play(fileToPlay); tc = m_VoiceResource.GetDigits(); userInput = m_VoiceResource.DigitBuffer; Log.Write("Prompt recorder user input: '{0}'", userInput); if (userInput == "1") { deleteFile = true; break; } } if (userInput.Length < 1) { EndCall(); return; } if (!deleteFile) { continue; } File.Delete(recordFile); fileToPlay = Path.Combine(m_PromptPath, "RecDeleted.wav"); } // Record the file m_VoiceResource.TerminationDigits = ""; fileToPlay = Path.Combine(m_PromptPath, "RecReady.wav"); m_VoiceResource.Play(fileToPlay); m_VoiceResource.MaximumTime = 180; m_VoiceResource.MaximumDigits = 1; m_VoiceResource.InterDigitTimeout = 8; m_VoiceResource.TerminationDigits = "#"; m_VoiceResource.Record(recordFile); responseReceived = false; for (int i = 0; i < 3; i++)// Play intro, get a 1 to confirm they want to record now. { fileToPlay = Path.Combine(m_PromptPath, "RecAnother.wav"); m_VoiceResource.MaximumTime = 10; m_VoiceResource.MaximumDigits = 1; m_VoiceResource.InterDigitTimeout = 5; m_VoiceResource.TerminationDigits = "@"; m_VoiceResource.Play(fileToPlay); tc = m_VoiceResource.GetDigits(); userInput = m_VoiceResource.DigitBuffer; Log.Write("Prompt recorder user input: '{0}'", userInput); if (userInput == "1") { responseReceived = true; break; } } if (!responseReceived) { EndCall(); return; } continue; } } catch (Exception ex) { Log.WriteException(ex, "Error ending prompt record IVR script."); } }
/// <summary> /// ͨ��<seealso cref="ITTSEngine"/>����ʵ�ִ��ı����ݵ������ļ���ת����ת��ʱ�����ṩ���ļ���չ��ʵ����Ӧ��ʽ���Զ�֧�� /// </summary> /// <param name="text">��ת�����ı�����</param> /// <param name="fileName">ת����������ļ���</param> /// <param name="voiceResource">������Դ��������ָ��ת�������֣���ϸ��Ϣ��ο�<seealso cref="VoiceResource"/></param> /// <returns> /// ת�������Ľ��״̬����ϸ��Ϣ��ο�<seealso cref="PlayResult"/> /// </returns> /// <seealso cref="PlayFile"/> /// <seealso cref="PlayMessage"/> /// <seealso cref="PlayNumber"/> public virtual SwitchStatus PlayToFile(string text, string fileName, VoiceResource voiceResource) { throw new Exception("The method or operation is not implemented."); }