aboutsummaryrefslogtreecommitdiff
path: root/scripts/dictate-toggle.sh
blob: d5248abd58d2fd2b4e68bed6cb0a9c3010d152e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
# Toggle nerd-dictation (VOSK live dictation, types into focused window).
VENV_PY=~/.virtualenvs/dictate/bin/python
ND=~/.local/share/nerd-dictation/nerd-dictation
NOTIFFILE="/tmp/vosk-dictate.notif_id"

if pgrep -f "nerd-dictation begin" >/dev/null; then
    "$VENV_PY" "$ND" end
    NID=""
    [ -f "$NOTIFFILE" ] && NID=$(cat "$NOTIFFILE")
    if [ -n "$NID" ]; then
        notify-send -r "$NID" -t 1000 "Dictation" "Stopped"
    else
        notify-send -t 1000 "Dictation" "Stopped"
    fi
    rm -f "$NOTIFFILE"
else
    NID=$(notify-send -p -t 0 -u low "Dictation" "Listening...")
    echo "$NID" > "$NOTIFFILE"
    "$VENV_PY" "$ND" begin --full-sentence &
fi