Skip to main content
Seb Duerr
January 23, 2026
Open in Github
This cookbook demonstrates how to build a realtime voice translation agent that:
  • Captures audio from your browser microphone
  • Transcribes speech using OpenAI Whisper
  • Translates text using Cerebras LLM at ~80-150ms latency
  • Speaks the translation back using OpenAI TTS

What You’ll Learn

  1. LiveKit Agents Framework - Building voice AI agents with WebRTC
  2. Cerebras Integration - Using Cerebras LLMs via OpenAI-compatible API
  3. Voice Pipeline - Connecting STT → LLM → TTS for realtime conversation
  4. Jupyter Integration - Running voice agents inline with microphone widgets

Setup

Install Dependencies

Load API Keys

Get API keys to get started: For detailed LiveKit setup, see our LiveKit Integration Guide.

Part 1: Translation Prompt

The translation prompt instructs the LLM to act as a real-time translator. It’s designed to be concise and focused on accurate translation without commentary.

Why This Prompt Works

  • Single responsibility: The LLM only translates, no explanations
  • Tone preservation: Maintains the speaker’s intent
  • Edge case handling: Handles same-language input gracefully
  • Minimal latency: Short responses = faster TTS

Part 2: Configure the Voice Agent

LiveKit Agents provides a high-level API for building voice AI applications. We configure:
  • VAD (Voice Activity Detection): Silero VAD detects when the user is speaking
  • STT (Speech-to-Text): OpenAI Whisper transcribes audio
  • LLM: Cerebras for ultra-fast translation
  • TTS (Text-to-Speech): OpenAI TTS speaks the translation

Part 3: Create the Agent Entrypoint

The entrypoint function is called when a user joins the LiveKit room. It sets up the voice pipeline and starts the translation session.

Key Components Explained

Part 4: Run the Agent in Jupyter

LiveKit provides a Jupyter integration that displays an inline microphone widget. This allows you to test the agent directly in your notebook.

How It Works

  1. Widget appears: An embedded audio widget displays below the cell
  2. Microphone access: Browser requests microphone permission
  3. Speak: Your voice is captured and sent to the agent
  4. Translation: Cerebras translates in ~80-150ms
  5. Response: You hear the translation spoken back
Important: Run this notebook in a browser (not VS Code or other IDEs) for proper microphone access via the LiveKit widget.

Part 5: Supported Languages

The translation agent supports any language that Llama-3.1-8B can translate. Common options: To change the target language, modify TARGET_LANGUAGE and re-run the agent cells.

Performance

Cerebras provides ~450 tokens/sec inference speed, enabling natural conversational translation with minimal perceived delay.

Summary

What We Built

A realtime voice translation agent with:
  • LiveKit Agents for WebRTC voice handling
  • Cerebras Llama-3.1-8B for ultra-fast translation
  • OpenAI Whisper for accurate speech recognition
  • OpenAI TTS for natural speech synthesis
  • Jupyter integration for easy testing

Key Patterns

  1. OpenAI-Compatible API: Cerebras works with any OpenAI-compatible client
  2. Voice Pipeline: VAD → STT → LLM → TTS for seamless conversation
  3. Minimal Prompts: Short, focused prompts reduce latency
  4. Browser Integration: Jupyter widgets enable microphone access

Next Steps

  • Add language detection for automatic source language identification
  • Implement conversation history for context-aware translation
  • Add support for multiple simultaneous languages
  • Deploy as a standalone web application

Resources

Acknowledgements

Thank you to the Cerebras team—Ryan, Ryann, Zhenwei, and Neeraj—for their support and feedback during the development of this cookbook.