Skip to content

Instantly share code, notes, and snippets.

@rcd27
Created March 19, 2026 22:19
Show Gist options
  • Select an option

  • Save rcd27/3cc2238ed56b6eac8e71c5fdede334f3 to your computer and use it in GitHub Desktop.

Select an option

Save rcd27/3cc2238ed56b6eac8e71c5fdede334f3 to your computer and use it in GitHub Desktop.
the-only-working-whisper-typer-ubuntu
#!/bin/bash
# Voice dictation: run once to start recording, run again to stop + transcribe.
# Text goes to clipboard β€” paste with Ctrl+V wherever you want.
# Usage: bind to a hotkey in system settings
PID_FILE="/tmp/dictate.pid"
AUDIO_FILE="/tmp/dictate.wav"
API_KEY="$(cat ~/.config/openai-api-key 2>/dev/null)"
PROXY="http://localhost:8888"
if [ -f "$PID_FILE" ]; then
# Stop recording
kill "$(cat "$PID_FILE")" 2>/dev/null
rm -f "$PID_FILE"
notify-send -t 1000 "🎀" "Transcribing..."
# Send to OpenAI Whisper API
RESULT=$(curl -s --proxy "$PROXY" \
-H "Authorization: Bearer $API_KEY" \
-F "file=@${AUDIO_FILE}" \
-F "model=whisper-1" \
-F "language=ru" \
"https://api.openai.com/v1/audio/transcriptions" | jq -r '.text // empty')
rm -f "$AUDIO_FILE"
if [ -n "$RESULT" ]; then
echo -n "$RESULT" | nohup xclip -selection clipboard &>/dev/null &
notify-send -t 2000 "🎀 Ctrl+V to paste" "$RESULT"
else
notify-send -t 2000 "🎀" "Nothing recognized"
fi
else
# Start recording
parecord --format=s16le --rate=16000 --channels=1 "$AUDIO_FILE" &
echo $! > "$PID_FILE"
notify-send -t 1000 "🎀" "Recording..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment