red-needle-56026
06/28/2025, 6:18 AM*
as "asterisk"tall-airline-16756
06/28/2025, 6:19 AMtall-airline-16756
06/28/2025, 6:19 AMfilter_markdown
function designed to remove markdown formatting from text before it is processed by Text-to-Speech (TTS) systems. This function is part of the livekit.agents.voice.transcription.filters
module and can handle various markdown elements such as headers, list markers, block quotes, and formatting for bold, italic, and code blocks.
For example, you can use this function in the tts_node
method of a custom agent to ensure that markdown formatting is removed before the text is sent to the TTS engine:
async def tts_node(
self, text: AsyncIterable[str], model_settings: ModelSettings
) -> AsyncIterable[AudioFrame]:
filtered_text = filter_markdown(text)
return super().tts_node(filtered_text, model_settings)
This ensures that the TTS engine receives clean text without markdown symbols interfering with speech synthesis.
Sources: GitHub::livekit::agents | tests/test_transcription_filter.pyred-needle-56026
06/28/2025, 6:29 AMtall-airline-16756
06/28/2025, 6:29 AMnew_sentence_delay
parameter in the TTSSegmentsForwarder
class is like a magic wand for making your speech sound more conversational. Think of it as adding those natural breath moments between sentences. Here's how simple it is to use:
TTSSegmentsForwarder(
room=room,
participant=participant,
new_sentence_delay=0.4, # Default is 0.4 seconds
# other parameters...
)
By default, it adds a 0.4-second pause between sentences, which helps your text-to-speech sound way more natural and smooth. Feel free to adjust the time to what sounds best to you. Happy speaking! š Sources: livekit.agents.transcription.tts_forwarder API documentation | livekit.agents.transcription.tts_forwarder API documentationred-needle-56026
06/29/2025, 8:16 AMtall-airline-16756
06/29/2025, 8:16 AMnew_sentence_delay
parameter.
from livekit.agents.voice.transcription.forwarders import TTSSegmentsForwarder
# Example usage
forwarder = TTSSegmentsForwarder(
room=my_room_instance,
participant=my_participant_instance,
new_sentence_delay=0.5, # Introduce a 0.5-second pause between sentences
# other parameters as needed
)
# Use the forwarder in your TTS pipeline
forwarder.forward_segments()
See what's happening here? By setting new_sentence_delay
to 0.5, you're basically telling your text-to-speech to take a tiny breather between sentences. It's like adding a natural rhythm to the speech, making it sound more conversational and less robotic. Feel free to play around with the delay time to find what sounds just right for your project. Pretty neat, right? šred-needle-56026
06/29/2025, 8:18 AMtall-airline-16756
06/29/2025, 8:18 AMtall-airline-16756
06/29/2025, 8:18 AM