Records computer or microphone audio in real time and translates it to Brazilian Portuguese using OpenAI Whisper and GPT-4o mini.
- Audio is captured from the selected input device in 30-second chunks
- Silent chunks are skipped automatically
- Each chunk is transcribed by Whisper (language-agnostic)
- The transcription is translated to pt-BR by GPT-4o mini
- Python 3.13+
- uv
- An OpenAI API key
git clone <repo>
cd live-translator
uv syncCreate a .env file in the project root:
OPENAI_API_KEY=sk-...
To translate audio playing on your computer (not just your microphone), you need a loopback device.
- Install BlackHole 2ch (free)
- Open Audio MIDI Setup (Spotlight → "Audio MIDI Setup")
- Click + → Create Multi-Output Device
- Check both BlackHole 2ch and your speakers/headphones
- In System Preferences → Sound → Output, select the new Multi-Output Device
Audio will now play through your speakers and be routed into BlackHole simultaneously.
Note: volume keys stop working with a Multi-Output Device. To fix it, check "Use this device for sound output" on the speakers entry inside the Multi-Output Device in Audio MIDI Setup.
# List available input devices
uv run live-translator --list-devices
# Translate from BlackHole (computer audio)
uv run live-translator --device-name blackhole
# Or select by device index
uv run live-translator --device 3
# Adjust chunk size (default: 30s)
uv run live-translator --device-name blackhole --chunk 10| Flag | Short | Default | Description |
|---|---|---|---|
--list-devices |
-l |
— | List available input devices and exit |
--device |
-d |
system default | Input device index |
--device-name |
-n |
— | Select device by name substring (e.g. blackhole) |
--chunk |
-c |
30 |
Audio buffer length in seconds |
--silence-threshold |
-s |
0.005 |
RMS level below which chunks are skipped |