示例#1
0
 // Token: 0x06001D5F RID: 7519 RVA: 0x00075404 File Offset: 0x00073604
 private void SignalRecognizeWithEmptyAudioAndBailOut(SpeechRecognitionProcessor.SpeechStreamBuffer speechStreamBuffer, Exception e, SpeechRecognitionProcessor.SpeechHttpStatus status, bool expectedException)
 {
     ExTraceGlobals.SpeechRecognitionTracer.TraceError <string, int, string>((long)this.GetHashCode(), "SignalRecognizeWithEmptyAudioAndBailOut - exception='{0}' Status code='{1}', Status message='{2}'", e.Message, status.StatusCode, status.StatusDescription);
     if (this.audioMemoryStream != null)
     {
         this.audioMemoryStream.Close();
     }
     this.audioMemoryStream = new MemoryStream();
     this.SignalRecognizeAsync();
     if (speechStreamBuffer != null)
     {
         speechStreamBuffer.Dispose();
     }
     if (expectedException)
     {
         this.HandleException(e, status);
         return;
     }
     this.HandleUnexpectedException(e);
 }
示例#2
0
 // Token: 0x06001D5D RID: 7517 RVA: 0x00075200 File Offset: 0x00073400
 private void ReadAudioBytesAsync(object state)
 {
     ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "Entering SpeechRecognitionProcessor.ReadAudioBytesAsync");
     SpeechRecognitionProcessor.SpeechStreamBuffer speechStreamBuffer = new SpeechRecognitionProcessor.SpeechStreamBuffer();
     try
     {
         this.audioMemoryStream         = new MemoryStream(16250);
         speechStreamBuffer.AudioStream = this.HttpContext.Request.GetBufferlessInputStream();
         speechStreamBuffer.AudioBuffer = new byte[400];
         speechStreamBuffer.AudioStream.BeginRead(speechStreamBuffer.AudioBuffer, 0, 400, new AsyncCallback(this.ReadAudioChunkCompleted), speechStreamBuffer);
     }
     catch (HttpException e)
     {
         this.SignalRecognizeWithEmptyAudioAndBailOut(speechStreamBuffer, e, SpeechRecognitionProcessor.SpeechHttpStatus.InternalServerError, true);
     }
     catch (Exception e2)
     {
         this.SignalRecognizeWithEmptyAudioAndBailOut(speechStreamBuffer, e2, SpeechRecognitionProcessor.SpeechHttpStatus.InternalServerError, false);
     }
 }
示例#3
0
 // Token: 0x06001D5E RID: 7518 RVA: 0x000752C4 File Offset: 0x000734C4
 private void ReadAudioChunkCompleted(IAsyncResult asyncResult)
 {
     ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "Entering SpeechRecognitionProcessor.BeginReadAudioBytes");
     SpeechRecognitionProcessor.SpeechStreamBuffer speechStreamBuffer = null;
     try
     {
         speechStreamBuffer = (asyncResult.AsyncState as SpeechRecognitionProcessor.SpeechStreamBuffer);
         int num = speechStreamBuffer.AudioStream.EndRead(asyncResult);
         if (num == 0)
         {
             ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "SpeechRecognitionProcessor.BeginReadAudioBytes - End of stream");
             this.SignalRecognizeAsync();
             speechStreamBuffer.Dispose();
         }
         else
         {
             ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "SpeechRecognitionProcessor.BeginReadAudioBytes - Read chunk");
             this.audioMemoryStream.Write(speechStreamBuffer.AudioBuffer, 0, num);
             if (this.audioMemoryStream.Length > (long)this.maxAudioSize)
             {
                 ExTraceGlobals.SpeechRecognitionTracer.TraceError <int>((long)this.GetHashCode(), "SpeechRecognitionProcessor.BeginReadAudioBytes - Max audio size ({0}) exceeded", this.maxAudioSize);
                 this.SignalRecognizeWithEmptyAudioAndBailOut(speechStreamBuffer, new ArgumentException("Max audio size exceeded"), SpeechRecognitionProcessor.SpeechHttpStatus.BadRequest, true);
             }
             else
             {
                 speechStreamBuffer.AudioStream.BeginRead(speechStreamBuffer.AudioBuffer, 0, 400, new AsyncCallback(this.ReadAudioChunkCompleted), speechStreamBuffer);
             }
         }
     }
     catch (HttpException e)
     {
         this.SignalRecognizeWithEmptyAudioAndBailOut(speechStreamBuffer, e, SpeechRecognitionProcessor.SpeechHttpStatus.InternalServerError, true);
     }
     catch (Exception e2)
     {
         this.SignalRecognizeWithEmptyAudioAndBailOut(speechStreamBuffer, e2, SpeechRecognitionProcessor.SpeechHttpStatus.InternalServerError, false);
     }
 }