Tuesday, July 15, 2025

offline transcription/dictation on raspberry pi with vosk

I installed vosk in a venv inside a directory for nerd-dictation which is another script that works great if you want to run vosk in the background and output it into vim. Heres my transcribe.sh for running vosk-transcriber on audio files


#!/bin/bash
# Activate the virtual environment
source "$HOME/.applications/nerd-dictation/venv/bin/activate"
# Check if a file argument was provided
if [[ -z "$1" ]]; then
    echo "Usage: $0 "
    exit 1
fi
AUDIO_FILE="$1"
# Check that the file exists
if [[ ! -f "$AUDIO_FILE" ]]; then
    echo "Error: File '$AUDIO_FILE' not found."
    exit 1
fi
# Run transcription and output to file
vosk-transcriber -i "$AUDIO_FILE" -o test.txt
# Print the output to the terminal
echo "Transcription output:"
cat test.txt

heres my vosk.sh for running nerd-dictation


#!/bin/bash
# Absolute path to the project
BASEDIR="$HOME/.applications/nerd-dictation"
# Activate the virtual environment
source "$BASEDIR/venv/bin/activate"
# Run nerd-dictation with the 'begin' command
"$BASEDIR/nerd-dictation" begin

No comments:

Post a Comment