#!/usr/bin/env python3 """Train the recogniser from Elix LSF dictionary videos. For each word in the catalogue (signs/lexicon.json) this fetches the word's reference sign video from the Elix dictionary (dico.elix-lsf.fr), runs it through the *same* pipeline as the live recorder, and stores a DTW template in signs/lsf_signs.json. The catalogue thus becomes recognisable without recording each sign by hand. Usage: python tools/elix_train.py # all catalogue words python tools/elix_train.py --limit 5 # first 5 (quick test) python tools/elix_train.py --words BONJOUR MERCI python tools/elix_train.py --cache clips/elix # keep downloaded mp4s Politeness / usage notes: * Elix robots.txt permits crawling (empty Disallow); we still rate-limit (--delay, default 1s) and send a descriptive User-Agent. * The videos are © Signes de sens (Elix). This derives abstract landmark templates for personal/on-device use and does NOT redistribute the videos. Respect Elix's terms — don't redistribute their video files. """ from __future__ import annotations import argparse import os import re import sys import tempfile import time import unicodedata import urllib.parse import urllib.request sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lsf.landmarks import HolisticTracker # noqa: E402 from lsf.lexicon import Lexicon # noqa: E402 from lsf.recognizer import SignRecognizer # noqa: E402 from tools.import_videos import import_clip # noqa: E402 UA = "LSF-transcripter/0.1 (educational; +https://github.com/RebornX10/LSF_transcription)" ELIX_PAGE = "https://dico.elix-lsf.fr/dictionnaire/" # Primary: the