feat: voice to text
This commit is contained in:
parent
3b589f54ce
commit
aea9d07ae9
2 changed files with 9 additions and 8 deletions
|
|
@ -43,6 +43,8 @@ return {
|
||||||
ft('sh,bash'):lint('shellcheck')
|
ft('sh,bash'):lint('shellcheck')
|
||||||
ft('zsh'):lint('zsh')
|
ft('zsh'):lint('zsh')
|
||||||
|
|
||||||
|
ft('html'):fmt('prettierd')
|
||||||
|
|
||||||
ft('proto'):fmt('buf'):lint('buf')
|
ft('proto'):fmt('buf'):lint('buf')
|
||||||
ft('dockerfile'):lint('hadolint')
|
ft('dockerfile'):lint('hadolint')
|
||||||
ft('tex'):fmt('latexindent')
|
ft('tex'):fmt('latexindent')
|
||||||
|
|
|
||||||
15
scripts/ctl
15
scripts/ctl
|
|
@ -548,33 +548,32 @@ dictate)
|
||||||
rm -f "$dpid"
|
rm -f "$dpid"
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
if [ ! -s "$daudio" ]; then
|
if [ ! -s "$daudio" ]; then
|
||||||
notify-send -a ctl "no audio"
|
notify-send -a ctl -t 1250 "no audio"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
notify-send -a ctl "transcribing..."
|
notify-send -a ctl -t 1250 "transcribing..."
|
||||||
text=$(whisper-cli \
|
text=$(whisper-cli \
|
||||||
--model "$dmodel_file" \
|
--model "$dmodel_file" \
|
||||||
--language "${DICTATE_LANG:-en}" \
|
--language "${DICTATE_LANG:-en}" \
|
||||||
--no-prints --no-timestamps \
|
--no-prints --no-timestamps \
|
||||||
"$daudio" 2>/dev/null)
|
"$daudio" 2>/dev/null | tr '\n' ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -s ' ')
|
||||||
rm -f "$daudio"
|
rm -f "$daudio"
|
||||||
text=$(printf '%s' "$text" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -s ' ')
|
|
||||||
if [ -z "$text" ]; then
|
if [ -z "$text" ]; then
|
||||||
notify-send -a ctl "no speech detected"
|
notify-send -a ctl -t 1250 "no speech detected"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf '%s' "$text" | wl-copy
|
printf '%s' "$text" | wl-copy
|
||||||
notify-send -a ctl "$text"
|
notify-send -a ctl -t 1250 "$text"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$dmodel_file" ]; then
|
if [ ! -f "$dmodel_file" ]; then
|
||||||
notify-send -a ctl "downloading whisper $dmodel model..."
|
notify-send -a ctl -t 1250 "downloading whisper $dmodel model..."
|
||||||
mkdir -p "$dmodel_dir"
|
mkdir -p "$dmodel_dir"
|
||||||
curl -L -o "$dmodel_file" \
|
curl -L -o "$dmodel_file" \
|
||||||
"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-$dmodel.bin"
|
"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-$dmodel.bin"
|
||||||
fi
|
fi
|
||||||
notify-send -a ctl "recording..."
|
notify-send -a ctl -t 1250 "recording..."
|
||||||
pw-record "$daudio" &
|
pw-record "$daudio" &
|
||||||
printf '%s' "$!" > "$dpid"
|
printf '%s' "$!" > "$dpid"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue