Leon Anavi
IT Tips && Tricks

Mobile & Embedded

Created: 31.08.2024 16:58 Last Modified: 01.09.2024 06:16 Views: 503
Keywords: ANAVI Dev Mic, Open AI Whisper, Python, Raspberry Pi, speech, speech-to-text

Offline Speech-to-Text on Raspberry Pi 5 with ANAVI Dev Mic and Python

In the world of speech recognition, online services like Google Speech-to-Text or Amazon Transcribe are popular choices, but what if you need offline functionality? In my latest video, I demonstrate offline speech-to-text (STT) recognition using a Raspberry Pi 5. This guide will walk you through setting up a Python3 environment on the Raspberry Pi OS, using an open-source USB-C microphone that I designed in KiCad, the ANAVI Dev Mic, and leveraging the power of the SpeechRecognition library and OpenAI's Whisper ASR system.

The process is straightforward and requires no internet connection for speech recognition, making it perfect for privacy-conscious projects or setups where connectivity is an issue.

What You'll Need

In the video, we provide two live demonstrations of converting spoken English into text, showcasing the effectiveness of the setup. The full source code is available on GitHub, allowing you to replicate the process or tweak it to suit your specific needs.

Step-by-Step Setup

If you have a Raspberry Pi 5 and ANAVI Dev Mic ready to go, here is how you can set up and run the speech-to-text script:

  1. Launch Raspberry Pi OS and open a terminal.

  2. Create a Python3 virtual environment:

    python -m venv test
    cd test
    source bin/activate
  3. Update your system and install necessary dependencies:

    sudo apt update
    sudo apt install portaudio19-dev
  4. Install the required Python libraries:

    pip install SpeechRecognition pyaudio openai-whisper
  5. Download the source code from GitHub:

    git clone https://github.com/AnaviTechnology/anavi-examples.git
  6. Run the script:

    cd anavi-examples/speech-to-text
    python3 stt.py
  7. Follow the onscreen instructions to start speaking when the script is listening.

The script is tailored for the ANAVI Dev Mic and will automatically select it from the available microphones. If the ANAVI Dev Mic isn't found, an error will be reported. Using a different microphone? You'll need to tweak the script to recognize your device.

Useful Links

For more detailed information, source code, and additional resources, check out the following links:

This setup provides a robust offline speech recognition solution on the Raspberry Pi, perfect for DIY enthusiasts, developers, and hobbyists alike. Whether you're working on a home automation project or just experimenting with speech recognition, this guide will help you get started quickly and efficiently. Happy coding!



  Home | About | Contact | Disclaimer | Sitemap © 2009-2022 Leon Anavi. All rights reserved.