ModelsLabEngine uses the ModelsLab text-to-speech API. It exists under
RealtimeTTS.engines, but the root RealtimeTTS package does not currently
lazy-export it. Import it from RealtimeTTS.engines until that mismatch is
resolved.
Install RealtimeTTS with the ModelsLab extra. The source uses requests plus
normal RealtimeTTS playback dependencies:
pip install "realtimetts[modelslab]"Set the API key in the environment or pass it to the constructor:
$env:MODELSLAB_API_KEY = "..."from RealtimeTTS import TextToAudioStream
from RealtimeTTS.engines import ModelsLabEngine
if __name__ == "__main__":
engine = ModelsLabEngine(voice="madison", language="american english")
stream = TextToAudioStream(engine)
stream.feed("Hello from ModelsLab.")
stream.play()- Defaults are
voice="madison",language="american english",speed=1.0, andemotion=False. - The source includes built-in voice IDs for American/British English, Spanish, French, German, Italian, Japanese, Hindi, Mandarin Chinese, and Brazilian Portuguese.
- The API can return
processing; the engine polls the returned fetch URL. - Output is MP3 and reports custom-format playback at 22050 Hz.
- Missing key errors can be fixed by passing
api_keyor settingMODELSLAB_API_KEY. - Because the root package export is absent, prefer
from RealtimeTTS.engines import ModelsLabEngine.