java/resources/audio/subresources/translations/index.md +0 −222 deleted
File Deleted View Diff
1# Translations
2
3## Create translation
4
5`TranslationCreateResponse audio().translations().create(TranslationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
6
7**post** `/audio/translations`
8
9Translates audio into English.
10
11### Parameters
12
13- `TranslationCreateParams params`
14
15 - `String file`
16
17 The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
18
19 - `AudioModel model`
20
21 ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
22
23 - `WHISPER_1("whisper-1")`
24
25 - `GPT_4O_TRANSCRIBE("gpt-4o-transcribe")`
26
27 - `GPT_4O_MINI_TRANSCRIBE("gpt-4o-mini-transcribe")`
28
29 - `GPT_4O_MINI_TRANSCRIBE_2025_12_15("gpt-4o-mini-transcribe-2025-12-15")`
30
31 - `GPT_4O_TRANSCRIBE_DIARIZE("gpt-4o-transcribe-diarize")`
32
33 - `Optional<String> prompt`
34
35 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.
36
37 - `Optional<ResponseFormat> responseFormat`
38
39 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
40
41 - `JSON("json")`
42
43 - `TEXT("text")`
44
45 - `SRT("srt")`
46
47 - `VERBOSE_JSON("verbose_json")`
48
49 - `VTT("vtt")`
50
51 - `Optional<Double> temperature`
52
53 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.
54
55### Returns
56
57- `class TranslationCreateResponse: A class that can be one of several variants.union`
58
59 - `class Translation:`
60
61 - `String text`
62
63 - `class TranslationVerbose:`
64
65 - `double duration`
66
67 The duration of the input audio.
68
69 - `String language`
70
71 The language of the output translation (always `english`).
72
73 - `String text`
74
75 The translated text.
76
77 - `Optional<List<TranscriptionSegment>> segments`
78
79 Segments of the translated text and their corresponding details.
80
81 - `long id`
82
83 Unique identifier of the segment.
84
85 - `double avgLogprob`
86
87 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
88
89 - `double compressionRatio`
90
91 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
92
93 - `double end`
94
95 End time of the segment in seconds.
96
97 - `double noSpeechProb`
98
99 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.
100
101 - `long seek`
102
103 Seek offset of the segment.
104
105 - `double start`
106
107 Start time of the segment in seconds.
108
109 - `double temperature`
110
111 Temperature parameter used for generating the segment.
112
113 - `String text`
114
115 Text content of the segment.
116
117 - `List<long> tokens`
118
119 Array of token IDs for the text content.
120
121### Example
122
123```java
124package com.openai.example;
125
126import com.openai.client.OpenAIClient;
127import com.openai.client.okhttp.OpenAIOkHttpClient;
128import com.openai.models.audio.AudioModel;
129import com.openai.models.audio.translations.TranslationCreateParams;
130import com.openai.models.audio.translations.TranslationCreateResponse;
131import java.io.ByteArrayInputStream;
132
133public final class Main {
134 private Main() {}
135
136 public static void main(String[] args) {
137 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
138
139 TranslationCreateParams params = TranslationCreateParams.builder()
140 .file(new ByteArrayInputStream("Example data".getBytes()))
141 .model(AudioModel.WHISPER_1)
142 .build();
143 TranslationCreateResponse translation = client.audio().translations().create(params);
144 }
145}
146```
147
148#### Response
149
150```json
151{
152 "text": "text"
153}
154```
155
156## Domain Types
157
158### Translation
159
160- `class Translation:`
161
162 - `String text`
163
164### Translation Verbose
165
166- `class TranslationVerbose:`
167
168 - `double duration`
169
170 The duration of the input audio.
171
172 - `String language`
173
174 The language of the output translation (always `english`).
175
176 - `String text`
177
178 The translated text.
179
180 - `Optional<List<TranscriptionSegment>> segments`
181
182 Segments of the translated text and their corresponding details.
183
184 - `long id`
185
186 Unique identifier of the segment.
187
188 - `double avgLogprob`
189
190 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
191
192 - `double compressionRatio`
193
194 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
195
196 - `double end`
197
198 End time of the segment in seconds.
199
200 - `double noSpeechProb`
201
202 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.
203
204 - `long seek`
205
206 Seek offset of the segment.
207
208 - `double start`
209
210 Start time of the segment in seconds.
211
212 - `double temperature`
213
214 Temperature parameter used for generating the segment.
215
216 - `String text`
217
218 Text content of the segment.
219
220 - `List<long> tokens`
221
222 Array of token IDs for the text content.