This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.mic-to-text: autodownload model

+17 -2
+1
tools/mic-to-text/flake-module.nix
··· 8 8 runtimeInputs = [ 9 9 pkgs.sox 10 10 pkgs.whisper-cpp 11 + pkgs.curl 11 12 ]; 12 13 text = builtins.readFile ./mic-to-text.sh; 13 14 };
+16 -2
tools/mic-to-text/mic-to-text.sh
··· 4 4 # Default recording duration in seconds 5 5 DURATION=${1:-5} 6 6 7 + # Model cache directory 8 + MODEL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/whisper-models" 9 + mkdir -p "$MODEL_DIR" 10 + 11 + # Default model 12 + MODEL_NAME="${WHISPER_MODEL:-base.en}" 13 + MODEL_FILE="$MODEL_DIR/ggml-$MODEL_NAME.bin" 14 + 15 + # Download model if not present 16 + if [ ! -f "$MODEL_FILE" ]; then 17 + echo "Downloading $MODEL_NAME model (first run only)..." >&2 18 + MODEL_URL="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-$MODEL_NAME.bin" 19 + curl -L -o "$MODEL_FILE.tmp" "$MODEL_URL" && mv "$MODEL_FILE.tmp" "$MODEL_FILE" 20 + fi 21 + 7 22 # Temporary file for audio recording 8 23 TEMP_AUDIO=$(mktemp /tmp/mic-to-text-XXXXXX.wav) 9 24 trap 'rm -f "$TEMP_AUDIO"' EXIT ··· 24 39 echo "Transcribing locally..." >&2 25 40 26 41 # Transcribe using whisper.cpp (runs locally, no API calls) 27 - # Uses the base model by default, you can override with WHISPER_MODEL env var 28 - whisper-cpp -m "${WHISPER_MODEL:-base.en}" -f "$TEMP_AUDIO" --no-timestamps --output-txt 42 + whisper-cli -m "$MODEL_FILE" -f "$TEMP_AUDIO" -np