AI::OpenAI::OpenAISpeechModel
Inherits AI::Provider::SpeechModel::V3 < Reference < Object
OpenAI speech model implementation.
Implements the SpeechModelV3 interface for text-to-speech synthesis using OpenAI's audio/speech API.
Supports models:
- tts-1 - Fast text-to-speech model
- tts-1-hd - High-definition text-to-speech model
- gpt-4o-mini-tts - GPT-4o mini text-to-speech model
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)
Constructors
new(model_id : OpenAISpeechModelId, config : OpenAIConfig)
Sourcenew(model_id : OpenAISpeechModelId, config : OpenAISpeechModelConfig)
SourceInstance methods
do_generate(options : Provider::SpeechModel::CallOptions) : Provider::SpeechModel::Result
Generates speech audio from text.
Parameters:
- options: Call options including text, voice, format, and speed
Returns speech result with audio data and metadata.