shy-room-34710
09/01/2025, 3:15 PMtall-airline-16756
09/01/2025, 3:15 PMtall-airline-16756
09/01/2025, 3:17 PMshy-room-34710
09/01/2025, 3:18 PMtall-airline-16756
09/01/2025, 3:19 PMpip 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: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:from livekit.plugins import openai
llm_model = openai.LLM()
• To translate full English sentences, just feed them into a prompt like this: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 Docsshy-room-34710
09/01/2025, 3:21 PMtall-airline-16756
09/01/2025, 3:21 PM