public async Task Start()
        {
            await StartRecognition();

            // TODO: make limit configurable
            if (!_recognitionStarted.WaitOne(10000))
            {
                Trace.Write("Recognition started not received");
                _transcriptionComplete.Set();
                throw new InvalidOperationException("Recognition started not received");
            }

            if (_api.Configuration.CustomDictionaryPlainWords != null ||
                _api.Configuration.CustomDictionarySoundsLikes != null ||
                _api.Configuration.OutputLocale != null ||
                _api.Configuration.DynamicTranscriptConfiguration != null)
            {
                await SetRecognitionConfig();
            }

            var streamBuffer = new byte[_api.Configuration.BlockSize];
            int bytesRead;

            while ((bytesRead = _stream.Read(streamBuffer, 0, streamBuffer.Length)) > 0 && !_transcriptionComplete.WaitOne(0))
            {
                await SendData(new ArraySegment <byte>(streamBuffer, 0, bytesRead));
            }

            var endOfStream = new EndOfStreamMessage(_sequenceNumber);
            await endOfStream.Send(_wsClient, _api.CancelToken);
        }
Пример #2
0
 public EndOfStreamEventArg(EndOfStreamMessage eos) => EOS = eos;