Files
lektor-ai/dictionary.txt
T
claudeandClaude Opus 5 e201aadc3e Add subtitle dictionaries, Polish number normalizer, ComfyUI lifecycle control
Text processing before TTS:

- dictionary.txt rewrites words and phrases (km/h, np., units). Rules compile
  into one alternation applied in a single pass, so replacements never chain
  and longest-literal wins. Case-sensitive, whole-word.
- A per-queue second dictionary, written by the GUI into the first video's job
  folder and merged with the shared one (--dictionary-extra).
- ALL-CAPS blocks become Title Case rather than sentence case: lowercasing
  destroyed proper nouns inside captions ("NASA - MARGO MADISON") and invited
  the normalizer to "correct" the name. Paired clips in output/clips/all-caps
  showed the TTS reads both casings the same.

normalizer/ — digits to spoken Polish, in its own venv because it needs
transformers>=5, which must not touch ComfyUI's pinned versions:

- Two backends. Plain integers go to num2words for the value and a general
  Polish LLM for the case; times, dates, decimals and identifiers go to a 0.6B
  fine-tune. Measured on 40 real subtitle lines, each is clearly better than
  the other on its half. 74% of numbered blocks take the first leg.
- Guards on every answer: runaway length, repetition loops, invalid bytes,
  leftover digits, a lost minus sign, a changed number, a lost word. A failure
  falls back to num2words, which is nominative but never wrong about the value.
- ComfyUI is asked to unload before normalizing; a normalizer that does not fit
  in VRAM is spilled to RAM silently at 5x the cost.

Backend lifecycle:

- ComfyUI is found by port through /proc, so a backend started by hand is
  managed too. SIGTERM escalates to SIGKILL, and a suspended process is killed
  outright since it never runs its handlers.
- A clip that kills the backend is retried three times, each with a different
  seed (the aborts are seed-dependent, not text-dependent), then skipped and
  reported so an overnight queue keeps moving.
- start_comfyui.sh execs python, so the script's PID is ComfyUI's.
- GUI gains ComfyUI and Queue dictionary buttons; quitting stops the backend.

--resume-from now reuses the job folder's tts_input.srt instead of reparsing
the subtitles, so block N still pairs with clip_NNNN.flac.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 21:55:31 +02:00

50 lines
2.5 KiB
Plaintext

# lektor_ai_comfy — replacement dictionary
#
# Words and phrases rewritten in the subtitles before they are sent to the TTS
# engine, for anything the model reads out wrong: abbreviations, units, symbols,
# names spelled in a way it mispronounces.
#
# One rule per line:
#
# pattern = replacement
#
# * Matching is CASE-SENSITIVE and matches whole words only: "np." leaves
# "znp." alone, and "Joshua" leaves "joshua" alone.
# * The replacement is inserted exactly as written — nothing is re-capitalised
# for you. Note that the first letter of every subtitle block is already
# capitalised before these rules run, so if a word can start a block, add a
# second rule for the capitalised form.
# * Longer patterns win: "km/h" below is used even though a plain "km" rule
# would also fit, whatever order the two are written in.
# * The replacement is never re-scanned, so rules cannot feed into each other.
# * A pattern wrapped in slashes is a regular expression, and \1 \2 … in the
# replacement refer to its groups.
# * A line starting with # or ; is a comment. An empty replacement deletes the
# phrase.
# * "->" and "=>" work as separators too, if you prefer them to "=".
#
# The changes are visible in clips/tts_input.srt after a run — check there if a
# rule is not doing what you expect.
# ── Units ──────────────────────────────────────────────────────────────────
km/h = kilometrów na godzinę
m/s = metrów na sekundę
# ── Abbreviations ──────────────────────────────────────────────────────────
np. = na przykład
tzn. = to znaczy
# These two almost always close a sentence, so the dot is kept; drop it if you
# see an unwanted pause mid-sentence.
itp. = i tym podobne.
itd. = i tak dalej.
m.in. = między innymi
24/7 = dwadzieścia cztery na siedem
# ── Symbols ────────────────────────────────────────────────────────────────
/(\d+)\s*%/ = \1 procent
/(\d+)\s*°C/ = \1 stopni Celsjusza
& = i
# ── Your own rules below ───────────────────────────────────────────────────