This is a demo of real time speech to text with OpenAI's Whisper model. It works by constantly recording audio in a thread and concatenating the raw bytes over multiple recordings.
Create and activate a virtual environment, then install dependencies:
python3 -m venv whisper_venv
source whisper_venv/bin/activate
pip install -r requirements.txtWhisper also requires the command-line tool ffmpeg to be installed on your system, which is available from most package managers:
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpegFor more information on Whisper please see https://github.com/openai/whisper
The web UI serves at http://127.0.0.1:5000 (also http://localhost:5000) by default. There are two ways to run this application:
To run the application with a web-based user interface:
python3 web_output.pyCommon web UI commands with explicit models and microphone backends:
python3 web_output.py --model tiny --default_microphone pipewire
python3 web_output.py --model base --default_microphone pipewire
python3 web_output.py --model small --default_microphone pipewire
python3 web_output.py --model medium --default_microphone pipewire
python3 web_output.py --model large --default_microphone pipewire
python3 web_output.py --model large-v3-turbo --default_microphone pipewireGemini API key variants:
python3 web_output.py --model large-v3-turbo --default_microphone pipewire --gemini_api_key YOUR_GEMINI_API_KEY
python3 web_output.py --model large-v3-turbo --default_microphone pipewire --gemini_api_key "$(cat .env | grep GEMINI_API_KEY | cut -d= -f2)"
python3 web_output.py --model large-v3-turbo --default_microphone pulse --gemini_api_key "$(cat .env | grep GEMINI_API_KEY | cut -d= -f2)"OpenRouter example:
python web_output.py --model large-v3-turbo --default_microphone pipewire --openrouter_api_key "$(cat .env | grep OPENROUTER_API_KEY | cut -d= -f2)"