@@ -191,7 +191,7 @@ public object DeleteSession(string sessionId)
191191 return result ;
192192 }
193193
194- public SpeechRecognitionEvent Recognize ( string contentType , FileStream audio , string transferEncoding = "" , string model = "" , string customizationId = "" , bool ? continuous = null , int ? inactivityTimeout = null , string [ ] keywords = null , double ? keywordsThreshold = null , int ? maxAlternatives = null , double ? wordAlternativesThreshold = null , bool ? wordConfidence = null , bool ? timestamps = null , bool profanityFilter = false , bool ? smartFormatting = null , bool ? speakerLabels = null )
194+ public SpeechRecognitionEvent Recognize ( string contentType , FileStream audio , string transferEncoding = "" , string model = "en-US_BroadbandModel " , string customizationId = "" , bool ? continuous = null , int ? inactivityTimeout = null , string [ ] keywords = null , double ? keywordsThreshold = null , int ? maxAlternatives = null , double ? wordAlternativesThreshold = null , bool ? wordConfidence = null , bool ? timestamps = null , bool profanityFilter = false , bool ? smartFormatting = null , bool ? speakerLabels = null )
195195 {
196196 if ( audio == null )
197197 throw new ArgumentNullException ( $ "{ nameof ( audio ) } ") ;
@@ -217,7 +217,7 @@ public SpeechRecognitionEvent Recognize(string contentType, FileStream audio, st
217217 model : model ) ;
218218 }
219219
220- public SpeechRecognitionEvent Recognize ( string contentType , Metadata metaData , FileStream audio , string transferEncoding = "" , string model = "" , string customizationId = "" )
220+ public SpeechRecognitionEvent Recognize ( string contentType , Metadata metaData , FileStream audio , string transferEncoding = "" , string model = "en-US_BroadbandModel " , string customizationId = "" )
221221 {
222222 if ( metaData == null )
223223 throw new ArgumentNullException ( $ "{ nameof ( metaData ) } ") ;
@@ -235,7 +235,7 @@ public SpeechRecognitionEvent Recognize(string contentType, Metadata metaData, F
235235 model : model ) ;
236236 }
237237
238- public SpeechRecognitionEvent RecognizeWithSession ( string sessionId , string contentType , FileStream audio , string transferEncoding = "" , string model = "" , string customizationId = "" , bool ? continuous = null , int ? inactivityTimeout = null , string [ ] keywords = null , double ? keywordsThreshold = null , int ? maxAlternatives = null , double ? wordAlternativesThreshold = null , bool ? wordConfidence = null , bool ? timestamps = null , bool profanityFilter = false , bool ? smartFormatting = null , bool ? speakerLabels = null )
238+ public SpeechRecognitionEvent RecognizeWithSession ( string sessionId , string contentType , FileStream audio , string transferEncoding = "" , string model = "en-US_BroadbandModel " , string customizationId = "" , bool ? continuous = null , int ? inactivityTimeout = null , string [ ] keywords = null , double ? keywordsThreshold = null , int ? maxAlternatives = null , double ? wordAlternativesThreshold = null , bool ? wordConfidence = null , bool ? timestamps = null , bool profanityFilter = false , bool ? smartFormatting = null , bool ? speakerLabels = null )
239239 {
240240 if ( string . IsNullOrEmpty ( sessionId ) )
241241 throw new ArgumentNullException ( $ "{ nameof ( sessionId ) } ") ;
@@ -264,7 +264,7 @@ public SpeechRecognitionEvent RecognizeWithSession(string sessionId, string cont
264264 model : model ) ;
265265 }
266266
267- public SpeechRecognitionEvent RecognizeWithSession ( string sessionId , string contentType , Metadata metaData , FileStream audio , string transferEncoding = "" , string model = "" , string customizationId = "" )
267+ public SpeechRecognitionEvent RecognizeWithSession ( string sessionId , string contentType , Metadata metaData , FileStream audio , string transferEncoding = "" , string model = "en-US_BroadbandModel " , string customizationId = "" )
268268 {
269269 if ( string . IsNullOrEmpty ( sessionId ) )
270270 throw new ArgumentNullException ( $ "{ nameof ( sessionId ) } ") ;
@@ -307,13 +307,15 @@ private SpeechRecognitionEvent Recognize(string sessionId, string contentType, M
307307 {
308308 request =
309309 this . Client . WithAuthentication ( this . UserName , this . Password )
310- . PostAsync ( $ "{ this . Endpoint } { string . Format ( PATH_SESSION_RECOGNIZE , sessionId ) } ") ;
311- // .WithHeader("Cookie", sessionId);
310+ . PostAsync ( $ "{ this . Endpoint } { string . Format ( PATH_SESSION_RECOGNIZE , sessionId ) } ")
311+ . WithHeader ( "Cookie" , sessionId ) ;
312312 }
313313
314314 if ( metaData == null )
315315 {
316- request . WithArgument ( "model" , model ) ;
316+ // if a session exists, the model should not be sent
317+ if ( string . IsNullOrEmpty ( sessionId ) )
318+ request . WithArgument ( "model" , model ) ;
317319
318320 if ( ! string . IsNullOrEmpty ( customizationId ) )
319321 request . WithArgument ( "customization_id" , customizationId ) ;
@@ -351,9 +353,7 @@ private SpeechRecognitionEvent Recognize(string sessionId, string contentType, M
351353 if ( speakerLabels . HasValue )
352354 request . WithArgument ( "speaker_labels" , speakerLabels . Value ) ;
353355
354- //StreamContent bodyContent = new StreamContent(audio);
355- ByteArrayContent bodyContent = new ByteArrayContent ( audio . ReadAllBytes ( ) ) ;
356-
356+ StreamContent bodyContent = new StreamContent ( audio ) ;
357357 bodyContent . Headers . Add ( "Content-Type" , contentType ) ;
358358
359359 request . WithBodyContent ( bodyContent ) ;
@@ -366,11 +366,14 @@ private SpeechRecognitionEvent Recognize(string sessionId, string contentType, M
366366 metadata . Headers . ContentType = MediaTypeHeaderValue . Parse ( HttpMediaType . APPLICATION_JSON ) ;
367367
368368 var audioContent = new ByteArrayContent ( ( audio as Stream ) . ReadAllBytes ( ) ) ;
369- //var audioContent = new StreamContent((audio as Stream));
370369 audioContent . Headers . ContentType = MediaTypeHeaderValue . Parse ( contentType ) ;
371370
372371 MultipartFormDataContent formData = new MultipartFormDataContent ( ) ;
373- request . WithArgument ( "model" , model ) ;
372+
373+ // if a session exists, the model should not be sent
374+ if ( string . IsNullOrEmpty ( sessionId ) )
375+ request . WithArgument ( "model" , model ) ;
376+
374377 formData . Add ( metadata , "metadata" ) ;
375378 formData . Add ( audioContent , "upload" , Path . GetFileName ( audio . Name ) ) ;
376379
@@ -401,7 +404,7 @@ public List<SpeechRecognitionEvent> ObserveResult(string sessionId, int? sequenc
401404 {
402405 var request =
403406 this . Client . WithAuthentication ( this . UserName , this . Password )
404- . PostAsync ( $ "{ this . Endpoint } { string . Format ( PATH_OBSERVE_RESULT , sessionId ) } ") ;
407+ . GetAsync ( $ "{ this . Endpoint } { string . Format ( PATH_OBSERVE_RESULT , sessionId ) } ") ;
405408
406409 if ( sequenceId . HasValue )
407410 request . WithArgument ( "sequence_id" , sequenceId ) ;
0 commit comments