@@ -9,7 +9,9 @@ class Audio(APIResource):
9
9
OBJECT_NAME = "audio"
10
10
11
11
@classmethod
12
- def _get_url (cls , action ):
12
+ def _get_url (cls , action , deployment_id = None , api_type = None , api_version = None ):
13
+ if api_type in (util .ApiType .AZURE , util .ApiType .AZURE_AD ):
14
+ return f"/{ cls .azure_api_prefix } /deployments/{ deployment_id } /audio/{ action } ?api-version={ api_version } "
13
15
return cls .class_url () + f"/{ action } "
14
16
15
17
@classmethod
@@ -50,6 +52,8 @@ def transcribe(
50
52
api_type = None ,
51
53
api_version = None ,
52
54
organization = None ,
55
+ * ,
56
+ deployment_id = None ,
53
57
** params ,
54
58
):
55
59
requestor , files , data = cls ._prepare_request (
@@ -63,7 +67,8 @@ def transcribe(
63
67
organization = organization ,
64
68
** params ,
65
69
)
66
- url = cls ._get_url ("transcriptions" )
70
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
71
+ url = cls ._get_url ("transcriptions" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
67
72
response , _ , api_key = requestor .request ("post" , url , files = files , params = data )
68
73
return util .convert_to_openai_object (
69
74
response , api_key , api_version , organization
@@ -79,6 +84,8 @@ def translate(
79
84
api_type = None ,
80
85
api_version = None ,
81
86
organization = None ,
87
+ * ,
88
+ deployment_id = None ,
82
89
** params ,
83
90
):
84
91
requestor , files , data = cls ._prepare_request (
@@ -92,7 +99,8 @@ def translate(
92
99
organization = organization ,
93
100
** params ,
94
101
)
95
- url = cls ._get_url ("translations" )
102
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
103
+ url = cls ._get_url ("translations" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
96
104
response , _ , api_key = requestor .request ("post" , url , files = files , params = data )
97
105
return util .convert_to_openai_object (
98
106
response , api_key , api_version , organization
@@ -109,6 +117,8 @@ def transcribe_raw(
109
117
api_type = None ,
110
118
api_version = None ,
111
119
organization = None ,
120
+ * ,
121
+ deployment_id = None ,
112
122
** params ,
113
123
):
114
124
requestor , files , data = cls ._prepare_request (
@@ -122,7 +132,8 @@ def transcribe_raw(
122
132
organization = organization ,
123
133
** params ,
124
134
)
125
- url = cls ._get_url ("transcriptions" )
135
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
136
+ url = cls ._get_url ("transcriptions" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
126
137
response , _ , api_key = requestor .request ("post" , url , files = files , params = data )
127
138
return util .convert_to_openai_object (
128
139
response , api_key , api_version , organization
@@ -139,6 +150,8 @@ def translate_raw(
139
150
api_type = None ,
140
151
api_version = None ,
141
152
organization = None ,
153
+ * ,
154
+ deployment_id = None ,
142
155
** params ,
143
156
):
144
157
requestor , files , data = cls ._prepare_request (
@@ -152,7 +165,8 @@ def translate_raw(
152
165
organization = organization ,
153
166
** params ,
154
167
)
155
- url = cls ._get_url ("translations" )
168
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
169
+ url = cls ._get_url ("translations" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
156
170
response , _ , api_key = requestor .request ("post" , url , files = files , params = data )
157
171
return util .convert_to_openai_object (
158
172
response , api_key , api_version , organization
@@ -168,6 +182,8 @@ async def atranscribe(
168
182
api_type = None ,
169
183
api_version = None ,
170
184
organization = None ,
185
+ * ,
186
+ deployment_id = None ,
171
187
** params ,
172
188
):
173
189
requestor , files , data = cls ._prepare_request (
@@ -181,7 +197,8 @@ async def atranscribe(
181
197
organization = organization ,
182
198
** params ,
183
199
)
184
- url = cls ._get_url ("transcriptions" )
200
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
201
+ url = cls ._get_url ("transcriptions" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
185
202
response , _ , api_key = await requestor .arequest (
186
203
"post" , url , files = files , params = data
187
204
)
@@ -199,6 +216,8 @@ async def atranslate(
199
216
api_type = None ,
200
217
api_version = None ,
201
218
organization = None ,
219
+ * ,
220
+ deployment_id = None ,
202
221
** params ,
203
222
):
204
223
requestor , files , data = cls ._prepare_request (
@@ -212,7 +231,8 @@ async def atranslate(
212
231
organization = organization ,
213
232
** params ,
214
233
)
215
- url = cls ._get_url ("translations" )
234
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
235
+ url = cls ._get_url ("translations" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
216
236
response , _ , api_key = await requestor .arequest (
217
237
"post" , url , files = files , params = data
218
238
)
@@ -231,6 +251,8 @@ async def atranscribe_raw(
231
251
api_type = None ,
232
252
api_version = None ,
233
253
organization = None ,
254
+ * ,
255
+ deployment_id = None ,
234
256
** params ,
235
257
):
236
258
requestor , files , data = cls ._prepare_request (
@@ -244,7 +266,8 @@ async def atranscribe_raw(
244
266
organization = organization ,
245
267
** params ,
246
268
)
247
- url = cls ._get_url ("transcriptions" )
269
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
270
+ url = cls ._get_url ("transcriptions" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
248
271
response , _ , api_key = await requestor .arequest (
249
272
"post" , url , files = files , params = data
250
273
)
@@ -263,6 +286,8 @@ async def atranslate_raw(
263
286
api_type = None ,
264
287
api_version = None ,
265
288
organization = None ,
289
+ * ,
290
+ deployment_id = None ,
266
291
** params ,
267
292
):
268
293
requestor , files , data = cls ._prepare_request (
@@ -276,7 +301,8 @@ async def atranslate_raw(
276
301
organization = organization ,
277
302
** params ,
278
303
)
279
- url = cls ._get_url ("translations" )
304
+ api_type , api_version = cls ._get_api_type_and_version (api_type , api_version )
305
+ url = cls ._get_url ("translations" , deployment_id = deployment_id , api_type = api_type , api_version = api_version )
280
306
response , _ , api_key = await requestor .arequest (
281
307
"post" , url , files = files , params = data
282
308
)
0 commit comments