TTS Optimization to generate speech lazily
Currently, all speech is generated sequentially. However, if the agent is interrupted mid-speech, some audio will not be played, and a significant cost will still be incurred (TTS is typically the most expensive component among STT, LLM, and TTS).
I propose generating speech in a more efficient manner. For instance, the initial speech segment could be generated immediately. Subsequently, there would be a 1.5-second delay (depending on the provider) before generating the next chunk of audio (1.5 delay before current speech ends) coinciding with the completion of the current segment. This approach aims to minimize wasted computational resources and expenditure.
I couldn't find an official API solution for this problem.
Thanks.
this feature is included in agents 1.2.3, here is an example https://github.com/livekit/agents/blob/[email protected]/examples/voice_agents/tts_text_pacing.py
@longcw Does it work with Elevenlabs TTS?
@longcw Does it work with Elevenlabs TTS?
for 11labs it needs a tts.StreamAdapter to make it work in non-streaming mode. 11labs also has the auto_mode that accepts full sentences in the stream, we can support it with streaming laterly.