dpo_reader.tts.openai

OpenAI TTS backend - high quality cloud voices.

Classes

OpenAIBackend

OpenAI TTS backend using their API.

class dpo_reader.tts.openai.OpenAIBackend[source]

Bases: TTSBackend

OpenAI TTS backend using their API.

Requires OPENAI_API_KEY environment variable.

name: str = 'openai'
sample_rate: int = 24000
narrator_voice: str = 'onyx'
__init__(model='tts-1')[source]

Initialize OpenAI TTS backend.

Parameters:

model (str) – Model to use - “tts-1” (faster) or “tts-1-hd” (higher quality)

get_voices()[source]

Return list of available voice IDs.

Return type:

list[str]

synthesize(text, voice)[source]

Synthesize text to audio using OpenAI TTS API.

Parameters:
  • text (str) – Text to synthesize

  • voice (str) – Voice ID to use (alloy, echo, fable, onyx, nova, shimmer)

Returns:

Audio as float32 numpy array

Return type:

ndarray