- Fix state detection priority: dictation now takes precedence over conversation - Fix critical bug: event loop was created but never started, preventing async coroutines from executing - Optimize audio processing: reorder AcceptWaveform/PartialResult checks - Switch to faster Vosk model: vosk-model-en-us-0.22-lgraph for 2-3x speed improvement - Reduce block size from 8000 to 4000 for lower latency - Add filtering to remove spurious 'the', 'a', 'an' words from start/end of transcriptions - Update toggle-dictation.sh to properly clean up conversation lock file - Improve batch audio processing for better responsiveness
79 lines
3.5 KiB
Bash
Executable File
79 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Setup Global Keybindings for GNOME Desktop
|
|
# This script configures custom keybindings for dictation control
|
|
|
|
TOGGLE_SCRIPT="/mnt/storage/Development/dictation-service/scripts/toggle-dictation.sh"
|
|
KEYBINDING_NAME="Toggle Dictation"
|
|
DESIRED_BINDING="<Alt>d"
|
|
|
|
echo "Setting up dictation service keybindings..."
|
|
|
|
# --- Find or Create Custom Keybinding ---
|
|
KEYBASE="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
|
|
FOUND_PATH=""
|
|
CURRENT_LIST_STR=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
|
CURRENT_LIST_ARRAY=()
|
|
|
|
# Parse CURRENT_LIST_STR into an array
|
|
# This handles both empty and non-empty lists from gsettings
|
|
if [[ "$CURRENT_LIST_STR" != "@as []" ]]; then
|
|
# Remove leading "@as [" and trailing "]" and split by "', '"
|
|
# Then add each path to the array
|
|
TEMP_STR=$(echo "$CURRENT_LIST_STR" | sed -e "s/^@as \[//g" -e "s/\]$//g" -e "s/'//g")
|
|
IFS=',' read -ra CURRENT_LIST_ARRAY <<< "$TEMP_STR"
|
|
fi
|
|
|
|
for path in "${CURRENT_LIST_ARRAY[@]}"; do
|
|
path=$(echo "$path" | xargs) # Trim whitespace
|
|
if [ -n "$path" ]; then
|
|
name=$(gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$path"/ name 2>/dev/null)
|
|
if [[ "$name" == "'$KEYBINDING_NAME'" ]]; then
|
|
FOUND_PATH="$path"
|
|
break
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ -n "$FOUND_PATH" ]; then
|
|
echo "Updating existing keybinding: $FOUND_PATH"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$FOUND_PATH"/ command "'$TOGGLE_SCRIPT'"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$FOUND_PATH"/ binding "'$DESIRED_BINDING'"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$FOUND_PATH"/ name "'$KEYBINDING_NAME'"
|
|
else
|
|
# Create a new custom keybinding slot
|
|
NEXT_NUM=0
|
|
for path in "${CURRENT_LIST_ARRAY[@]}"; do
|
|
path_num=$(echo "$path" | sed -n 's/.*custom\([0-9]\+\)$/\1/p')
|
|
if [ -n "$path_num" ] && [ "$path_num" -ge "$NEXT_NUM" ]; then
|
|
NEXT_NUM=$((path_num + 1))
|
|
fi
|
|
done
|
|
|
|
NEW_KEY_ID="custom$NEXT_NUM"
|
|
FULL_KEYPATH="$KEYBASE/$NEW_KEY_ID/"
|
|
|
|
echo "Creating new keybinding at: $FULL_KEYPATH"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybindings:"$FULL_KEYPATH" name "'$KEYBINDING_NAME'"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybindings:"$FULL_KEYPATH" command "'$TOGGLE_SCRIPT'"
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybindings:"$FULL_KEYPATH" binding "'$DESIRED_BINDING'"
|
|
|
|
# Add the new keybinding to the list if it's not already there
|
|
if ! echo "$CURRENT_LIST_STR" | grep -q "$FULL_KEYPATH"; then
|
|
if [[ "$CURRENT_LIST_STR" == "@as []" ]]; then
|
|
NEW_LIST="['$FULL_KEYPATH']"
|
|
else
|
|
# Ensure proper comma separation
|
|
NEW_LIST="${CURRENT_LIST_STR::-1}, '$FULL_KEYPATH']"
|
|
NEW_LIST=$(echo "$NEW_LIST" | sed "s/@as //g") # Remove @as if present
|
|
fi
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$NEW_LIST"
|
|
fi
|
|
fi
|
|
|
|
echo "Keybinding setup complete!"
|
|
echo "Press $DESIRED_BINDING to toggle dictation service"
|
|
echo ""
|
|
echo "Note: The keybinding will only function if the 'dictation.service' is running."
|
|
echo "To remove this specific keybinding (if it was created), you might need to manually check"
|
|
echo "your GNOME Keyboard Shortcuts settings or use dconf-editor to remove '$KEYBINDING_NAME'." |