@@ -229,10 +229,7 @@ public virtual AsyncCollectionResult<StreamingAudioTranscriptionUpdate> Transcri
229229 Argument . AssertNotNull ( audio , nameof ( audio ) ) ;
230230 Argument . AssertNotNullOrEmpty ( audioFilename , nameof ( audioFilename ) ) ;
231231
232- if ( string . Equals ( _model , "whisper-1" , StringComparison . OrdinalIgnoreCase ) )
233- {
234- throw new NotSupportedException ( $ "The selected model { _model } does not support streaming transcription. Please use a compatible model.") ;
235- }
232+ EnsureModelSupportsStreaming ( ) ;
236233
237234 MultiPartFormDataBinaryContent content
238235 = CreatePerCallTranscriptionOptions ( options , stream : true )
@@ -250,10 +247,7 @@ public virtual AsyncCollectionResult<StreamingAudioTranscriptionUpdate> Transcri
250247 {
251248 Argument . AssertNotNullOrEmpty ( audioFilePath , nameof ( audioFilePath ) ) ;
252249
253- if ( string . Equals ( _model , "whisper-1" , StringComparison . OrdinalIgnoreCase ) )
254- {
255- throw new NotSupportedException ( $ "The selected model { _model } does not support streaming transcription. Please use a compatible model.") ;
256- }
250+ EnsureModelSupportsStreaming ( ) ;
257251
258252 FileStream inputStream = File . OpenRead ( audioFilePath ) ;
259253
@@ -276,10 +270,7 @@ public virtual CollectionResult<StreamingAudioTranscriptionUpdate> TranscribeAud
276270 Argument . AssertNotNull ( audio , nameof ( audio ) ) ;
277271 Argument . AssertNotNullOrEmpty ( audioFilename , nameof ( audioFilename ) ) ;
278272
279- if ( string . Equals ( _model , "whisper-1" , StringComparison . OrdinalIgnoreCase ) )
280- {
281- throw new NotSupportedException ( $ "The selected model { _model } does not support streaming transcription. Please use a compatible model.") ;
282- }
273+ EnsureModelSupportsStreaming ( ) ;
283274
284275 MultiPartFormDataBinaryContent content
285276 = CreatePerCallTranscriptionOptions ( options , stream : true )
@@ -297,10 +288,7 @@ public virtual CollectionResult<StreamingAudioTranscriptionUpdate> TranscribeAud
297288 {
298289 Argument . AssertNotNullOrEmpty ( audioFilePath , nameof ( audioFilePath ) ) ;
299290
300- if ( string . Equals ( _model , "whisper-1" , StringComparison . OrdinalIgnoreCase ) )
301- {
302- throw new NotSupportedException ( $ "The selected model { _model } does not support streaming transcription. Please use a compatible model.") ;
303- }
291+ EnsureModelSupportsStreaming ( ) ;
304292
305293 FileStream inputStream = File . OpenRead ( audioFilePath ) ;
306294
@@ -316,6 +304,20 @@ MultiPartFormDataBinaryContent content
316304 return result ;
317305 }
318306
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+
319321 #endregion
320322
321323 #region TranslateAudio
0 commit comments