Notebooks
C
Cerebras
Realtime Voice Translation

Realtime Voice Translation

agentscerebras-inference-cookbook

Realtime Voice Translation with Cerebras AI + LiveKit

Experience ultra-fast realtime voice translation powered by Cerebras AI's inference and LiveKit's voice infrastructure. Translate conversations to any language in real-time with sub-second latency.

Prerequisites

You'll need three API keys:

  1. Cerebras API Key - Get yours at https://cloud.cerebras.ai
  2. OpenAI API Key - For speech-to-text (Whisper) and text-to-speech. Get it at https://platform.openai.com
  3. LiveKit Credentials - For WebRTC audio streaming

Getting LiveKit Credentials

Follow the complete setup guide at: https://inference-docs.cerebras.ai/integrations/livekit

Quick steps:

  1. Sign up at LiveKit Cloud
  2. Create a new project
  3. Go to Settings → Keys and generate an API key pair
  4. Copy your:
    • LIVEKIT_URL (starts with wss://)
    • LIVEKIT_API_KEY
    • LIVEKIT_API_SECRET

Running the Translation Agent - Start Jupyter Notebook

Start a new terminal and run the following commands:

# Install Jupyter
pip3 install jupyter

Launch Jupyter with the correct Python kernel:

# Register the kernel
python3 -m ipykernel install --user --name=translation-agent --display-name="Python 3.12 (translation-agent)"

# Start Jupyter
jupyter notebook translation_agent.ipynb

Important: When you open the notebook, make sure to select the "Python 3.12 (translation-agent)" kernel from the kernel menu (top right).

Why Jupyter in a Browser?

Running Jupyter in a browser (not VS Code or other IDEs) ensures proper microphone access via the LiveKit widget. The browser's native WebRTC support provides the best experience for realtime voice interaction.

1. Install Dependencies

Run this cell to install the necessary packages (uncomment if needed).

[ ]

2. Setup & Credentials

Set your API keys here. You can also use a .env file in the same directory.

[ ]
[ ]

4. Run the Agent

Run this cell to start the agent. It will display an embedded microphone widget.

How it works:

  1. An embedded audio widget appears below (microphone access is requested automatically)
  2. Click "Allow" when your browser asks for microphone permission
  3. Speak into your microphone - the agent will translate and respond
  4. To stop: interrupt this cell (Kernel → Interrupt) or restart the kernel

Note: This cell blocks until you stop it. The agent runs continuously while this cell executes.

5. Change Target Language (Optional)

To translate to a different language, change TARGET_LANGUAGE in cell 3 and re-run cells 3 and 4.

Supported languages:

  • English
  • Spanish (Español)
  • German (Deutsch)
  • French (Français)
  • Italian (Italiano)
  • Portuguese (Português)
  • Japanese (日本語)
  • Chinese (中文)
[ ]