/// <summary> /// /// </summary> /// <param name="settings"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task <IStreamingRecognition> StartStreamingRecognitionAsync( AudioSettings?settings = null, CancellationToken cancellationToken = default) { settings ??= SupportedStreamingSettings.First(); IamToken ??= await RequestIamTokenByOAuthTokenAsync(OAuthToken, cancellationToken).ConfigureAwait(false); var channel = new Channel("stt.api.cloud.yandex.net", 443, new SslCredentials()); var client = new SttService.SttServiceClient(channel); var call = client.StreamingRecognize(new Metadata { { "authorization", $"Bearer {IamToken}" } }, cancellationToken: cancellationToken); await call.RequestStream.WriteAsync(new StreamingRecognitionRequest { Config = new RecognitionConfig { Specification = new RecognitionSpec { LanguageCode = Lang, ProfanityFilter = ProfanityFilter, Model = Topic, AudioEncoding = settings.Format switch { AudioFormat.Ogg => RecognitionSpec.Types.AudioEncoding.OggOpus, AudioFormat.Raw => RecognitionSpec.Types.AudioEncoding.Linear16Pcm, _ => RecognitionSpec.Types.AudioEncoding.Unspecified, },
public SpeechKitSttStreamClient(Uri address, string folderId, string IamToken, RecognitionSpec rSpec, ILoggerFactory loggerFactory) : base(address, IamToken) { this.rConf = new RecognitionConfig() { FolderId = folderId, Specification = rSpec }; speechKitRpctClient = new SttService.SttServiceClient(MakeChannel(loggerFactory)); }
public SkRecognitionClient(Uri address, string folderId, string IamToken, RecognitionSpec rSpec, ILoggerFactory loggerFactory, ISkTaskDb taskDb) { this.log = loggerFactory.CreateLogger <SkRecognitionClient>(); this.taskDb = taskDb; this.endpointAddress = address; this.IamToken = IamToken; this.rConf = new RecognitionConfig() { FolderId = folderId, Specification = rSpec }; SslCredentials sslCred = new Grpc.Core.SslCredentials(); var chn = GrpcChannel.ForAddress(endpointAddress, new GrpcChannelOptions { LoggerFactory = loggerFactory }); speechKitRpctClient = new SttService.SttServiceClient(chn); }