freezing-jelly-85538
10/17/2025, 3:27 AMtall-airline-16756
10/17/2025, 3:27 AMtall-airline-16756
10/17/2025, 3:29 AMstt.SpeechEventType.PREFLIGHT_TRANSCRIPT event is a helpful feature that kicks in when the STT system feels confident enough that a part of the speech is stable and ready to be processed, even before the user finishes speaking. Usually, the LiveKit framework takes care of this automatically, but you also have the option to create your own custom handling by using the RecognitionHooks protocol.
Here’s a friendly example to show you how you might handle this event:
from livekit.agents.voice.audio_recognition import RecognitionHooks
class CustomRecognitionHooks(RecognitionHooks):
def on_interim_transcript(self, ev, *, speaking=None):
if ev.type == stt.SpeechEventType.PREFLIGHT_TRANSCRIPT:
transcript = ev.alternatives[0].text
confidence = ev.alternatives[0].confidence
print(f"Preflight transcript: {transcript} (confidence: {confidence})")
# Add custom logic here, e.g., logging or validation
super().on_interim_transcript(ev, speaking=speaking)
This way, you can easily process the preflight transcript, decide what to do based on confidence levels, or even connect it with other systems you’re using. If you’d like, I’m here to help with any questions or to guide you through the implementation!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/stt.py | Agent speech and audio | LiveKit Docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki