elevenlabs / elevenlabs-python

The official Python API for ElevenLabs Text to Speech.
https://elevenlabs.io/docs/api-reference/getting-started
MIT License
2.2k stars 255 forks source link

(feat): Support for text iterators in `AsyncElevenLabs` #346

Closed BackSlasher closed 2 months ago

BackSlasher commented 3 months ago

Why: Allowing the async client to utilize incoming text streams when generating voice. Very useful when feeding the realtime output of an LLM into the TTS.

Closes #344

What:

  1. Copied RealtimeTextToSpeechClient and text_chunker into AsyncRealtimeTextToSpeechClient and async_text_chunker Most of the logic is intact, aside from async stuff
  2. Added AsyncRealtimeTextToSpeechClient into AsyncElevenLabs just like RealtimeTextToSpeechClient is in ElevenLabs
  3. Added rudimentary testing

The code is basically a copy-paste of what I found in the repo. We can rewrite it to be more elegant, but I figured parity with the sync code is more important.