mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 10:56:10 +00:00
whisper-server is started on --inference-path /v1/audio/transcriptions, which is exactly the path api.py already builds for the hosted providers, and llama-server answers /chat/completions the way OpenRouter does. So the local half is one more base URL rather than a second code path: worker.py, filetranscribe.py and meeting.py are untouched, and dictation, subtitles and meetings all work here on the first try. Three findings worth naming, none of them in the new code: whisper.cpp cuts segments on tokens, which in Turkish lands inside a word about as often as between two. Pasted raw that gives "akraba değ\niller."; in a subtitle it gives a cue reading "değ". Whisper marks the start of a word with a leading space, so a piece that does not begin with one continues the word above it. A small model will repeat the transcript until the context is full, and every one of those tokens is a second of somebody waiting: measured at 206 seconds, and 25 with a ceiling on the reply. Hosted models are left alone, where the same runaway is rare and a ceiling would cut the minutes short. A server outlives SIGTERM and SIGKILL holding its model in memory. Signals are now turned into an event Qt delivers, since Qt blocks in C where a Python handler never runs, and a pid file lets the next start sweep up what a SIGKILL left behind. The minutes keep their own provider rather than following cleanup's. The two jobs are not the same size: a 4B model here will strip the filler words out of a dictation and will not write up an hour long meeting. The suite runs offline now: a test that reaches the network says so instead of quietly going there.
122 lines
3.8 KiB
Bash
Executable File
122 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Dikte installer: dependency check, launchers, KDE shortcut.
|
|
set -euo pipefail
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PY="$(command -v python3)"
|
|
BIN_DIR="$HOME/.local/bin"
|
|
APP_DIR="$HOME/.local/share/applications"
|
|
AUTOSTART_DIR="$HOME/.config/autostart"
|
|
SHORTCUT="${1:-Ctrl+Space}"
|
|
|
|
say() { printf ' %s\n' "$1"; }
|
|
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
|
|
warn() { printf ' \033[33m!\033[0m %s\n' "$1"; }
|
|
|
|
echo
|
|
echo "Installing Dikte"
|
|
echo "────────────────"
|
|
|
|
# 1. Dependencies ----------------------------------------------------------
|
|
missing=()
|
|
audio_cmds=(ffmpeg)
|
|
if command -v parec >/dev/null || command -v pw-record >/dev/null; then
|
|
:
|
|
else
|
|
missing+=("pulseaudio-utils-or-pipewire-audio")
|
|
fi
|
|
if [[ "${XDG_SESSION_TYPE:-}" == "x11" ]]; then
|
|
desktop_cmds=(xclip xdotool)
|
|
else
|
|
desktop_cmds=(wl-copy wl-paste ydotool)
|
|
fi
|
|
for cmd in "${audio_cmds[@]}" "${desktop_cmds[@]}"; do
|
|
command -v "$cmd" >/dev/null || missing+=("$cmd")
|
|
done
|
|
python3 -c 'import PyQt6.QtWidgets' 2>/dev/null || missing+=("python-pyqt6")
|
|
|
|
if ((${#missing[@]})); then
|
|
warn "Missing: ${missing[*]}"
|
|
say "Ubuntu X11: sudo apt install pulseaudio-utils xclip xdotool ffmpeg"
|
|
say "Arch Wayland: sudo pacman -S --needed pipewire-audio wl-clipboard ydotool ffmpeg python-pyqt6"
|
|
echo
|
|
else
|
|
ok "All dependencies present"
|
|
fi
|
|
|
|
# 2. ydotoold --------------------------------------------------------------
|
|
if [[ "${XDG_SESSION_TYPE:-}" != "x11" ]] && command -v ydotool >/dev/null; then
|
|
if systemctl --user is-active --quiet ydotool 2>/dev/null \
|
|
|| systemctl --user is-active --quiet ydotoold 2>/dev/null; then
|
|
ok "ydotoold is running (auto-paste ready)"
|
|
else
|
|
warn "ydotoold is not running, auto-paste will not work"
|
|
say "systemctl --user enable --now ydotool"
|
|
fi
|
|
fi
|
|
|
|
# 3. Launchers -------------------------------------------------------------
|
|
mkdir -p "$BIN_DIR" "$APP_DIR" "$AUTOSTART_DIR"
|
|
ln -sf "$DIR/dikte.py" "$BIN_DIR/dikte"
|
|
chmod +x "$DIR/dikte.py"
|
|
ok "Command installed: $BIN_DIR/dikte"
|
|
case ":$PATH:" in
|
|
*":$BIN_DIR:"*) ;;
|
|
*) warn "$BIN_DIR is not on your PATH. For fish: fish_add_path $BIN_DIR" ;;
|
|
esac
|
|
|
|
cat > "$APP_DIR/dikte.desktop" <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Dikte
|
|
Comment=Voice dictation: record, transcribe, clean up, paste
|
|
Exec=$PY $DIR/dikte.py
|
|
Icon=audio-input-microphone
|
|
Categories=Utility;AudioVideo;
|
|
StartupNotify=false
|
|
EOF
|
|
ok "Application menu entry added"
|
|
|
|
cat > "$AUTOSTART_DIR/dikte.desktop" <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Dikte
|
|
Exec=$PY $DIR/dikte.py
|
|
Icon=audio-input-microphone
|
|
X-GNOME-Autostart-enabled=true
|
|
StartupNotify=false
|
|
EOF
|
|
ok "Will start automatically on login"
|
|
|
|
# 4. KDE global shortcut ---------------------------------------------------
|
|
cat > "$APP_DIR/dikte-toggle.desktop" <<EOF
|
|
[Desktop Entry]
|
|
Exec=$PY $DIR/dikte.py toggle
|
|
Name=Dikte: start/stop recording
|
|
NoDisplay=true
|
|
StartupNotify=false
|
|
Type=Application
|
|
X-KDE-GlobalAccel-CommandShortcut=true
|
|
EOF
|
|
|
|
if [[ "${XDG_CURRENT_DESKTOP:-}" == *GNOME* || "${XDG_CURRENT_DESKTOP:-}" == *gnome* ]]; then
|
|
ok "GNOME detected"
|
|
say "Open Dikte Settings > Shortcut to install the global shortcut."
|
|
elif command -v kwriteconfig6 >/dev/null; then
|
|
kwriteconfig6 --notify --file kglobalshortcutsrc \
|
|
--group services --group dikte-toggle.desktop \
|
|
--key _launch "$SHORTCUT"
|
|
ok "KDE shortcut registered: $SHORTCUT"
|
|
warn "KWin only reads this at startup, so the shortcut goes live after your"
|
|
say "next login. Until then open Settings → Shortcut and turn on the"
|
|
say "built-in listener to use it right away."
|
|
else
|
|
warn "No supported shortcut manager found. Add the shortcut in desktop settings."
|
|
fi
|
|
|
|
echo
|
|
ok "Done. Start it with: dikte"
|
|
say "The settings window opens on first run: download a speech model, or add"
|
|
say "an OpenAI or OpenRouter key instead."
|
|
echo
|