ripe-elephant-41652
08/07/2025, 4:55 AMtall-airline-16756
08/07/2025, 4:55 AMripe-elephant-41652
08/07/2025, 4:56 AMtall-airline-16756
08/07/2025, 4:56 AMuse_streaming
parameter during TTS initialization.
If you need help with implementation or configuration, let me know!
Sources: livekit-plugins/livekit-plugins-google/README.md | Google Cloud TTS integration guide | LiveKit Docstall-airline-16756
08/07/2025, 4:56 AMuse_streaming
parameter during TTS initialization.
If you need help with implementation or configuration, let me know!ripe-elephant-41652
08/07/2025, 4:59 AMripe-elephant-41652
08/07/2025, 5:00 AMtall-airline-16756
08/07/2025, 5:00 AMRuntimeError: aclose(): asynchronous generator is already running
pops up when an asynchronous generator tries to close more than once. If you're using use_streaming=True
with the LiveKit Google TTS plugin, the key is to make sure each stream is closed just once and handled carefully.
Here’s a simple way to fix it:
1. Update the aclose()
method in both the TTS
and SynthesizeStream
classes to check if a stream is already closed before calling aclose()
.
2. Make sure streams get removed from the WeakSet
after closing so they don’t get closed again by mistake.
Here’s some example code to guide you:
async def aclose(self):
for stream in list(self._streams):
if not stream.closed:
await stream.aclose()
self._streams.clear()
async def aclose(self):
if self.closed:
return
self.closed = True
if not self.input.closed:
await self.input.aclose()
if not self.output.closed:
await self.output.aclose()
self._tts._streams.discard(self)
This way, everything cleans up nicely and avoids that error. If you get stuck or want to chat more about it, just let me know—I’m here to help!ripe-elephant-41652
08/07/2025, 5:01 AMtall-airline-16756
08/07/2025, 5:01 AMuse_streaming=True
.
To fix this, the plugin’s code needs a little tweak to make sure streams are closed just once and that the async generators are managed properly. If you’d like, I’m here to help walk you through those changes—just let me know!ripe-elephant-41652
08/07/2025, 5:09 AMtall-airline-16756
08/07/2025, 5:09 AM