Build an offline voice translator on a Raspberry Pi 5

Set up a Raspberry Pi 5 to hear speech in one language and speak it back in another, with no internet needed after setup.

Julian ReedElectronics restorer and tinkerer
3 min read

A Raspberry Pi 5 on a workbench wired to a USB stick microphone and a small USB speaker.
Photo by Pixabay / Pexels
Skill
Beginner with the command line
Tools
Keyboard, display, terminal
Model size
2.6 GB
Needs
Raspberry Pi 5 with 8 GB RAM

You hold down a key, speak in one language, and a few seconds later the Pi says it back in another. This build turns a Raspberry Pi 5 into a stand-alone translator that needs no cloud service and no internet once it is installed. Plan on a few hours, much of it waiting for packages and the model to download.

Before you start, know that it is not instant. Everything runs on the Pi's CPU, so there is a noticeable pause between when you finish speaking and when the translation plays.

How the translator works

Three AI pieces run in a chain.

  • Speech-to-text with Moonshine. Speech recognition models built for edge devices, with a separate trained model for each language. They run only on the CPU and don't use a GPU or any attached AI accelerator board.
  • Translation with Gemma 3n E2B. A general-purpose open-weight language model with an Effective 2 Billion parameters, packaged as a 2.6 GB file. It is not a dedicated translation engine. It gets a specific prompt asking it to act as a translator and returns the result as a JSON string. A lightweight local LLM server loads it and handles requests. It needs internet only on its first run.
  • Text-to-speech with Moonshine Voice. It converts the translated text to phonemes using language-specific rules and outputs raw audio for the speaker.

In use, you hold the Z key while a React web page records through the USB microphone. When you release the key, the audio goes to a Python backend over HTTP. The backend transcribes it, sends the text to Gemma, turns the translation into speech, and sends both text and audio back to the page, which shows the words and plays the sound.

What you will need

  • Raspberry Pi 5 with 8 GB of RAM
  • A USB microphone (a stick-style one works)
  • A USB or Bluetooth speaker. The Pi 5 has no audio output jack.
  • An HDMI display and a USB keyboard
  • A microSD card, 32 GB or larger, with 64-bit Raspberry Pi OS (Bookworm) installed
  • The official Raspberry Pi USB-C power supply
  • An internet connection for setup only

The project's repository includes a 3D-printed case design built around specific hardware. You can skip it and build on an open bench, or adapt an existing Pi case.

Step by step

  1. Update and install packages. Open a terminal and run the commands below. The list is long, so give it a few minutes.

    sudo apt update && sudo apt full-upgrade -y
    sudo apt install -y git python3-venv python3-pip ffmpeg libasound2-dev pulseaudio-utils alsa-utils lsof netcat-openbsd nodejs npm
    
  2. Switch from Wayland to X11. Recent Raspberry Pi OS uses Wayland by default, but this project needs X11. Switch, then reboot.

    sudo raspi-config nonint do_wayland W1
    sudo reboot
    
  3. List your audio devices. Check that the Pi can see the microphone and speaker.

    arecord -l
    aplay -l
    

    An HDMI monitor often appears as an audio output too, so expect more than one output in the list.

  4. Record a test clip. Start recording, say something, then press Ctrl+C to stop.

    pw-record test.wav
    
  5. Play it back. If you hear your voice, both devices work.

    pw-play test.wav
    
  6. Delete the test file.

    rm test.wav
    
  7. Clone the project and make the scripts runnable.

    cd ~
    git clone https://github.com/google-gemma/gemma-translator.git
    cd gemma-translator
    chmod +x setup.sh download_model.sh start.sh deploy-pi.sh
    
  8. Deploy with the included scripts. The repository provides setup.sh, download_model.sh, start.sh and deploy-pi.sh. Follow the repository's own instructions for running them. Leave the internet connected until Gemma has downloaded and run once.

Check setup.sh before deploying

As of August 2026, setup.sh passes a --require-hashes flag to pip, which can cause trouble during install. Check the repository's current notes and open issues for this before you run the deploy scripts.

Using it offline

Once the translator has run once, you can unplug the Ethernet cable or turn off Wi-Fi, and it keeps working anywhere you can plug it in. Hold Z, speak clearly, release, and wait for the reply.

Set expectations for the pause

The delay comes from three models running one after another on the CPU. Speak a sentence, release the key, and give it a few seconds before you decide something is wrong.

Filed underTechnologyElectronicsWeekendLearning
Portrait of Julian Reed

Written by

Julian Reed

A vintage electronics restorer and hobbyist tinkerer who walks readers through soldering basics, retro console repairs, and fun weekend gadget builds.

Previous articleWhitewash wood furniture so the grain still showsNext articleWarm up for at least 6 minutes before you exercise

You may also like

0 comments

    Join the conversation

    Be kind and be specific. Comments are moderated before they appear.