chilly-nest-87883
07/27/2025, 10:48 PMtall-airline-16756
07/27/2025, 10:48 PMtall-airline-16756
07/27/2025, 10:49 PMinterim_results=True
and smart_format=True
, you need to listen for INTERIM_TRANSCRIPT
events from the STT stream. Here’s how you can implement this:
Python Implementation:
from livekit.plugins.deepgram import STT
from livekit.agents.stt import SpeechEventType, SpeechEvent
from typing import AsyncIterable
# Configure Deepgram STT with interim results and smart formatting
stt = STT(
interim_results=True,
smart_format=True,
# other options...
)
# Create a stream and process events
stt_stream = stt.stream()
async def process_speech_events(stream: AsyncIterable[SpeechEvent]):
async for event in stream:
if event.type == SpeechEventType.INTERIM_TRANSCRIPT:
# Handle interim transcript events
interim_text = event.alternatives[0].text
print(f"Interim: {interim_text}")
elif event.type == SpeechEventType.FINAL_TRANSCRIPT:
# Handle final transcript events
final_text = event.alternatives[0].text
print(f"Final: {final_text}")
JavaScript Implementation:
import { STT } from '@livekit/agents-plugin-deepgram';
import { SpeechEventType } from '@livekit/agents';
// Configure Deepgram STT
const stt = new STT({
interimResults: true,
smartFormat: true,
// other options...
});
const stream = stt.stream();
// Process events from the stream
for await (const event of stream) {
switch (event.type) {
case SpeechEventType.INTERIM_TRANSCRIPT:
// Handle interim transcript
const interimText = event.alternatives[0].text;
console.log(`Interim: ${interimText}`);
break;
case SpeechEventType.FINAL_TRANSCRIPT:
// Handle final transcript
const finalText = event.alternatives[0].text;
console.log(`Final: ${finalText}`);
break;
}
}
Key Points:
• Ensure that interim_results
and smart_format
are set to true
in your Deepgram STT configuration.
• Listen for INTERIM_TRANSCRIPT
events from the STT stream to handle interim transcripts.
• Use the SpeechEventType
to differentiate between interim and final transcript events.
This approach should allow your handlers to receive and process interim transcript events correctly.
Sources: livekit-plugins/livekit-plugins-speechmatics/livekit/plugins/speechmatics/s... | plugins/deepgram/src/stt.ts | SpeechEventType | LiveKit Agents | Deepgram integration guide | LiveKit Docs