33 AsyncRealtimeConnectionManager ,
44 RealtimeConnectionManager ,
55)
6+ from portkey_ai ._vendor .openai .types .beta .realtime .transcription_session import (
7+ TranscriptionSession ,
8+ )
69from portkey_ai ._vendor .openai .types .websocket_connection_options import (
710 WebsocketConnectionOptions ,
811)
@@ -17,6 +20,7 @@ def __init__(self, client: Portkey) -> None:
1720 super ().__init__ (client )
1821 self .openai_client = client .openai_client
1922 self .sessions = BetaSessions (client )
23+ self .transcription_sessions = BetaTranscriptionSessions (client )
2024
2125 def connect (
2226 self ,
@@ -33,11 +37,49 @@ def connect(
3337 )
3438
3539
40+ class BetaTranscriptionSessions (APIResource ):
41+ def __init__ (self , client : Portkey ) -> None :
42+ super ().__init__ (client )
43+ self .openai_client = client .openai_client
44+
45+ def create (
46+ self ,
47+ * ,
48+ client_secret : Union [Any , NotGiven ] = NOT_GIVEN ,
49+ include : Union [List [Any ], NotGiven ] = NOT_GIVEN ,
50+ input_audio_format : Union [Any , NotGiven ] = NOT_GIVEN ,
51+ input_audio_noise_reduction : Union [Any , NotGiven ] = NOT_GIVEN ,
52+ input_audio_transcription : Union [Any , NotGiven ] = NOT_GIVEN ,
53+ modalities : Union [List [Any ], NotGiven ] = NOT_GIVEN ,
54+ turn_detection : Union [Any , NotGiven ] = NOT_GIVEN ,
55+ ** kwargs ,
56+ ) -> TranscriptionSession :
57+ extra_headers = kwargs .pop ("extra_headers" , None )
58+ extra_query = kwargs .pop ("extra_query" , None )
59+ extra_body = kwargs .pop ("extra_body" , None )
60+ timeout = kwargs .pop ("timeout" , None )
61+ response = self .openai_client .beta .realtime .transcription_sessions .create (
62+ client_secret = client_secret ,
63+ include = include ,
64+ input_audio_format = input_audio_format ,
65+ input_audio_noise_reduction = input_audio_noise_reduction ,
66+ input_audio_transcription = input_audio_transcription ,
67+ modalities = modalities ,
68+ turn_detection = turn_detection ,
69+ extra_headers = extra_headers ,
70+ extra_query = extra_query ,
71+ extra_body = {** (extra_body or {}), ** kwargs },
72+ timeout = timeout ,
73+ )
74+ return response
75+
76+
3677class AsyncBetaRealtime (AsyncAPIResource ):
3778 def __init__ (self , client : AsyncPortkey ) -> None :
3879 super ().__init__ (client )
3980 self .openai_client = client .openai_client
4081 self .sessions = AsyncBetaSessions (client )
82+ self .transcription_sessions = AsyncBetaTranscriptionSessions (client )
4183
4284 def connect (
4385 self ,
@@ -54,6 +96,43 @@ def connect(
5496 )
5597
5698
99+ class AsyncBetaTranscriptionSessions (AsyncAPIResource ):
100+ def __init__ (self , client : AsyncPortkey ) -> None :
101+ super ().__init__ (client )
102+ self .openai_client = client .openai_client
103+
104+ async def create (
105+ self ,
106+ * ,
107+ client_secret : Union [Any , NotGiven ] = NOT_GIVEN ,
108+ include : Union [List [Any ], NotGiven ] = NOT_GIVEN ,
109+ input_audio_format : Union [Any , NotGiven ] = NOT_GIVEN ,
110+ input_audio_noise_reduction : Union [Any , NotGiven ] = NOT_GIVEN ,
111+ input_audio_transcription : Union [Any , NotGiven ] = NOT_GIVEN ,
112+ modalities : Union [List [Any ], NotGiven ] = NOT_GIVEN ,
113+ turn_detection : Union [Any , NotGiven ] = NOT_GIVEN ,
114+ ** kwargs ,
115+ ) -> TranscriptionSession :
116+ extra_headers = kwargs .pop ("extra_headers" , None )
117+ extra_query = kwargs .pop ("extra_query" , None )
118+ extra_body = kwargs .pop ("extra_body" , None )
119+ timeout = kwargs .pop ("timeout" , None )
120+ response = await self .openai_client .beta .realtime .transcription_sessions .create (
121+ client_secret = client_secret ,
122+ include = include ,
123+ input_audio_format = input_audio_format ,
124+ input_audio_noise_reduction = input_audio_noise_reduction ,
125+ input_audio_transcription = input_audio_transcription ,
126+ modalities = modalities ,
127+ turn_detection = turn_detection ,
128+ extra_headers = extra_headers ,
129+ extra_query = extra_query ,
130+ extra_body = {** (extra_body or {}), ** kwargs },
131+ timeout = timeout ,
132+ )
133+ return response
134+
135+
57136class BetaSessions (APIResource ):
58137 def __init__ (self , client : Portkey ) -> None :
59138 super ().__init__ (client )
0 commit comments