ElevenlabsEngine uses the ElevenLabs streaming text-to-speech API. It is a
cloud engine and requires an ElevenLabs API key.
pip install "realtimetts[elevenlabs]"Set the API key in the environment or pass it to the constructor:
$env:ELEVENLABS_API_KEY = "..."Install mpv for local playback of the MPEG stream.
from RealtimeTTS import TextToAudioStream, ElevenlabsEngine
if __name__ == "__main__":
engine = ElevenlabsEngine(voice="Nicole")
stream = TextToAudioStream(engine)
stream.feed("Hello from ElevenLabs.")
stream.play()- Constructor defaults include
voice="Nicole",id="piTKgcLEGmPE4e6mEKli",category="premade", andmodel="eleven_multilingual_v2". get_voices()calls the ElevenLabs API and returnsElevenlabsVoiceobjects.- The current source comments note that newer ElevenLabs stream endpoints do not accept clarity, stability, or style values per request. The constructor keeps those fields for compatibility.
- Output reports
pyaudio.paCustomFormat, -1, -1, so compressed playback needs the external player path.
- Missing key errors can be fixed by passing
api_keyor settingELEVENLABS_API_KEY. - If a voice name is not found, pass the explicit voice ID in the constructor.