Class: OpenAI::Resources::Audio::Speech

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/audio/speech.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Speech

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Speech.

Parameters:

API:

  • private



48
49
50
# File 'lib/openai/resources/audio/speech.rb', line 48

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

Generates audio from the input text.

Parameters:

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

  • One of the available TTS models:

  • The voice to use when generating the audio. Supported voices are alloy, ash,

  • Control the voice of your generated audio with additional instructions. Does not

  • The format to audio in. Supported formats are mp3, opus, aac, flac, `wav

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

  • The format to stream the audio in. Supported formats are sse and audio. `sse

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/openai/resources/audio/speech.rb', line 33

def create(params)
  parsed, options = OpenAI::Audio::SpeechCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "audio/speech",
    headers: {"accept" => "application/octet-stream"},
    body: parsed,
    model: StringIO,
    options: options
  )
end