Google Cloud TTS isn't working while running
Getting the below error when I am trying to run it in the console
File "/Users/vishnuteja/Documents/WorkSpace/ava/venv/lib/python3.12/site-packages/livekit/plugins/google/tts.py", line 325, in _run_segments
await self._run_stream(input_stream, output_emitter, streaming_config)
File "/Users/vishnuteja/Documents/WorkSpace/ava/venv/lib/python3.12/site-packages/livekit/plugins/google/tts.py", line 375, in _run_stream
await input_gen.aclose()
RuntimeError: aclose(): asynchronous generator is already running
I am using the below versions python - 3.12
livekit 1.0.12
livekit-agents 1.2.1
livekit-api 1.0.3
livekit-blingfire 1.0.0
livekit-plugins-assemblyai 1.2.1
livekit-plugins-google 1.2.1
livekit-plugins-noise-cancellation 0.2.5
livekit-plugins-openai 1.2.1
livekit-plugins-silero 1.2.1
livekit-plugins-turn-detector 1.2.1
livekit-protocol 1.0.4
can you share a reproducible example or the agent session configuration?
I get similar error.
It happens randomly, not always.
For details, please have a look at below images.
Here,s is the code for tts_node.
async def tts_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
# Handle streaming text
full_message_parts = []
# Define an async generator to stream the collected parts for TTS processing *and* collect them
async def stream_and_collect_generator():
async for chunk in text: # text is the original LLM output stream
full_message_parts.append(chunk)
yield chunk
# Process the stream for TTS first using the new generator
processed_tts_stream = Agent.default.tts_node(
self,
process_stream(
stream_and_collect_generator(), self.ctx, self.participant
),
model_settings,
)
# Yield from the processed TTS stream
async for frame in processed_tts_stream:
yield frame
print(full_message_parts)
Here's the list of packages:
livekit-agents==1.2.2
livekit-plugins-cartesia==1.2.2
livekit-plugins-deepgram==1.2.2
livekit-plugins-openai==1.2.2
livekit-plugins-silero==1.2.2
livekit-plugins-turn-detector==1.2.2
livekit-plugins-google==1.2.2
Let me know if you need more details. @longcw
@longcw I am using another TTS provider like Rime and Cartesan, and it's working fine. But I am still experiencing the same issue in Google TTS mentioned by @nidhi-canopas
Hello, Anyone has managed to solve it ?
what is the reason for the error :
n_task
raise APIError(f"no audio frames were pushed for text: {self._pushed_text}")
10:29:27.169 ERROR… livekit.agents Error in _tts_inference_task
Traceback (most recent call last):
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\tts\tts.py", line 625, in
anext
val = await self._event_aiter.anext()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopAsyncIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in
async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\voice\generation.py", line
290, in _tts_inference_task
pushed_duration += await _tts_node_inference(input_segment, pushed_duration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\opentelemetry\util_decorator.py", line 71,
in async_wrapper
return await func(*args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\voice\generation.py", line
248, in _tts_node_inference
async for audio_frame in tts_node:
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\voice\agent.py", line 448, in
tts_node
async for ev in stream:
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\tts\tts.py", line 628, in
anext
raise exc # noqa: B904
^^^^^^^^^
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\tts\tts.py", line 418, in
_traceable_main_task
await self._main_task()
File "C:\Users\girid\Desktop\Hitloop\livekit-gemini-agent.venv\Lib\site-packages\livekit\agents\tts\tts.py", line 463, in
_main_task
raise APIError(f"no audio frames were pushed for text: {self._pushed_text}")
livekit.agents._exceptions.APIError: no audio frames were pushed for text: Hey hello good morning! Meeru ela unnaru? Naaku emaina
Exception in thread Thread-2 (_listen_for_keys):
Traceback (most recent call last):
File "C:\Users\girid\Anaconda3\Lib\threading.py", line 1075, in _bootstrap_inner
self.run()
File "C:\Users\girid\Anaconda3\Lib\threading.py", line 1012, in run