agents icon indicating copy to clipboard operation
agents copied to clipboard

Crash while using- before_tts_cb

Open Test-isom opened this issue 1 year ago • 2 comments

{"message": "Error in _str_synthesis_task\nTraceback (most recent call last):\n File "/root/pythonenv/enve/lib/python3.10/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n File "/root/pythonenv/enve/lib/python3.10/site-packages/livekit/agents/voice_assistant/agent_output.py", line 195, in _str_synthesis_task\n handle.tts_forwarder.push_text(transcript)\n File "/root/pythonenv/enve/lib/python3.10/site-packages/livekit/agents/transcription/tts_forwarder.py", line 200, in push_text\n self._text_data.pushed_text += text\nTypeError: can only concatenate str (not "async_generator") to str", "level": "ERROR", "pid": 772990, "job_id": "AJ_owPeUnBxdvK3", "timestamp": "2024-09-09T10:18:21.988046+00:00"}

Test-isom avatar Sep 09 '24 10:09 Test-isom

Can you share what your before_tts_cb is doing?

davidzhao avatar Sep 09 '24 15:09 davidzhao

sure, not sure if iam doing something wrong, aim was to replace asterisk(currently i control it via prompt) before passing them to TTS,

initially it was this- if isinstance(text, AsyncIterable): async def process_async_text(): async for chunk in text: yield chunk.replace('*', '')

        return process_async_text()

    return text.replace('*', '')

Later i tried it with-

return tokenize.utils.replace_words(text=text, replacements={"*": ""})

Took reference from this-

https://github.com/livekit/agents/blob/main/examples/voice-assistant/custom_pronunciation.py

Test-isom avatar Sep 10 '24 04:09 Test-isom

Did you resolve @Test-isom ?

sinhpn92 avatar Mar 29 '25 03:03 sinhpn92