Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
OpenAITTS
OpenAI Text-to-Speech provider plugin. Wraps the OpenAI TTS API to synthesize speech from text, supporting both streaming and non-streaming output. The default model (gpt-4o-mini-tts)
offers prompt-driven voice control: accent, emotion, intonation, and speed
can all be shaped via a plain-English voice instruction in addition to the
speed multiplier.
Constructor
OpenAI API key. Falls back to the
OPENAI_API_KEY environment variable when None.Built-in voice name to use for synthesis. Defaults to
"ash". Available voices: alloy, ash, ballad, cedar, coral, echo, fable, marin, nova, onyx, sage, shimmer, verse marin and cedar are recommended for the highest quality. Older models (tts-1, tts-1-hd) support only alloy, ash, coral, echo, fable, onyx, nova, sage, and shimmer.TTS model identifier. Defaults to
"gpt-4o-mini-tts". Options: "gpt-4o-mini-tts": newest, most capable; supports prompt-driven voice control (emotion, accent, intonation). "tts-1": lower latency, reduced quality. "tts-1-hd": higher quality, increased latency.Output audio sample rate in Hz. Defaults to
24000.Speaking speed multiplier.
None uses the provider default (1.0). Range is 0.25 – 4.0.When
True (default), audio is returned as a streaming response; False requests the full audio before playback.aclose
emit
The event to emit.
interrupt
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_first_audio_byte
A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
synthesize
The text to synthesize; coerced to a string if needed.