java/resources/audio/subresources/speech/index.md +0 −140 deleted
File Deleted View Diff
1# Speech
2
3## Create speech
4
5`HttpResponse audio().speech().create(SpeechCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
6
7**post** `/audio/speech`
8
9Generates audio from the input text.
10
11Returns the audio file content, or a stream of audio events.
12
13### Parameters
14
15- `SpeechCreateParams params`
16
17 - `String input`
18
19 The text to generate audio for. The maximum length is 4096 characters.
20
21 - `SpeechModel model`
22
23 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
24
25 - `TTS_1("tts-1")`
26
27 - `TTS_1_HD("tts-1-hd")`
28
29 - `GPT_4O_MINI_TTS("gpt-4o-mini-tts")`
30
31 - `GPT_4O_MINI_TTS_2025_12_15("gpt-4o-mini-tts-2025-12-15")`
32
33 - `Voice voice`
34
35 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
36
37 - `String`
38
39 - `enum UnionMember1:`
40
41 - `ALLOY("alloy")`
42
43 - `ASH("ash")`
44
45 - `BALLAD("ballad")`
46
47 - `CORAL("coral")`
48
49 - `ECHO("echo")`
50
51 - `SAGE("sage")`
52
53 - `SHIMMER("shimmer")`
54
55 - `VERSE("verse")`
56
57 - `MARIN("marin")`
58
59 - `CEDAR("cedar")`
60
61 - `class Id:`
62
63 Custom voice reference.
64
65 - `String id`
66
67 The custom voice ID, e.g. `voice_1234`.
68
69 - `Optional<String> instructions`
70
71 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.
72
73 - `Optional<ResponseFormat> responseFormat`
74
75 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
76
77 - `MP3("mp3")`
78
79 - `OPUS("opus")`
80
81 - `AAC("aac")`
82
83 - `FLAC("flac")`
84
85 - `WAV("wav")`
86
87 - `PCM("pcm")`
88
89 - `Optional<Double> speed`
90
91 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
92
93 - `Optional<StreamFormat> streamFormat`
94
95 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
96
97 - `SSE("sse")`
98
99 - `AUDIO("audio")`
100
101### Example
102
103```java
104package com.openai.example;
105
106import com.openai.client.OpenAIClient;
107import com.openai.client.okhttp.OpenAIOkHttpClient;
108import com.openai.core.http.HttpResponse;
109import com.openai.models.audio.speech.SpeechCreateParams;
110import com.openai.models.audio.speech.SpeechModel;
111
112public final class Main {
113 private Main() {}
114
115 public static void main(String[] args) {
116 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
117
118 SpeechCreateParams params = SpeechCreateParams.builder()
119 .input("input")
120 .model(SpeechModel.TTS_1)
121 .voice("string")
122 .build();
123 HttpResponse speech = client.audio().speech().create(params);
124 }
125}
126```
127
128## Domain Types
129
130### Speech Model
131
132- `enum SpeechModel:`
133
134 - `TTS_1("tts-1")`
135
136 - `TTS_1_HD("tts-1-hd")`
137
138 - `GPT_4O_MINI_TTS("gpt-4o-mini-tts")`
139
140 - `GPT_4O_MINI_TTS_2025_12_15("gpt-4o-mini-tts-2025-12-15")`