class
AI::OpenAI::OpenAISpeechModel
- AI::OpenAI::OpenAISpeechModel
- Reference
- Object
Overview
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)
Included Modules
Defined in:
ai/openai/speech/openai_speech_model.crConstructors
- .new(model_id : OpenAISpeechModelId, config : OpenAIConfig)
- .new(model_id : OpenAISpeechModelId, config : OpenAISpeechModelConfig)
Instance Method Summary
-
#do_generate(options : Provider::SpeechModel::CallOptions) : Provider::SpeechModel::Result
Generates speech audio from text.
-
#model_id : OpenAISpeechModelId
The model ID.
-
#provider : String
Returns the provider name.
-
#specification_version : String
Returns the specification version.
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
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.