narrow-laptop-64001
10/29/2025, 10:58 AM@session.on("user_input_transcribed")
def on_user_input_transcribed(event: UserInputTranscribedEvent):
nonlocal last_activity_time, warned_user
logger.info(f"User input transcribed: {event.transcript[:50]}...")
last_activity_time = perf_counter()
warned_user = False # Reset warning when user speaks
This transcribes each word and logs it one by one. Is there a way to transcribe a sentence and not a word?tall-airline-16756
10/29/2025, 10:58 AMtall-airline-16756
10/29/2025, 10:59 AMSentenceTokenizer from the LiveKit library, which is designed to break text into sentence-sized chunks. It works great in both synchronous and streaming modes.
For streaming transcription, here's a friendly example using the .stream() method:
from livekit.agents.tokenize.basic import SentenceTokenizer
sentence_tokenizer = SentenceTokenizer()
sentence_stream = sentence_tokenizer.stream()
sentence_stream.push_text("Hello")
sentence_stream.push_text(" world. ")
sentence_stream.push_text("How are you?")
async for sentence in sentence_stream:
print(f"New sentence: {sentence}")
# Result: First iteration yields "Hello world.", second yields "How are you?"
sentence_stream.close()
If you're working with complete transcript segments, another helpful option is the livekit-blingfire plugin's text_to_sentences function:
from livekit.blingfire import text_to_sentences
text = "Hello world. How are you? I'm fine, thanks."
segmented_text = text_to_sentences(text)
# Returns a string with sentences separated by newlines
Please feel free to reach out if you'd like any more help or have questions while implementing this—I’m here to support you!
Sources: livekit-agents/livekit/agents/inference/stt.py | Text and transcriptions | LiveKit Docsnarrow-laptop-64001
10/29/2025, 11:02 AMtall-airline-16756
10/29/2025, 11:02 AMuser_input_transcribed event. Here’s a simple example to get you started:
@session.on("user_input_transcribed")
def on_transcript(event):
if event.is_final:
print(f"Sentence transcribed: {event.transcript}")
If you want to customize things further, there are helpful tools like the livekit-blingfire plugin that can assist with sentence segmentation. Feel free to reach out if you’d like some guidance on setting that up—I’m here to help!
Sources: livekit-plugins/livekit-plugins-speechmatics/README.md | pipeline-llm/interrupt_user.py | Text and transcriptions | LiveKit Docs