title: Microsoft Azure Speech Recognition Stream closes to early
body: <p>I am trying to implement a lifestream translation of a user microphone.
  The users will use Chrome or Edge.</p>
  <p>The browser will post the user input every 500ms. No information will be lost.</p>
  <p>At server level, I basically create <code>PushAudioInputStream</code></p>
  <p>and write to the body of the post into the stream.</p>
  <pre><code> _httpListener = new HttpListener();
  ...
  var context = _httpListener.GetContext();
  ...
  var binaryReader = new BinaryReader(context.Request.InputStream);
  </code></pre>
  <pre><code>public static void CopyFromReader(BinaryReader reader, PushAudioInputStream writer)
  {
    byte[] readBytes;
    do
    {
       readBytes = reader.ReadBytes(2048);
       writer.Write(readBytes);
    } while (readBytes.Length &gt; 0);
  }
  </code></pre>
  <p>After the first post, I let the following parallel method run (basically until the user leaves)</p>
  <pre><code>private async void azureSideRequest()
          {
              //Standard settings for Audio Data
              byte channels = 1;
              byte bitsPerSample = 16;
              uint samplesPerSecond = 48000; // &lt;--- my Mic
              var audioFormat = AudioStreamFormat.GetWaveFormatPCM(samplesPerSecond, bitsPerSample, channels);
              var audioConfig = AudioConfig.FromStreamInput(_livestream._audioStream);
              var speechConfig = SpeechConfig.FromSubscription(ResourceKey, Region);
  
              using var recognizer = new SpeechRecognizer(speechConfig, &quot;en-US&quot;, audioConfig);
  
              List&lt;string&gt; list = new List&lt;string&gt;();
              var signal = new SemaphoreSlim(0, 1);
  
              //If the text is recognized append him to the builder.
              recognizer.Recognized += (s, e) =&gt;
              {
                  if (e.Result.Text == &quot;&quot;) return;
                  _livestream._stashed.Add(e.Result.Text);
              };
  
              recognizer.Canceled += (s, e) =&gt;
              {
  
                  signal.Release(); //Immediately called, Reason: End of Stream
              };
  
              await recognizer.StartContinuousRecognitionAsync().ConfigureAwait(false);
              await signal.WaitAsync();
          }
  </code></pre>
  <p>After the first post, this code immediately calls .Canceled() and returns. The given Reason is <code>EndOfStream</code>. But I never .close() the stream or something similar...</p>