acoustic-lizard-86122
02/27/2025, 8:12 PMgray-monkey-83525
02/27/2025, 8:12 PMbefore_tts_cb
callback to filter out unwanted text before it is sent to the text-to-speech system. This callback allows you to modify or strip out specific parts of the text that you do not want to be spoken aloud.
According to LiveKit documentation, you can define a before_tts_cb
function to process the text before it is synthesized. This function can be used to remove or alter any tool call information from the text.
Would you like more details on how to implement this?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.acoustic-lizard-86122
02/27/2025, 8:12 PMgray-monkey-83525
02/27/2025, 8:12 PMbefore_tts_cb
callback to filter out tool call details from the text before it is sent to the text-to-speech system:
from livekit.agents.pipeline import VoicePipelineAgent
from livekit.agents import llm
def before_tts_cb(assistant: VoicePipelineAgent, text: str | AsyncIterable[str]):
if isinstance(text, str):
# Remove tool call details from the text
return text.replace("tool_call_details", "")
else:
async def process_stream():
async for chunk in text:
# Remove tool call details from each chunk
yield chunk.replace("tool_call_details", "")
return process_stream()
# Initialize the VoicePipelineAgent with the before_tts_cb
agent = VoicePipelineAgent(
vad=silero.VAD.load(),
stt=deepgram.STT(),
llm=openai.LLM(),
tts=cartesia.TTS(),
before_tts_cb=before_tts_cb
)
# Start the agent for a particular room and participant
agent.start(room, participant)
In this example, the before_tts_cb
function checks if the text is a string or an AsyncIterable
. It then removes any occurrences of "tool_call_details" from the text. You can replace "tool_call_details" with the specific text or pattern you want to filter out.
Would you like more details on this implementation?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.acoustic-lizard-86122
02/27/2025, 8:37 PMgray-monkey-83525
02/27/2025, 8:37 PMAPIConnectionError
occurred during the _stream_synthesis_task
in the LiveKit pipeline. This error typically arises when there is a connection issue with the API service, in this case, likely related to OpenAI. The traceback shows that the error was raised in the _run
method of the OpenAI LLM plugin, suggesting a failure to establish or maintain a connection to the OpenAI service.
To resolve this, you should check your network connection, ensure that your API keys are correct, and verify that the OpenAI service is operational. If the issue persists, consider implementing retry logic to handle transient connection errors.
Would you like more details on troubleshooting this error?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1732345136.594869
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1727414645.070779 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.