This repository has no description
0

Configure Feed

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

tools: add mic-to-text

+43
+15
tools/mic-to-text/flake-module.nix
··· 1 + { ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + packages.mic-to-text = pkgs.writeShellApplication { 7 + name = "mic-to-text"; 8 + runtimeInputs = [ 9 + pkgs.sox 10 + pkgs.whisper-cpp 11 + ]; 12 + text = builtins.readFile ./mic-to-text.sh; 13 + }; 14 + }; 15 + }
+28
tools/mic-to-text/mic-to-text.sh
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + 4 + # Default recording duration in seconds 5 + DURATION=${1:-5} 6 + 7 + # Temporary file for audio recording 8 + TEMP_AUDIO=$(mktemp /tmp/mic-to-text-XXXXXX.wav) 9 + trap 'rm -f "$TEMP_AUDIO"' EXIT 10 + 11 + echo "Recording for $DURATION seconds... (press Ctrl+C to stop early)" >&2 12 + 13 + # Record audio from default microphone 14 + # -r 16000: sample rate 16kHz (optimal for speech recognition) 15 + # -c 1: mono channel 16 + # -b 16: 16-bit audio 17 + rec -q -r 16000 -c 1 -b 16 "$TEMP_AUDIO" trim 0 "$DURATION" || true 18 + 19 + if [ ! -s "$TEMP_AUDIO" ]; then 20 + echo "Error: No audio recorded" >&2 21 + exit 1 22 + fi 23 + 24 + echo "Transcribing locally..." >&2 25 + 26 + # 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