delightful-apartment-77345
02/26/2025, 1:26 AMgray-monkey-83525
02/26/2025, 1:26 AMSTTSegmentsForwarder
class for real-time transcription of user speech. This class forwards speech-to-text (STT) transcriptions to users, which can be useful for client-side rendering. You can listen to transcription events such as user_speech_committed
and agent_speech_committed
to capture the final transcriptions of both user and agent speech.
For frontend integration, you can use the LiveKit SDKs to receive transcription events. For example, in a React application, you can listen to RoomEvent.TranscriptionReceived
to collect TranscriptionSegment
objects and update your UI accordingly. Here's a basic example in React:
import { useEffect, useState } from 'react';
import { RoomEvent } from '@livekit/components-react';
const room = useMaybeRoomContext();
const [transcriptions, setTranscriptions] = useState({});
useEffect(() => {
if (!room) return;
const updateTranscriptions = (segments) => {
setTranscriptions((prev) => {
const newTranscriptions = { ...prev };
segments.forEach((segment) => {
newTranscriptions[segment.id] = segment;
});
return newTranscriptions;
});
};
room.on(RoomEvent.TranscriptionReceived, updateTranscriptions);
return () => {
room.off(RoomEvent.TranscriptionReceived, updateTranscriptions);
};
}, [room]);
Would you like more detailed guidance on implementing this in your specific setup?
Sources:
- Transcriptions | LiveKit Docs
- useTrackTranscription | React Components | LiveKit Docs 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.delightful-apartment-77345
02/26/2025, 1:41 AM