Hi, I am building a app that adds live transcripti...
# agents
b
Hi, I am building a app that adds live transcription to a LiveKit room using LiveKit voice agent
voice.AgentSession
but I am struggling to figure out how to make it work for multiple participants. The docs seem to indicate the AgentSession should work out of the box for multiple participants, but I am not seeing that. The transcription works just for the first user who is joining the room and ends when that user leaves the room. Does anyone have experience with this?
Here is a simplified version of the code:
Copy code
export default defineAgent({
  prewarm: async (proc) => {
    console.log('Agent prewarming...');
  },

  entry: async (ctx: JobContext) => {
    console.log(`Agent connected to room: ${ctx.room.name}`);

    await ctx.connect();

    // Create Deepgram STT instance
    const stt = new deepgram.STT({
      apiKey: process.env.DEEPGRAM_API_KEY,
      model: 'nova-2-meeting',
      language: 'en',
      smartFormat: true,
      interimResults: false,
    });

    // Create a voice agent session
    const session = new voice.AgentSession({
      stt: stt,
    });

    session.on(voice.AgentSessionEventTypes.UserInputTranscribed, (event) => {
      console.log(`User input transcribed: ${event.transcript}`);
    });
    // Start the session
    await session.start({
      agent: new voice.Agent({
        instructions:
          'You are a transcription agent. You will transcribe the audio from the participants into text.',
      }),
      room: ctx.room,
      outputOptions: {
        transcriptionEnabled: true, // Forward transcriptions to clients
        audioEnabled: false, // Agent won't speak back
      },
    });

    console.log('Agent is ready and transcribing...');
  },
});