/// <summary> /// Calls InitializeAsync if recorder is not initialized. /// </summary> /// <param name="settings"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override Task <IRecording> StartAsync(AudioSettings?settings = null, CancellationToken cancellationToken = default) { settings ??= SupportedSettings.First(); return(Task.FromResult <IRecording>(new NAudioRecording( settings, DeviceNumber, NumberOfBuffers))); }
/// <summary> /// /// </summary> /// <param name="bytes"></param> /// <param name="settings"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task <string> ConvertAsync(byte[] bytes, AudioSettings?settings = null, CancellationToken cancellationToken = default) { settings ??= SupportedSettings.First(); using var client = new HttpClient(); using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.wit.ai/speech") { Headers = { Authorization = AuthenticationHeaderValue.Parse($"Bearer {Token}"), TransferEncodingChunked = true, },
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="settings"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task <byte[]> ConvertAsync(string text, AudioSettings?settings = null, CancellationToken cancellationToken = default) { settings ??= SupportedSettings.First(); var key = TextToKey(text, settings); if (UseCache && Cache.Contains(key)) { return(Cache[key]?.ToArray() ?? EmptyArray <byte> .Value); } var bytes = await InternalConvertAsync(text, settings, cancellationToken).ConfigureAwait(false); Cache[key] = bytes; return(bytes); }
/// <summary> /// /// </summary> /// <param name="settings"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override Task <IRecording> StartAsync(AudioSettings?settings = null, CancellationToken cancellationToken = default) { settings ??= SupportedSettings.First(); return(Task.FromResult <IRecording>(new WinmmRecording(settings))); }