go/resources/audio/subresources/translations/index.md +0 −171 deleted
File Deleted View Diff
1# Translations
2
3## Create translation
4
5`client.Audio.Translations.New(ctx, body) (*Translation, error)`
6
7**post** `/audio/translations`
8
9Translates audio into English.
10
11### Parameters
12
13- `body AudioTranslationNewParams`
14
15 - `File param.Field[Reader]`
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 - `Model param.Field[AudioModel]`
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 - `string`
24
25 - `type AudioModel string`
26
27 - `const AudioModelWhisper1 AudioModel = "whisper-1"`
28
29 - `const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe"`
30
31 - `const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe"`
32
33 - `const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15"`
34
35 - `const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"`
36
37 - `Prompt param.Field[string]`
38
39 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.
40
41 - `ResponseFormat param.Field[AudioTranslationNewParamsResponseFormat]`
42
43 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
44
45 - `const AudioTranslationNewParamsResponseFormatJSON AudioTranslationNewParamsResponseFormat = "json"`
46
47 - `const AudioTranslationNewParamsResponseFormatText AudioTranslationNewParamsResponseFormat = "text"`
48
49 - `const AudioTranslationNewParamsResponseFormatSRT AudioTranslationNewParamsResponseFormat = "srt"`
50
51 - `const AudioTranslationNewParamsResponseFormatVerboseJSON AudioTranslationNewParamsResponseFormat = "verbose_json"`
52
53 - `const AudioTranslationNewParamsResponseFormatVTT AudioTranslationNewParamsResponseFormat = "vtt"`
54
55 - `Temperature param.Field[float64]`
56
57 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.
58
59### Returns
60
61- `type AudioTranslationNewResponse interface{…}`
62
63 - `type Translation struct{…}`
64
65 - `Text string`
66
67### Example
68
69```go
70package main
71
72import (
73 "bytes"
74 "context"
75 "fmt"
76 "io"
77
78 "github.com/openai/openai-go"
79 "github.com/openai/openai-go/option"
80)
81
82func main() {
83 client := openai.NewClient(
84 option.WithAPIKey("My API Key"),
85 )
86 translation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{
87 File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
88 Model: openai.AudioModelWhisper1,
89 })
90 if err != nil {
91 panic(err.Error())
92 }
93 fmt.Printf("%+v\n", translation)
94}
95```
96
97#### Response
98
99```json
100{
101 "text": "text"
102}
103```
104
105## Domain Types
106
107### Translation
108
109- `type Translation struct{…}`
110
111 - `Text string`
112
113### Translation Verbose
114
115- `type TranslationVerbose struct{…}`
116
117 - `Duration float64`
118
119 The duration of the input audio.
120
121 - `Language string`
122
123 The language of the output translation (always `english`).
124
125 - `Text string`
126
127 The translated text.
128
129 - `Segments []TranscriptionSegment`
130
131 Segments of the translated text and their corresponding details.
132
133 - `ID int64`
134
135 Unique identifier of the segment.
136
137 - `AvgLogprob float64`
138
139 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
140
141 - `CompressionRatio float64`
142
143 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
144
145 - `End float64`
146
147 End time of the segment in seconds.
148
149 - `NoSpeechProb float64`
150
151 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.
152
153 - `Seek int64`
154
155 Seek offset of the segment.
156
157 - `Start float64`
158
159 Start time of the segment in seconds.
160
161 - `Temperature float64`
162
163 Temperature parameter used for generating the segment.
164
165 - `Text string`
166
167 Text content of the segment.
168
169 - `Tokens []int64`
170
171 Array of token IDs for the text content.