How can I create an agent that transcribes a long ...
# ask-ai
s
How can I create an agent that transcribes a long running lecture (not a conversation), and translates it into Spanish before sending it?
t
Thanks for reaching out, Jay. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To get you set up with an agent that can transcribe and translate your lecture, could you let me know a couple of things? • Which speech-to-text (STT) provider are you thinking of using? For example, OpenAI Whisper, Groq, Amazon Transcribe, or something else? • Do you have a favorite translation service you’d like to use to turn the transcription into Spanish? Once I have those details, I’ll be able to guide you through the setup step-by-step. Sources: Transcription Applications | livekit/livekit_composite | DeepWiki | Amazon Transcribe STT integration guide | LiveKit Docs | examples/other/transcription/README.md | Transcriptions | LiveKit Docs | README.md
s
AssmeblyAI for SST and OpenAI for translation. I also want to only send full english sentences to the LLM for translation,
t
Hey there! If you want to create an agent that transcribes a long-running lecture using AssemblyAI and translates it into Spanish with OpenAI, here’s a friendly step-by-step guide to help you out: 1. Set Up AssemblyAI for Transcription • First, install the necessary plugin:
pip install "livekit-agents[assemblyai]~=1.2"
• Next, pop your AssemblyAI API key into the
.env
file like this:
ASSEMBLYAI_API_KEY=your_api_key
• Then, initialize the AssemblyAI STT provider in your agent code:
Copy code
from livekit.plugins import assemblyai
stt_provider = assemblyai.STT()
2. Set Up OpenAI for Translation • Install the OpenAI plugin by running:
pip install "livekit-agents[openai]~=1.2"
• Don’t forget to add your OpenAI API key to the
.env
file:
OPENAI_API_KEY=your_openai_api_key
• Use the OpenAI LLM in your agent code like this:
Copy code
from livekit.plugins import openai
llm_model = openai.LLM()
• To translate full English sentences, just feed them into a prompt like this:
Copy code
chat_context = llm.ChatContext().append(
    role="system",
    text="You are a translator. Translate the input text into Spanish."
)
stream = llm_model.chat(chat_ctx=chat_context, messages=[{"role": "user", "text": transcribed_text}])
3. How It All Comes Together 1. Your agent joins a LiveKit room and listens to the audio track. 2. It uses
assemblyai.STT()
to convert that live audio into text. 3. Then, it passes the transcribed text to
openai.LLM()
to get it translated. 4. Finally, the translated text gets sent back to clients using
publish_transcription()
or whatever method you prefer. If you hit any bumps or want to dive into specifics, just let me know—I’m here to help! Sources: AssemblyAI integration guide | LiveKit Docs | OpenAI STT integration guide | LiveKit Docs | server/main.py | OpenAI integration guide | LiveKit Docs
s
Can you give me code for it?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!