Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new stream and starts the recording.
 /// </summary>
 public async Task GetNextRecording()
 {
     mSttStream = mSttClient.CreateStream();
     mAudioCapture.Start();
     Console.ReadLine();
     await StopRecordingAsync();
 }
Ejemplo n.º 2
0
        private void startSpeechRecognition()
        {
            isFeeding = true;
            stream    = client.CreateStream();
            var feedCount  = 0;
            var decodeRate = 100; // decode every 100 feeds

            Task.Run(async() =>
            {
                while (isFeeding || !bufferQueue.IsEmpty)
                {
                    if (!bufferQueue.IsEmpty && bufferQueue.TryDequeue(out short[] buffer))
                    {
                        client.FeedAudioContent(stream, buffer, Convert.ToUInt32(buffer.Length));

                        if (++feedCount % decodeRate == 0)
                        {
                            var transcription = client.IntermediateDecode(stream);
                            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                result.Text = transcription;
                            });
                        }
                    }
                }
            });
        }