/// <summary>
        /// 待合成音频文本内容text设置.
        /// </summary>
        /// <param name="request">
        /// CreateSynthesizerRequest所建立的request对象.
        /// </param>
        /// <param name="value">
        /// 待合成文本字符串.
        /// </param>
        /// <returns>成功则返回0, 否则返回-1.</returns>
        public int SetText(SpeechSynthesizerRequest request, string value)
        {
            byte[] text     = Encoding.UTF8.GetBytes(value);
            UInt32 textSize = (UInt32)text.Length;

            return(NativeMethods.SYsetText(request.native_request, text, textSize));
        }
        /// <summary>
        /// 创建语音合成对象.
        /// </summary>
        /// <param name="version">
        /// tts类型, 短文本或长文本.
        /// </param>
        /// <returns></returns>
        public SpeechSynthesizerRequest CreateSynthesizerRequest(TtsVersion version)
        {
            IntPtr request = NativeMethods.NlsCreateSynthesizerRequest((int)version);
            SpeechSynthesizerRequest SYrequest = new SpeechSynthesizerRequest();

            SYrequest.native_request = request;
            return(SYrequest);
        }
        /// <summary>
        /// 设置文本对应的日志信息接收回调函数,
        /// 接收到服务端送回文本对应的日志信息,增量返回对应的字幕信息时,sdk内部线程上报该回调函数.
        /// </summary>
        /// <param name="request">
        /// CreateSynthesizerRequest所建立的request对象.
        /// </param>
        /// <param name="callback">
        /// 用户传入的回调函数.
        /// </param>
        /// <param name="para">
        /// 用户对象.
        /// </param>
        /// <returns></returns>
        public void SetOnMetaInfo(
            SpeechSynthesizerRequest request, CallbackDelegate callback, object para = null)
        {
            SpeechParamStruct user_param = new SpeechParamStruct();

            user_param.user     = para;
            user_param.callback = callback;
            user_param.nlsEvent = new NLS_EVENT_STRUCT();
            IntPtr toCppParam = Marshal.AllocHGlobal(Marshal.SizeOf(user_param));

            Marshal.StructureToPtr(user_param, toCppParam, false);
            NativeMethods.SYOnMetaInfo(request.native_request, onMetaInfo, (IntPtr)toCppParam);
            return;
        }
 /// <summary>
 /// 设置语音合成服务URL地址
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <param name="value">
 /// 服务url字符串.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int SetUrl(SpeechSynthesizerRequest request, string value)
 {
     return(NativeMethods.SYsetUrl(request.native_request, value));
 }
 /// <summary>
 /// 直接关闭语音合成过程. 调用cancel之后不会在上报任何回调事件.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int Cancel(SpeechSynthesizerRequest request)
 {
     return(NativeMethods.SYcancel(request.native_request));
 }
 /// <summary>
 /// 会与服务端确认关闭, 正常停止语音合成操作. 异步操作, 失败返回TaskFailed.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int Stop(SpeechSynthesizerRequest request)
 {
     return(NativeMethods.SYstop(request.native_request));
 }
 /// <summary>
 /// 设置用户自定义ws阶段http header参数.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <param name="key">
 /// 参数名称.
 /// </param>
 /// <param name="value">
 /// 参数内容.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int AppendHttpHeaderParam(SpeechSynthesizerRequest request, string key, string value)
 {
     return(NativeMethods.SYappendHttpHeaderParam(request.native_request, key, value));
 }
 /// <summary>
 /// 设置Socket接收超时时间.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <param name="value">
 /// 超时时间.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int SetTimeout(SpeechSynthesizerRequest request, int value)
 {
     return(NativeMethods.SYsetTimeout(request.native_request, value));
 }
 /// <summary>
 /// 是否开启字幕功能.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <param name="value">
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int SetEnableSubtitle(SpeechSynthesizerRequest request, bool value)
 {
     return(NativeMethods.SYsetEnableSubtitle(request.native_request, value));
 }
 /// <summary>
 /// 语调pitch_rate设置.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <param name="value">
 /// 语调, 范围是-500~500, 可选参数, 默认是0.
 /// </param>
 /// <returns>成功则返回0, 否则返回-1.</returns>
 public int SetPitchRate(SpeechSynthesizerRequest request, int value)
 {
     return(NativeMethods.SYsetPitchRate(request.native_request, value));
 }
Esempio n. 11
0
 /// <summary>
 /// 销毁语音合成对象.
 /// </summary>
 /// <param name="request">
 /// CreateSynthesizerRequest所建立的request对象.
 /// </param>
 /// <returns></returns>
 public void ReleaseSynthesizerRequest(SpeechSynthesizerRequest request)
 {
     NativeMethods.NlsReleaseSynthesizerRequest(request.native_request);
     return;
 }