hi, is there anyway to save the stt from deepgram ...
# ask-ai
v
hi, is there anyway to save the stt from deepgram in a local list in python.
t
Thanks for reaching out, Adithya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! You can easily save the speech-to-text (STT) results from Deepgram into a local list using Python. Here’s a simple way to do it: 1. First, set up the Deepgram STT plugin with your API key. 2. Next, create an
AgentSession
to manage those transcription events. 3. Then, add an event handler for
user_input_transcribed
events to catch and save the transcription results into a list. 4. Finally, append the final transcription results to a Python list. Here’s a quick example to get you started:
Copy code
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import deepgram

async def entrypoint(ctx):
    session = AgentSession()
    transcriptions_list = []

    @session.on("user_input_transcribed")
    def on_transcript(transcript):
        if transcript.is_final:
            transcriptions_list.append(transcript.transcript)

    await session.start(
        agent=Agent(
            instructions="Transcribe user speech to text.",
            stt=deepgram.STT()
        ),
        room=ctx.room
    )
With this, all the final transcriptions will be saved in the
transcriptions_list
, ready for you to use however you like. If you want me to walk you through any part or need more help, just let me know—I’m here for you!