Exemplo n.º 1
0
 /// <summary>
 /// 释放语音库资源
 /// </summary>
 public void DisposeVoice()
 {
     try
     {
         Jtts.jTTS_End();
     }
     catch (Exception ea)
     {
         throw new Exception("释放语音包资源出现异常!原因:" + ea.Message);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 调整语音朗诵对象的语速
 /// </summary>
 public void VoiceRate()
 {
     try
     {
         string RateValue = ApiFunction.GetIniString("分诊系统呼叫速度调节", "Rate", Application.StartupPath + @"\ClientWindow.ini");
         uint   value     = 2;
         uint.TryParse(RateValue, out value);
         Jtts.jTTS_SetParam(Jtts.PARAM_SPEED, value); //调节语速
     }
     catch (Exception ea)
     {
         throw ea;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 语音朗诵
        /// </summary>
        /// <param name="message">朗诵信息</param>
        /// <param name="msg">返回的异常信息</param>
        public void VoiceSpeak(string callString, ref string msg)
        {
            try
            {
                if (callString.Trim() == "")
                {
                    return;
                }

                // jianqg 修改 不限定使用捷通 2013-12-05
                SpeechLib.SpVoice speech = new SpVoice();
                if (voiceInfo.init)
                {
                    speech.Voice  = speech.GetVoices(string.Empty, string.Empty).Item(voiceInfo.voices);
                    speech.Volume = voiceInfo.lolume;
                    //   speech.Rate = voiceInfo.rate;
                }
                // speech.WaitUntilDone(-1);

                speech.Speak(callString, SpeechVoiceSpeakFlags.SVSFlagsAsync);


                //SpVoice speech1 = new SpVoice();
                //speech1.Voice = speech1.GetVoices(string.Empty, string.Empty).Item(3);
                //speech1.Rate = -1;
                //speech1.Volume = 100;
                //speech1.WaitUntilDone(-1);
                //speech1.Speak("测试", SpeechVoiceSpeakFlags.SVSFlagsAsync);//.
                //以下是 周鹏原来使用 捷通语音的 jianqg 2013-12-05  注释



                int iErr = Jtts.jTTS_Play(callString, 0);

                if (Jtts.ERR_NONE != iErr)
                {
                    msg = "语音包错误!错误号:" + iErr.ToString();
                    return;
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化语音库
        /// </summary>
        public void InitializeVoiceLib()
        {
            try
            {
                int iErr = Jtts.jTTS_Init(null, null); //初始化JTTS语音库
                Jtts.JTTS_CONFIG config = new Jtts.JTTS_CONFIG();
                iErr = Jtts.jTTS_Get(out config);
                if (iErr != 0)
                {
                    throw new Exception("当前机器未安装语音包!或语音包异常!");
                }
                config.nCodePage = (ushort)Encoding.Default.CodePage;
                Jtts.jTTS_Set(ref config);

                VoiceRate();
            }
            catch (Exception ea)
            {
                throw new Exception("初始化语音库出现异常!原因:" + ea.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 语音朗诵
        /// </summary>
        /// <param name="message">朗诵信息</param>
        /// <param name="msg">返回的异常信息</param>
        public void VoiceSpeak(string callString, ref string msg)
        {
            try
            {
                if (callString.Trim() == "")
                {
                    return;
                }

                int iErr = Jtts.jTTS_Play(callString, 0);

                if (Jtts.ERR_NONE != iErr)
                {
                    msg = "语音包错误!错误号:" + iErr.ToString();
                    return;
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
        }