@@ -198,6 +198,7 @@ def __init__(self) -> None:
198198 self ._playback_tracker : RealtimePlaybackTracker | None = None
199199 self ._created_session : OpenAISessionCreateRequest | None = None
200200 self ._server_event_type_adapter = get_server_event_type_adapter ()
201+ self ._call_id : str | None = None
201202
202203 async def connect (self , options : RealtimeModelConfig ) -> None :
203204 """Establish a connection to the model and keep it alive."""
@@ -220,6 +221,7 @@ async def connect(self, options: RealtimeModelConfig) -> None:
220221 if model_name :
221222 self .model = model_name
222223
224+ self ._call_id = call_id
223225 api_key = await get_api_key (options .get ("api_key" ))
224226
225227 if "tracing" in model_settings :
@@ -833,10 +835,13 @@ def _get_session_config(
833835 speed = model_settings .get ("speed" )
834836 modalities = model_settings .get ("modalities" , DEFAULT_MODEL_SETTINGS .get ("modalities" ))
835837
836- input_audio_format = model_settings .get (
837- "input_audio_format" ,
838- DEFAULT_MODEL_SETTINGS .get ("input_audio_format" ),
839- )
838+ if self ._call_id :
839+ input_audio_format = model_settings .get ("input_audio_format" )
840+ else :
841+ input_audio_format = model_settings .get (
842+ "input_audio_format" ,
843+ DEFAULT_MODEL_SETTINGS .get ("input_audio_format" ),
844+ )
840845 input_audio_transcription = model_settings .get (
841846 "input_audio_transcription" ,
842847 DEFAULT_MODEL_SETTINGS .get ("input_audio_transcription" ),
@@ -845,10 +850,13 @@ def _get_session_config(
845850 "turn_detection" ,
846851 DEFAULT_MODEL_SETTINGS .get ("turn_detection" ),
847852 )
848- output_audio_format = model_settings .get (
849- "output_audio_format" ,
850- DEFAULT_MODEL_SETTINGS .get ("output_audio_format" ),
851- )
853+ if self ._call_id :
854+ output_audio_format = model_settings .get ("output_audio_format" )
855+ else :
856+ output_audio_format = model_settings .get (
857+ "output_audio_format" ,
858+ DEFAULT_MODEL_SETTINGS .get ("output_audio_format" ),
859+ )
852860 input_audio_noise_reduction = model_settings .get (
853861 "input_audio_noise_reduction" ,
854862 DEFAULT_MODEL_SETTINGS .get ("input_audio_noise_reduction" ),
0 commit comments