Class: OpenAI::Models::Audio::SpeechCreateParams

Inherits:
Internal::Type::BaseModel show all
Extended by:
Internal::Type::RequestParameters::Converter
Includes:
Internal::Type::RequestParameters
Defined in:
lib/openai/models/audio/speech_create_params.rb,
sig/openai/models/audio/speech_create_params.rbs

Overview

See Also:

  • OpenAI::Resources::Audio::Speech#create

Defined Under Namespace

Modules: Model, ResponseFormat, StreamFormat, Voice

Instance Attribute Summary collapse

Attributes included from Internal::Type::RequestParameters

#request_options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Internal::Type::RequestParameters::Converter

dump_request

Methods included from Internal::Type::RequestParameters

included

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, stream_format: nil, request_options: {}) ⇒ Object

Some parameter documentations has been truncated, see OpenAI::Models::Audio::SpeechCreateParams for more details.

Parameters:



# File 'lib/openai/models/audio/speech_create_params.rb', line 63

Instance Attribute Details

#inputString

The text to generate audio for. The maximum length is 4096 characters.

Parameters:

  • value (String)

Returns:

  • (String)


15
# File 'lib/openai/models/audio/speech_create_params.rb', line 15

required :input, String

#instructionsString?

Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

Parameters:

  • (String)

Returns:

  • (String, nil)


40
# File 'lib/openai/models/audio/speech_create_params.rb', line 40

optional :instructions, String

#modelString, ...

One of the available TTS models: tts-1, tts-1-hd, gpt-4o-mini-tts, or gpt-4o-mini-tts-2025-12-15.

Parameters:

  • value (OpenAI::Models::Audio::SpeechCreateParams::model)

Returns:



22
# File 'lib/openai/models/audio/speech_create_params.rb', line 22

required :model, union: -> { OpenAI::Audio::SpeechCreateParams::Model }

#response_formatSymbol, ...

The format to audio in. Supported formats are mp3, opus, aac, flac, wav, and pcm.



47
# File 'lib/openai/models/audio/speech_create_params.rb', line 47

optional :response_format, enum: -> { OpenAI::Audio::SpeechCreateParams::ResponseFormat }

#speedFloat?

The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.

Parameters:

  • (Float)

Returns:

  • (Float, nil)


54
# File 'lib/openai/models/audio/speech_create_params.rb', line 54

optional :speed, Float

#stream_formatSymbol, ...

The format to stream the audio in. Supported formats are sse and audio. sse is not supported for tts-1 or tts-1-hd.



61
# File 'lib/openai/models/audio/speech_create_params.rb', line 61

optional :stream_format, enum: -> { OpenAI::Audio::SpeechCreateParams::StreamFormat }

#voiceString, ...

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.

Parameters:

  • value (OpenAI::Models::Audio::SpeechCreateParams::voice)

Returns:



33
# File 'lib/openai/models/audio/speech_create_params.rb', line 33

required :voice, union: -> { OpenAI::Audio::SpeechCreateParams::Voice }

Class Method Details

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/openai/models/audio/speech_create_params.rb', line 185

.variantsArray(String, Symbol, OpenAI::Models::Audio::SpeechModel)

Returns:



# File 'lib/openai/models/audio/speech_create_params.rb', line 93

Instance Method Details

#to_hash{

Returns:

  • ({)


57
# File 'sig/openai/models/audio/speech_create_params.rbs', line 57

def to_hash: -> {