Docs & Howtos

Jason Kolpin Random Docs and Howto's

Setting Up A Local Whisper Translator Service (Debian Trixie)

WARNING!!! THIS REQUIRES YOU TO COMPILE SOFTWARE! IT IS UP TO YOU TO BE SURE EVERYTHIGN IS SANE! I TAKE NO REPOSNSIBILITY FOR ANY DAMAGE DONE IN YOUR TRAVELS.

Note! This will run on a Raspberry PI 4 8GB but is extremely slow when using the "small" or "medium" Whisper models. The faster your machine is (specially the GPU) the faster the translation will happen. This code could also be altered to run the larger (smarter) models on a faster machine.

REQUIRED DIRECTORY STRUCTURE


USER_HOME_DIR
          |
		  -- translator
		  |
		  -- whisper.cpp

Install required packages


:~# sudo apt install python3 python3-flask python3-flask-sqlalchemy python3-flask-login ffmpeg cmake git

Clone the whisper.cpp project and compile it.

THIS MUST BE CLONED IN THE HOME DIRECTORY OF THE USER THAT RUNS THE TRANSCRIBER


:~ # git clone https://github.com/ggerganov/whisper.cpp
:~ # cd whisper.cpp
:~/whisper.cpp # make

Download whisper models


:~/whisper.cpp # cd ~/whisper.cpp/models
:~/whisper.cpp/models # ./download-ggml-model.sh tiny
:~/whisper.cpp/models # ./download-ggml-model.sh small
:~/whisper.cpp/models # ./download-ggml-model.sh base
:~/whisper.cpp/models # ./download-ggml-model.sh medium

Upload the transcriber.zip to your home directory (ex: /home/pi) [Download Here]


:~/whisper.cpp/models # cd ~/
:~ # wget http://jasonkolpin.com/docs/dl/transcriber.zip
:~ # unzip transcriber.zip

Prepare the transcriber for first start and user generation

Enable user registration in config.py, register your user, and the IMMEDIATLY disable user registration (IMPORTANT!)


:~ # cd ~/transcriber
:~/transcriber # nano config.py

Change the following line to "True" and save the file


# --- Authentication Configuration ---
# Set to True to enable the /register route for initial user creation.
# Set to False (SECURE DEFAULT) immediately after the first user is created.
REGISTRATION_ENABLED = True # Change this to true for initial user setup. DO NOT LEAVE THIS SET TO TRUE!! YOU WILL REGRET IT!

Manually fire up the transcriber to test and save the initial user.


:~/transcriber # python3 app.py

The transcriber should start up and tell you the url to view the web interface. At this point you should be able to browse to the transciber URL with your web browser. I suggest bookmarking the url. You should be presented with login box that has an option to register an account. Choose register, fill in the form, and when finished, save and try logging in.

ONCE YOU HAVE LOGGED IN YOU MUST EDIT config.py and set REGISTRATION_ENABLED to "False".


:~ # cd ~/transcriber
:~/transcriber # nano config.py

Change the following line to "False" and save the file


# --- Authentication Configuration ---
# Set to True to enable the /register route for initial user creation.
# Set to False (SECURE DEFAULT) immediately after the first user is created.
REGISTRATION_ENABLED = False # Change this to true for initial user setup. DO NOT LEAVE THIS SET TO TRUE!! YOU WILL REGRET IT!

Manually start the transcriber and make sure it starts okay. Once it starts, I suggest browsing to it again, logging in, and testing out a file before creating a systemd service for it to run automatically.

Set up a systemd service to run the transcriber.

To run the transcriber as a service. Change the user to the user you plan to use to run the service:

create the service file:


sudo nano /etc/systemd/system/transcriber.service

Paste this to the service file (BE SURE TO CHANGE THE PATH TO THE FILES AND THE USER!!):


[Unit]
Description=Local Audio Translator
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/pi/transcriber/app.py
WorkingDirectory=/home/pi/transcriber
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Enable the service, start it, and check if it started okay:


:~# sudo systemctl enable transcriber
:~# sudo systemctl start transcriber
:~# sudo systemctl status transcriber