mirror of
https://github.com/deunix-educ/voice-assistant.git
synced 2026-11-26 20:19:43 +01:00
F4b : suppression du code devenu inutile (VAD, diarisation, voix, mot de réveil, écoute continue)
Serveur : modules voice_activity, diarization, speaker_identifier, speaker_attribution, wake_word et hands_free avec leurs tests ; sections vad, diarization, speaker et wake de config.yaml ; horodatage des mots de Whisper ; extras diarization et wakeword ; HF_TOKEN. __main__.py ne branche plus d'écoute mains libres. Outils : vad_check, diarize_check et enroll supprimés ; speech_check sans VAD, say sans mot de réveil, download_models limité à Whisper et Piper, latency_check réécrit (temps de Whisper sur la session entière). Makefile : cibles et variables correspondantes retirées. Firmware : commandes listen et capture, flux audio/stream, LED d'écoute continue supprimés ; la LED au repos clignote lentement ; l'absence du serveur est seulement journalisée. mosquitto/acl : droit d'écriture audio/stream retiré. Les profils vocaux (server/profiles) et les modèles inutilisés ne sont pas touchés. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
models/whisper/<stt.model>/ modèle faster-whisper (CTranslate2)
|
||||
models/piper/<tts.voice>.onnx voix Piper et sa configuration .onnx.json
|
||||
models/pyannote/<nom>/ diarisation (étape 8) : jeton HF_TOKEN dans server/.env
|
||||
models/openwakeword/*.onnx mots de réveil (étape 13)
|
||||
|
||||
Les modèles déjà présents ne sont pas retéléchargés. Ensuite, le serveur
|
||||
fonctionne sans Internet : il ne lit que ces fichiers locaux.
|
||||
@@ -17,7 +15,6 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -25,16 +22,7 @@ SERVER_DIR = Path(__file__).resolve().parents[1] / "server"
|
||||
if str(SERVER_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(SERVER_DIR))
|
||||
|
||||
from voice_server.settings import ( # noqa: E402
|
||||
DiarizationSettings,
|
||||
SttSettings,
|
||||
TtsSettings,
|
||||
WakeSettings,
|
||||
load_settings,
|
||||
)
|
||||
from voice_server.wake_word import model_files # noqa: E402
|
||||
|
||||
OPENWAKEWORD_URL = "https://github.com/dscripka/openWakeWord/releases/download/v0.5.1/{name}"
|
||||
from voice_server.settings import SttSettings, TtsSettings, load_settings # noqa: E402
|
||||
|
||||
logger = logging.getLogger("download_models")
|
||||
|
||||
@@ -63,55 +51,6 @@ def download_piper(tts: TtsSettings) -> None:
|
||||
download_voice(tts.voice, tts.model_path.parent)
|
||||
|
||||
|
||||
def download_pyannote(diarization: DiarizationSettings) -> bool:
|
||||
"""Télécharge le pipeline de diarisation ; False si le jeton ou l'accord manque."""
|
||||
if not diarization.enabled:
|
||||
logger.info("diarisation desactivee dans config.yaml : rien a telecharger")
|
||||
return True
|
||||
if (diarization.model_dir / "config.yaml").exists():
|
||||
logger.info("diarisation %s deja presente : %s", diarization.model, diarization.model_dir)
|
||||
return True
|
||||
page = f"https://huggingface.co/{diarization.model}"
|
||||
token = os.environ.get("HF_TOKEN") # chargé depuis server/.env par load_settings
|
||||
if not token:
|
||||
logger.error("HF_TOKEN absent de server/.env. Pour la diarisation :\n"
|
||||
" 1. compte sur https://huggingface.co, puis accepter les conditions sur %s\n"
|
||||
" 2. jeton « Read » sur https://huggingface.co/settings/tokens\n"
|
||||
" 3. cp server/.env.example server/.env, y renseigner HF_TOKEN=..., relancer 'make models'",
|
||||
page)
|
||||
return False
|
||||
from huggingface_hub import snapshot_download
|
||||
from huggingface_hub.errors import GatedRepoError, HfHubHTTPError
|
||||
|
||||
logger.info("telechargement de %s vers %s…", diarization.model, diarization.model_dir)
|
||||
try:
|
||||
snapshot_download(diarization.model, local_dir=diarization.model_dir, token=token,
|
||||
allow_patterns=["config.yaml", "*/pytorch_model.bin", "plda/*.npz"])
|
||||
except GatedRepoError:
|
||||
logger.error("acces refuse : acceptez les conditions du modele sur %s", page)
|
||||
return False
|
||||
except HfHubHTTPError as error:
|
||||
logger.error("echec du telechargement (%s) : jeton HF_TOKEN valide ?", error)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def download_openwakeword(wake: WakeSettings) -> None:
|
||||
"""Télécharge les modèles ONNX d'openWakeWord (communs + un par mot) depuis GitHub."""
|
||||
if not wake.enabled:
|
||||
return
|
||||
from urllib.request import urlretrieve
|
||||
|
||||
wake.model_dir.mkdir(parents=True, exist_ok=True)
|
||||
for name in model_files(wake):
|
||||
target = wake.model_dir / name
|
||||
if target.exists():
|
||||
continue
|
||||
logger.info("telechargement de %s", name)
|
||||
urlretrieve(OPENWAKEWORD_URL.format(name=name), target)
|
||||
logger.info("mots de reveil prets : %s", ", ".join(wake.words))
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
"""Télécharge ce qui manque, puis affiche la taille totale."""
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
@@ -127,12 +66,10 @@ def main(argv: list[str]) -> int:
|
||||
except ImportError as error:
|
||||
logger.error("%s : lancez d'abord 'make install-speech'", error)
|
||||
return 1
|
||||
download_openwakeword(settings.wake)
|
||||
diarization_ready = download_pyannote(settings.diarization)
|
||||
|
||||
size = sum(f.stat().st_size for f in settings.models_dir.rglob("*") if f.is_file())
|
||||
logger.info("modeles dans %s (%.0f Mo)", settings.models_dir, size / 1e6)
|
||||
return 0 if diarization_ready else 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user