mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-08 16:54:43 +02:00
feat(stt): app de bureau (fenêtre type Discord) + auto-update
Rend STT lançable comme une application de bureau et ajoute la mise à jour intégrée.
- Mode fenêtre « app » : _open_browser ouvre le HUD en fenêtre chromeless
(--app=, type Discord) en plus du kiosk plein écran ; support Brave ajouté.
Sélection via --window {app,kiosk,none} ou [ui].window_mode.
- stt --install-desktop / --uninstall-desktop : entrée .desktop + icône
(stt/hud/icon.svg, aussi favicon du HUD) → STT dans le menu/dock, lance --window app.
- stt --update : pipx reinstall depuis la source git (via clé SSH), affiche
« ancienne → nouvelle » ; stt --version.
- Docs (admin/ia/stt.md, stt/README) + config (window_mode) + bump 0.3.0 → 0.4.0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qjq5jHiqNepnobJpHYpCa
This commit is contained in:
parent
d1bf20c86d
commit
c0da379755
9 changed files with 191 additions and 12 deletions
|
|
@ -14,9 +14,9 @@ Objectif ultérieur : « agir sur le homelab » via les outils de Hermes (phase
|
|||
> (5e).
|
||||
> ✅ **2026-06-18** — HUD avancé (4) + auto-start (6). HUD : design **Claude Design** (avatar
|
||||
> portrait réactif, transcript à bulles, drawer Réglages **câblé au backend** : reset / mode
|
||||
> cerveau / mot de réveil à chaud). Auto-start : `stt --install-service` (systemd --user,
|
||||
> `graphical-session.target`). Reste : test audio bout-en-bout (phase 1), portraits réels +
|
||||
> test sur cible, outils Hermes (7).
|
||||
> cerveau / mot de réveil à chaud). Auto-start : `stt --install-service` (systemd --user).
|
||||
> App de bureau : `stt --install-desktop` (fenêtre type Discord) ; auto-update : `stt --update`.
|
||||
> Reste : test audio bout-en-bout (phase 1), portraits réels + test sur cible, outils Hermes (7).
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -182,6 +182,36 @@ la session graphique démarre au boot et tire le service.
|
|||
|
||||
---
|
||||
|
||||
## Application de bureau & mise à jour
|
||||
|
||||
**Lancer STT comme une appli** (fenêtre dédiée type Discord, pas un onglet) :
|
||||
|
||||
```bash
|
||||
stt --install-desktop # entrée de menu (.desktop) + icône → épinglable au dock
|
||||
stt --uninstall-desktop # la retirer
|
||||
```
|
||||
|
||||
Le lanceur exécute `stt --window app` : le HUD s'ouvre en fenêtre *chromeless* (`--app=` de
|
||||
Chromium/Brave). Modes via `--window` ou `[ui].window_mode` : `app` (fenêtre), `kiosk` (plein
|
||||
écran, défaut du service), `none` (n'ouvre rien). L'icône est `stt/hud/icon.svg` (aussi favicon).
|
||||
|
||||
> ⚠️ Le lanceur de bureau et le service systemd (kiosk) utilisent les **mêmes ports** (9300/9301) :
|
||||
> n'en faire tourner qu'un à la fois. Borne dédiée → service kiosk ; usage à la demande → lanceur
|
||||
> de bureau (et `stt --uninstall-service`).
|
||||
|
||||
**Mettre à jour** (sans désinstaller/réinstaller à la main) :
|
||||
|
||||
```bash
|
||||
stt --update # pipx reinstall depuis la source git (via ta clé SSH) — affiche ancienne → nouvelle
|
||||
stt --version # version installée
|
||||
```
|
||||
|
||||
`--update` re-récupère la dernière version depuis la branche/source d'installation. Pré-requis :
|
||||
avoir installé via `pipx` depuis git. Astuce : toujours bumper la version du paquet à chaque
|
||||
release, sinon le cache de build pipx/uv peut resservir l'ancienne (cf. `pyproject.toml`).
|
||||
|
||||
---
|
||||
|
||||
## Roadmap
|
||||
|
||||
| Phase | Objectif | État |
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ stt --text # chat texte simple (sans micro ni HUD) — idéal pour t
|
|||
stt # voix + HUD ; dis "Ok Hermès …"
|
||||
stt --model claude # choisir le modèle : hermes (défaut) | claude | qwen | opus
|
||||
stt --install-service # auto-start au login (systemd --user, kiosk « écran Jarvis »)
|
||||
stt --install-desktop # ajoute STT au menu des applis → fenêtre dédiée (type Discord)
|
||||
stt --window app # ouvre le HUD en fenêtre app (sinon : kiosk plein écran)
|
||||
stt --update # met à jour depuis git (plus de désinstall/réinstall manuel)
|
||||
```
|
||||
En mode texte : commandes `/model <nom>`, `/models`, `/quit`.
|
||||
Prérequis voix : micro, Piper + voix dans `~/.local/share/piper/`, `aplay` (alsa-utils).
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ chat_timeout_sec = 60
|
|||
[ui]
|
||||
theme = "arc-reactor"
|
||||
avatar = "default"
|
||||
kiosk = true # ouvre le HUD en plein écran (kiosk) au lancement
|
||||
kiosk = true # (compat) plein écran si window_mode absent
|
||||
window_mode = "kiosk" # "app" (fenêtre, type Discord) | "kiosk" (plein écran) | "none"
|
||||
ws_host = "127.0.0.1"
|
||||
ws_port = 9300 # websocket états ↔ HUD (doit matcher hud/index.html)
|
||||
http_port = 9301 # HTTP statique qui sert le HUD
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "stt"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
description = "STT — client vocal Jarvis du homelab Funk (voix + HUD, parle au STT-server)"
|
||||
requires-python = ">=3.11"
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -109,6 +109,106 @@ def _cmd_uninstall_service() -> int:
|
|||
return 0
|
||||
|
||||
|
||||
def _desktop_entry(stt_bin: str, icon_path: str) -> str:
|
||||
"""Contenu du lanceur .desktop : STT comme application de bureau (fenêtre app)."""
|
||||
return f"""[Desktop Entry]
|
||||
Type=Application
|
||||
Name=STT — Assistant vocal
|
||||
GenericName=Assistant vocal
|
||||
Comment=Assistant vocal Jarvis du homelab Funk
|
||||
Exec={stt_bin} --window app
|
||||
Icon={icon_path}
|
||||
Terminal=false
|
||||
Categories=Utility;AudioVideo;
|
||||
Keywords=jarvis;assistant;voix;hermes;
|
||||
StartupNotify=true
|
||||
"""
|
||||
|
||||
|
||||
def _cmd_install_desktop() -> int:
|
||||
"""Crée l'entrée de menu (.desktop) + icône → STT lançable comme une appli (type Discord)."""
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
stt_bin = shutil.which("stt") or os.path.realpath(sys.argv[0])
|
||||
icon_path = Path(__file__).resolve().parent / "hud" / "icon.svg"
|
||||
apps_dir = Path.home() / ".local" / "share" / "applications"
|
||||
apps_dir.mkdir(parents=True, exist_ok=True)
|
||||
entry = apps_dir / "stt.desktop"
|
||||
entry.write_text(_desktop_entry(stt_bin, str(icon_path)))
|
||||
entry.chmod(0o755)
|
||||
subprocess.run(["update-desktop-database", str(apps_dir)], check=False)
|
||||
|
||||
print(f"✓ Lanceur : {entry}")
|
||||
print(f" Icône : {icon_path}")
|
||||
print(f" Exec : {stt_bin} --window app")
|
||||
print("\nSTT apparaît dans le menu des applications (épinglable au dock).")
|
||||
print("Il s'ouvre en fenêtre « app » (sans onglets), comme Discord.")
|
||||
print("Retirer : stt --uninstall-desktop")
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_uninstall_desktop() -> int:
|
||||
"""Supprime le lanceur de bureau."""
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
entry = Path.home() / ".local" / "share" / "applications" / "stt.desktop"
|
||||
if entry.exists():
|
||||
entry.unlink()
|
||||
print(f"✓ Lanceur supprimé : {entry}")
|
||||
else:
|
||||
print("(lanceur déjà absent)")
|
||||
subprocess.run(["update-desktop-database", str(entry.parent)], check=False)
|
||||
return 0
|
||||
|
||||
|
||||
def _installed_version() -> str | None:
|
||||
from importlib.metadata import PackageNotFoundError, version
|
||||
|
||||
try:
|
||||
return version("stt")
|
||||
except PackageNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
def _cmd_version() -> int:
|
||||
print(_installed_version() or "version inconnue (pas installé via pip/pipx)")
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_update() -> int:
|
||||
"""Met à jour STT depuis sa source git (pipx reinstall) — sans désinstall/réinstall manuel."""
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
pipx = shutil.which("pipx")
|
||||
if not pipx:
|
||||
print("pipx introuvable — mise à jour automatique impossible.")
|
||||
print("Réinstalle manuellement depuis la source git.")
|
||||
return 1
|
||||
before = _installed_version()
|
||||
if before:
|
||||
print(f"Version installée : {before}")
|
||||
print("Récupération de la dernière version depuis git (pipx reinstall)…\n")
|
||||
res = subprocess.run([pipx, "reinstall", "stt"], capture_output=True, text=True)
|
||||
out = ((res.stdout or "") + (res.stderr or "")).strip()
|
||||
if out:
|
||||
print(out)
|
||||
m = re.search(r"installed package stt ([0-9][^\s,]*)", out)
|
||||
after = m.group(1) if m else None
|
||||
print()
|
||||
if after and before and after != before:
|
||||
print(f"✓ Mis à jour : {before} → {after}")
|
||||
elif after:
|
||||
print(f"✓ Déjà à jour ({after}).")
|
||||
else:
|
||||
print("✓ Réinstallation terminée — vérifie avec : stt --version")
|
||||
return res.returncode
|
||||
|
||||
|
||||
def _make_client(args):
|
||||
from stt.api import ServerClient
|
||||
from stt.config import load_config, resolve_model
|
||||
|
|
@ -172,6 +272,11 @@ def _cmd_voice(args) -> int:
|
|||
from stt.voice import VoiceEngine
|
||||
|
||||
cfg, client = _make_client(args)
|
||||
# mode d'ouverture du HUD : --window > config window_mode > kiosk (compat) > none
|
||||
ui = cfg["ui"]
|
||||
ui["window_mode"] = (
|
||||
args.window or ui.get("window_mode") or ("kiosk" if ui.get("kiosk") else "none")
|
||||
)
|
||||
print(f"STT-server : {client.url} — modèle '{client.model}'")
|
||||
if not client.healthy():
|
||||
print(" ⚠️ serveur injoignable — vérifie [server] url et le réseau")
|
||||
|
|
@ -203,18 +308,35 @@ def main(argv: list[str] | None = None) -> int:
|
|||
p.add_argument("--model", help="Modèle : hermes, claude, qwen, opus (ou alias LiteLLM)")
|
||||
p.add_argument("--server", help="Force l'URL du STT-server (sinon config)")
|
||||
p.add_argument("--no-tts", action="store_true", help="Réponses texte seulement (voix)")
|
||||
p.add_argument("--window", choices=["app", "kiosk", "none"],
|
||||
help="Ouverture du HUD : app (fenêtre, type Discord) | kiosk (plein écran) | none")
|
||||
p.add_argument("--install-service", action="store_true",
|
||||
help="Installe le service systemd --user (auto-start au login + kiosk)")
|
||||
p.add_argument("--uninstall-service", action="store_true",
|
||||
help="Désinstalle le service systemd --user")
|
||||
p.add_argument("--install-desktop", action="store_true",
|
||||
help="Crée le lanceur de bureau (.desktop + icône) — appli type Discord")
|
||||
p.add_argument("--uninstall-desktop", action="store_true",
|
||||
help="Supprime le lanceur de bureau")
|
||||
p.add_argument("--update", action="store_true",
|
||||
help="Met à jour STT depuis git (pipx reinstall)")
|
||||
p.add_argument("--version", action="store_true", help="Affiche la version installée")
|
||||
args = p.parse_args(argv)
|
||||
|
||||
if args.version:
|
||||
return _cmd_version()
|
||||
if args.setup:
|
||||
return _cmd_setup()
|
||||
if args.update:
|
||||
return _cmd_update()
|
||||
if args.install_service:
|
||||
return _cmd_install_service()
|
||||
if args.uninstall_service:
|
||||
return _cmd_uninstall_service()
|
||||
if args.install_desktop:
|
||||
return _cmd_install_desktop()
|
||||
if args.uninstall_desktop:
|
||||
return _cmd_uninstall_desktop()
|
||||
if args.text:
|
||||
return _cmd_text(args)
|
||||
return _cmd_voice(args)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ DEFAULT_CONFIG: dict[str, Any] = {
|
|||
"theme": "arc-reactor",
|
||||
"avatar": "default",
|
||||
"kiosk": True,
|
||||
# window_mode : "app" (fenêtre type Discord) | "kiosk" (plein écran) | "none".
|
||||
# Si absent, repli sur kiosk ci-dessus (compat).
|
||||
"window_mode": "kiosk",
|
||||
"ws_host": "127.0.0.1",
|
||||
"ws_port": 9300,
|
||||
"http_port": 9301,
|
||||
|
|
|
|||
13
stt/client/stt/hud/icon.svg
Normal file
13
stt/client/stt/hud/icon.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" role="img" aria-label="STT — Assistant vocal">
|
||||
<defs>
|
||||
<radialGradient id="bg" cx="50%" cy="38%" r="75%">
|
||||
<stop offset="0%" stop-color="#10202f"/>
|
||||
<stop offset="100%" stop-color="#070b12"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<rect width="128" height="128" rx="30" fill="url(#bg)"/>
|
||||
<circle cx="64" cy="64" r="38" fill="none" stroke="#ff5d6c" stroke-width="6"/>
|
||||
<circle cx="64" cy="64" r="24" fill="none" stroke="#f0c9cf" stroke-width="3" opacity=".65"/>
|
||||
<circle cx="64" cy="64" r="6" fill="#ff5d6c"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 658 B |
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||
<title>STT — Assistant vocal</title>
|
||||
<link rel="icon" href="icon.svg" />
|
||||
<style>
|
||||
/* ============================================================
|
||||
THÈME — variables CSS faciles à régler
|
||||
|
|
|
|||
|
|
@ -97,10 +97,11 @@ async def serve(cfg: dict[str, Any], make_engine, client) -> None:
|
|||
async with websockets.serve(handler, ui["ws_host"], ui["ws_port"]):
|
||||
url = f"http://{ui['ws_host']}:{ui['http_port']}/"
|
||||
print(f" HUD : {url}")
|
||||
if ui.get("kiosk"):
|
||||
mode = ui.get("window_mode") or ("kiosk" if ui.get("kiosk") else "none")
|
||||
if mode != "none":
|
||||
# ?v=<timestamp> : URL unique à chaque lancement → le navigateur ne peut
|
||||
# pas servir une version cachée du HUD (« ancien HUD persistant »).
|
||||
_open_browser(f"{url}?v={int(time.time())}", kiosk=True)
|
||||
_open_browser(f"{url}?v={int(time.time())}", mode)
|
||||
await asyncio.Future() # tourne indéfiniment
|
||||
|
||||
|
||||
|
|
@ -112,17 +113,22 @@ def _run_engine(engine, emit) -> None:
|
|||
emit({"type": "error", "text": f"moteur vocal : {e}"})
|
||||
|
||||
|
||||
def _open_browser(url: str, kiosk: bool) -> None:
|
||||
def _open_browser(url: str, mode: str) -> None:
|
||||
"""Ouvre le HUD. mode : 'app' (fenêtre chromeless, type Discord) | 'kiosk' (plein écran)."""
|
||||
import shutil
|
||||
import subprocess
|
||||
import webbrowser
|
||||
|
||||
for browser in ("chromium", "google-chrome", "chromium-browser"):
|
||||
# Chromium-like : --app=<url> = fenêtre dédiée sans onglets ; --kiosk = plein écran.
|
||||
for browser in (
|
||||
"brave-browser", "brave", "chromium", "chromium-browser",
|
||||
"google-chrome", "google-chrome-stable",
|
||||
):
|
||||
if shutil.which(browser):
|
||||
flag = "--kiosk" if kiosk else "--new-window"
|
||||
subprocess.Popen([browser, flag, url])
|
||||
args = [browser, "--kiosk", url] if mode == "kiosk" else [browser, f"--app={url}"]
|
||||
subprocess.Popen(args)
|
||||
return
|
||||
webbrowser.open(url)
|
||||
webbrowser.open(url) # repli : onglet dans le navigateur par défaut
|
||||
|
||||
|
||||
def _apply_settings(client, engine, data: dict, loop) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue