ruby/resources/audio/subresources/speech/index.md +0 −131 deleted
File Deleted View Diff
1# Speech
2
3## Create speech
4
5`audio.speech.create(**kwargs) -> StringIO`
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- `input: String`
16
17 The text to generate audio for. The maximum length is 4096 characters.
18
19- `model: String | SpeechModel`
20
21 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`.
22
23 - `String = String`
24
25 - `SpeechModel = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" | :"gpt-4o-mini-tts-2025-12-15"`
26
27 - `:"tts-1"`
28
29 - `:"tts-1-hd"`
30
31 - `:"gpt-4o-mini-tts"`
32
33 - `:"gpt-4o-mini-tts-2025-12-15"`
34
35- `voice: String | :alloy | :ash | :ballad | 7 more | ID{ id}`
36
37 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).
38
39 - `String = String`
40
41 - `Voice = :alloy | :ash | :ballad | 7 more`
42
43 - `:alloy`
44
45 - `:ash`
46
47 - `:ballad`
48
49 - `:coral`
50
51 - `:echo`
52
53 - `:sage`
54
55 - `:shimmer`
56
57 - `:verse`
58
59 - `:marin`
60
61 - `:cedar`
62
63 - `class ID`
64
65 Custom voice reference.
66
67 - `id: String`
68
69 The custom voice ID, e.g. `voice_1234`.
70
71- `instructions: String`
72
73 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.
74
75- `response_format: :mp3 | :opus | :aac | 3 more`
76
77 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
78
79 - `:mp3`
80
81 - `:opus`
82
83 - `:aac`
84
85 - `:flac`
86
87 - `:wav`
88
89 - `:pcm`
90
91- `speed: Float`
92
93 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
94
95- `stream_format: :sse | :audio`
96
97 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
98
99 - `:sse`
100
101 - `:audio`
102
103### Returns
104
105- `StringIO`
106
107### Example
108
109```ruby
110require "openai"
111
112openai = OpenAI::Client.new(api_key: "My API Key")
113
114speech = openai.audio.speech.create(input: "input", model: :"tts-1", voice: "string")
115
116puts(speech)
117```
118
119## Domain Types
120
121### Speech Model
122
123- `SpeechModel = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" | :"gpt-4o-mini-tts-2025-12-15"`
124
125 - `:"tts-1"`
126
127 - `:"tts-1-hd"`
128
129 - `:"gpt-4o-mini-tts"`
130
131 - `:"gpt-4o-mini-tts-2025-12-15"`