How do i generate transcript with livekit sdk kit
# ask-ai
d
How do i generate transcript with livekit sdk kit
g
To generate transcripts using the LiveKit SDK, you can utilize the
STTSegmentsForwarder
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:
Copy code
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.
d
can it generate it in different languages?