@@ -229,6 +229,8 @@ public virtual AsyncCollectionResult<StreamingAudioTranscriptionUpdate> Transcri
229
229
Argument . AssertNotNull ( audio , nameof ( audio ) ) ;
230
230
Argument . AssertNotNullOrEmpty ( audioFilename , nameof ( audioFilename ) ) ;
231
231
232
+ EnsureModelSupportsStreaming ( ) ;
233
+
232
234
MultiPartFormDataBinaryContent content
233
235
= CreatePerCallTranscriptionOptions ( options , stream : true )
234
236
. ToMultipartContent ( audio , audioFilename ) ;
@@ -245,6 +247,8 @@ public virtual AsyncCollectionResult<StreamingAudioTranscriptionUpdate> Transcri
245
247
{
246
248
Argument . AssertNotNullOrEmpty ( audioFilePath , nameof ( audioFilePath ) ) ;
247
249
250
+ EnsureModelSupportsStreaming ( ) ;
251
+
248
252
FileStream inputStream = File . OpenRead ( audioFilePath ) ;
249
253
250
254
MultiPartFormDataBinaryContent content
@@ -266,6 +270,8 @@ public virtual CollectionResult<StreamingAudioTranscriptionUpdate> TranscribeAud
266
270
Argument . AssertNotNull ( audio , nameof ( audio ) ) ;
267
271
Argument . AssertNotNullOrEmpty ( audioFilename , nameof ( audioFilename ) ) ;
268
272
273
+ EnsureModelSupportsStreaming ( ) ;
274
+
269
275
MultiPartFormDataBinaryContent content
270
276
= CreatePerCallTranscriptionOptions ( options , stream : true )
271
277
. ToMultipartContent ( audio , audioFilename ) ;
@@ -282,6 +288,8 @@ public virtual CollectionResult<StreamingAudioTranscriptionUpdate> TranscribeAud
282
288
{
283
289
Argument . AssertNotNullOrEmpty ( audioFilePath , nameof ( audioFilePath ) ) ;
284
290
291
+ EnsureModelSupportsStreaming ( ) ;
292
+
285
293
FileStream inputStream = File . OpenRead ( audioFilePath ) ;
286
294
287
295
MultiPartFormDataBinaryContent content
@@ -296,6 +304,20 @@ MultiPartFormDataBinaryContent content
296
304
return result ;
297
305
}
298
306
307
+ private void EnsureModelSupportsStreaming ( )
308
+ {
309
+ if ( string . Equals ( _model , "whisper-1" , StringComparison . OrdinalIgnoreCase ) )
310
+ {
311
+ string isEnabled = Environment . GetEnvironmentVariable ( "OPENAI_ENABLE_WHISPER_1_STREAMING" ) ;
312
+ if ( ! string . Equals ( isEnabled , "true" , StringComparison . OrdinalIgnoreCase ) )
313
+ {
314
+ throw new NotSupportedException (
315
+ "The selected model 'whisper-1' does not support streaming transcription. " +
316
+ "Please use a compatible model or set the environment variable 'OPENAI_ENABLE_WHISPER_1_STREAMING=true' to bypass this check." ) ;
317
+ }
318
+ }
319
+ }
320
+
299
321
#endregion
300
322
301
323
#region TranslateAudio
0 commit comments