python/resources/audio/subresources/translations/index.md +0 −300 deleted
File Deleted View Diff
1# Translations
2
3## Create translation
4
5`audio.translations.create(TranslationCreateParams**kwargs) -> TranslationCreateResponse`
6
7**post** `/audio/translations`
8
9Translates audio into English.
10
11### Parameters
12
13- `file: FileTypes`
14
15 The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
16
17- `model: Union[str, AudioModel]`
18
19 ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
20
21 - `str`
22
23 - `Literal["whisper-1", "gpt-4o-transcribe", "gpt-4o-mini-transcribe", 2 more]`
24
25 - `"whisper-1"`
26
27 - `"gpt-4o-transcribe"`
28
29 - `"gpt-4o-mini-transcribe"`
30
31 - `"gpt-4o-mini-transcribe-2025-12-15"`
32
33 - `"gpt-4o-transcribe-diarize"`
34
35- `prompt: Optional[str]`
36
37 An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should be in English.
38
39- `response_format: Optional[Literal["json", "text", "srt", 2 more]]`
40
41 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
42
43 - `"json"`
44
45 - `"text"`
46
47 - `"srt"`
48
49 - `"verbose_json"`
50
51 - `"vtt"`
52
53- `temperature: Optional[float]`
54
55 The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
56
57### Returns
58
59- `TranslationCreateResponse`
60
61 - `class Translation: …`
62
63 - `text: str`
64
65 - `class TranslationVerbose: …`
66
67 - `duration: float`
68
69 The duration of the input audio.
70
71 - `language: str`
72
73 The language of the output translation (always `english`).
74
75 - `text: str`
76
77 The translated text.
78
79 - `segments: Optional[List[TranscriptionSegment]]`
80
81 Segments of the translated text and their corresponding details.
82
83 - `id: int`
84
85 Unique identifier of the segment.
86
87 - `avg_logprob: float`
88
89 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
90
91 - `compression_ratio: float`
92
93 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
94
95 - `end: float`
96
97 End time of the segment in seconds.
98
99 - `no_speech_prob: float`
100
101 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.
102
103 - `seek: int`
104
105 Seek offset of the segment.
106
107 - `start: float`
108
109 Start time of the segment in seconds.
110
111 - `temperature: float`
112
113 Temperature parameter used for generating the segment.
114
115 - `text: str`
116
117 Text content of the segment.
118
119 - `tokens: List[int]`
120
121 Array of token IDs for the text content.
122
123### Example
124
125```python
126import os
127from openai import OpenAI
128
129client = OpenAI(
130 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
131)
132translation = client.audio.translations.create(
133 file=b"Example data",
134 model="whisper-1",
135)
136print(translation)
137```
138
139#### Response
140
141```json
142{
143 "text": "text"
144}
145```
146
147### Example
148
149```python
150from openai import OpenAI
151client = OpenAI()
152
153audio_file = open("speech.mp3", "rb")
154transcript = client.audio.translations.create(
155 model="whisper-1",
156 file=audio_file
157)
158```
159
160#### Response
161
162```json
163{
164 "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
165}
166```
167
168## Domain Types
169
170### Translation
171
172- `class Translation: …`
173
174 - `text: str`
175
176### Translation Verbose
177
178- `class TranslationVerbose: …`
179
180 - `duration: float`
181
182 The duration of the input audio.
183
184 - `language: str`
185
186 The language of the output translation (always `english`).
187
188 - `text: str`
189
190 The translated text.
191
192 - `segments: Optional[List[TranscriptionSegment]]`
193
194 Segments of the translated text and their corresponding details.
195
196 - `id: int`
197
198 Unique identifier of the segment.
199
200 - `avg_logprob: float`
201
202 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
203
204 - `compression_ratio: float`
205
206 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
207
208 - `end: float`
209
210 End time of the segment in seconds.
211
212 - `no_speech_prob: float`
213
214 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.
215
216 - `seek: int`
217
218 Seek offset of the segment.
219
220 - `start: float`
221
222 Start time of the segment in seconds.
223
224 - `temperature: float`
225
226 Temperature parameter used for generating the segment.
227
228 - `text: str`
229
230 Text content of the segment.
231
232 - `tokens: List[int]`
233
234 Array of token IDs for the text content.
235
236### Translation Create Response
237
238- `TranslationCreateResponse`
239
240 - `class Translation: …`
241
242 - `text: str`
243
244 - `class TranslationVerbose: …`
245
246 - `duration: float`
247
248 The duration of the input audio.
249
250 - `language: str`
251
252 The language of the output translation (always `english`).
253
254 - `text: str`
255
256 The translated text.
257
258 - `segments: Optional[List[TranscriptionSegment]]`
259
260 Segments of the translated text and their corresponding details.
261
262 - `id: int`
263
264 Unique identifier of the segment.
265
266 - `avg_logprob: float`
267
268 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
269
270 - `compression_ratio: float`
271
272 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
273
274 - `end: float`
275
276 End time of the segment in seconds.
277
278 - `no_speech_prob: float`
279
280 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.
281
282 - `seek: int`
283
284 Seek offset of the segment.
285
286 - `start: float`
287
288 Start time of the segment in seconds.
289
290 - `temperature: float`
291
292 Temperature parameter used for generating the segment.
293
294 - `text: str`
295
296 Text content of the segment.
297
298 - `tokens: List[int]`
299
300 Array of token IDs for the text content.