Beispiel #1
0
 /// <summary>
 /// 关闭语音识别方法
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static async Task CloseAsync(this IRecognizerProvider provider, Func <RecognizerStatus, string?, Task>?callback = null)
 {
     var option = new RecognizerOption()
     {
         MethodName = "bb_baidu_speech_close",
         Callback   = callback
     };
     await provider.InvokeAsync(option);
 }
 /// <summary>
 /// 关闭语音识别方法
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static async Task CloseAsync(this IRecognizerProvider provider, Func <RecognizerStatus, string?, Task> callback)
 {
     var option = new RecognizerOption()
     {
         MethodName = "bb_azure_close_recognizer",
         Callback   = callback
     };
     await provider.InvokeAsync(option);
 }
Beispiel #3
0
    /// <summary>
    /// 语音识别方法
    /// </summary>
    /// <param name="provider"></param>
    /// <param name="callback"></param>
    /// <param name="autoRecoginzerElapsedMilliseconds">默认 5000 毫秒后自动识别,设置 0 时禁用</param>
    public static async Task RecognizeOnceAsync(this IRecognizerProvider provider, Func <RecognizerStatus, string?, Task> callback, int?autoRecoginzerElapsedMilliseconds = null)
    {
        var option = new RecognizerOption()
        {
            MethodName = "bb_baidu_speech_recognizeOnce",
            Callback   = callback
        };

        // 设置自动识别时间
        if (autoRecoginzerElapsedMilliseconds.HasValue)
        {
            option.AutoRecoginzerElapsedMilliseconds = autoRecoginzerElapsedMilliseconds.Value;
        }
        await provider.InvokeAsync(option);
    }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="provider"></param>
 public RecognizerService(IRecognizerProvider provider)
 {
     Provider = provider;
 }