class AI::OpenAI::OpenAISpeechModel

Overview

OpenAI speech model implementation.

Implements the SpeechModelV3 interface for text-to-speech synthesis using OpenAI's audio/speech API.

Supports models:

Example:

model = OpenAISpeechModel.new("tts-1", config)
result = model.do_generate(
  Provider::SpeechModel::CallOptions.new(
    text: "Hello, world!",
    voice: "alloy"
  )
)
File.write("output.mp3", result.audio)

Included Modules

Defined in:

ai/openai/speech/openai_speech_model.cr

Constructors

Instance Method Summary

Instance methods inherited from module AI::Provider::SpeechModel::V3

do_generate(options : CallOptions) : Result do_generate, model_id : String model_id, provider : String provider, specification_version : String specification_version

Constructor Detail

def self.new(model_id : OpenAISpeechModelId, config : OpenAIConfig) #

[View source]
def self.new(model_id : OpenAISpeechModelId, config : OpenAISpeechModelConfig) #

[View source]

Instance Method Detail

Generates speech audio from text.

Parameters:

  • options: Call options including text, voice, format, and speed

Returns speech result with audio data and metadata.


[View source]
def model_id : OpenAISpeechModelId #

The model ID.


[View source]
def provider : String #

Returns the provider name.


[View source]
def specification_version : String #

Returns the specification version.


[View source]