ruby/resources/audio/subresources/translations/index.md +0 −275 deleted
File Deleted View Diff
1# Translations
2
3## Create translation
4
5`audio.translations.create(**kwargs) -> TranslationCreateResponse`
6
7**post** `/audio/translations`
8
9Translates audio into English.
10
11### Parameters
12
13- `file: String`
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: String | 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 - `String = String`
22
23 - `AudioModel = :"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: String`
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: :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: 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 = Translation | TranslationVerbose`
60
61 - `class Translation`
62
63 - `text: String`
64
65 - `class TranslationVerbose`
66
67 - `duration: Float`
68
69 The duration of the input audio.
70
71 - `language: String`
72
73 The language of the output translation (always `english`).
74
75 - `text: String`
76
77 The translated text.
78
79 - `segments: Array[TranscriptionSegment]`
80
81 Segments of the translated text and their corresponding details.
82
83 - `id: Integer`
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: Integer`
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: String`
116
117 Text content of the segment.
118
119 - `tokens: Array[Integer]`
120
121 Array of token IDs for the text content.
122
123### Example
124
125```ruby
126require "openai"
127
128openai = OpenAI::Client.new(api_key: "My API Key")
129
130translation = openai.audio.translations.create(file: StringIO.new("Example data"), model: :"whisper-1")
131
132puts(translation)
133```
134
135#### Response
136
137```json
138{
139 "text": "text"
140}
141```
142
143## Domain Types
144
145### Translation
146
147- `class Translation`
148
149 - `text: String`
150
151### Translation Verbose
152
153- `class TranslationVerbose`
154
155 - `duration: Float`
156
157 The duration of the input audio.
158
159 - `language: String`
160
161 The language of the output translation (always `english`).
162
163 - `text: String`
164
165 The translated text.
166
167 - `segments: Array[TranscriptionSegment]`
168
169 Segments of the translated text and their corresponding details.
170
171 - `id: Integer`
172
173 Unique identifier of the segment.
174
175 - `avg_logprob: Float`
176
177 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
178
179 - `compression_ratio: Float`
180
181 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
182
183 - `end_: Float`
184
185 End time of the segment in seconds.
186
187 - `no_speech_prob: Float`
188
189 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.
190
191 - `seek: Integer`
192
193 Seek offset of the segment.
194
195 - `start: Float`
196
197 Start time of the segment in seconds.
198
199 - `temperature: Float`
200
201 Temperature parameter used for generating the segment.
202
203 - `text: String`
204
205 Text content of the segment.
206
207 - `tokens: Array[Integer]`
208
209 Array of token IDs for the text content.
210
211### Translation Create Response
212
213- `TranslationCreateResponse = Translation | TranslationVerbose`
214
215 - `class Translation`
216
217 - `text: String`
218
219 - `class TranslationVerbose`
220
221 - `duration: Float`
222
223 The duration of the input audio.
224
225 - `language: String`
226
227 The language of the output translation (always `english`).
228
229 - `text: String`
230
231 The translated text.
232
233 - `segments: Array[TranscriptionSegment]`
234
235 Segments of the translated text and their corresponding details.
236
237 - `id: Integer`
238
239 Unique identifier of the segment.
240
241 - `avg_logprob: Float`
242
243 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
244
245 - `compression_ratio: Float`
246
247 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
248
249 - `end_: Float`
250
251 End time of the segment in seconds.
252
253 - `no_speech_prob: Float`
254
255 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.
256
257 - `seek: Integer`
258
259 Seek offset of the segment.
260
261 - `start: Float`
262
263 Start time of the segment in seconds.
264
265 - `temperature: Float`
266
267 Temperature parameter used for generating the segment.
268
269 - `text: String`
270
271 Text content of the segment.
272
273 - `tokens: Array[Integer]`
274
275 Array of token IDs for the text content.