Commit Graph
3 Commits
Author SHA1 Message Date
claudeandClaude Opus 5 1dbe862531 Add the Knapik voice and a fourth Gudowski sample
Tomasz_Knapik.wav is a second lektor voice to try against Gudowski. It has no
reference transcript yet, so it needs one written before it can be used the way
the others are.

gudowski_short_4.wav is a fourth reference sample with its transcript, and
gudowski_generated.wav is TTS output kept beside the samples for comparison,
not an input.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkWDx9dVB7xBpqntvjvm6A
2026-08-31 21:18:34 +02:00
claudeandClaude Opus 5 200d221816 Add graphical queue (ui.py), fix runaway-clip padding
ui.py — graphical front-end
  Queue several videos and run them one after another. Each job shells out to
  lektor_ai_comfy.py with ordinary command-line arguments, so the terminal
  script stays the single source of truth and remains usable on its own.

  Videos chosen together in one multi-select form a linked set whose settings
  move together; blocks added with + stay independent. Subtitles are found
  beside the video automatically, picked manually, or chosen from the video's
  embedded tracks. REGENERATE / RESUME / RE-BUILD map to --regen,
  --resume-from and --rebuild; RESUME pre-fills the last clip on disk, since an
  interrupted run can leave that one half-written. A Settings dialog edits
  settings.ini in place, rewriting only the value lines so the file's comments
  survive — configparser would have dropped all 29 of them. Closing asks first,
  and names the queued jobs that would be discarded.

  tkinter, so no new dependencies. It needs a Tk with real fonts: the system
  one after `apt install python3-tk`. Under miniforge's Python it still runs but
  falls back to X11 bitmap fonts, which the UI detects and reports.

  Reading the child's pipe deliberately avoids text=True. Text mode enables
  universal newlines, which rewrites a lone carriage return as a newline — so
  ffmpeg's progress bars redrew as a new line per update instead of animating.
  Wheel events are bound per widget rather than with bind_all, so scrolling
  stops at a widget's limit instead of spilling into whatever is behind it, and
  can no longer change a dropdown's value in passing.

start_lektor_ui.sh
  Picks a Python that has tkinter, preferring the system one for its fonts.

Runaway clip padding
  When the model fails to emit a stop token it generates until --max-tokens is
  exhausted: a two-second line becomes a 136s clip. Placement uses a
  push-forward cursor, so that padding delayed every clip after it — measured
  on one film, 1807 of 2075 clips were pushed late, the worst by 981 seconds,
  which is why the voiceover fell silent over later dialogue.

  Clips are now trimmed before they are saved. Two padding modes occur and both
  are handled: digital silence, found with silencedetect; and a steady tone that
  sits above any sane silence threshold, found by its flatness instead — tone
  tails spread 3-5 dB across their windows where speech spreads 43-61 dB.

  --trim-silence repairs jobs generated before this, in place and without
  regenerating anything. Applied to the six existing jobs it removed 77 clips'
  worth of padding, about 1h55m, leaving every job within a few seconds of its
  subtitle timing.

--embedded-sub-index
  Selects an embedded subtitle track by ffmpeg stream index instead of
  prompting, for the UI and for scripted runs. Interactive behaviour is
  unchanged when it is omitted.

settings.ini — voice gudowski_short_3, temperature 0.6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 12:36:59 +02:00
claudeandClaude Opus 5 3dde6e58e4 Settings file, per-job clip folders, faster polling, voices/ rename
Poll interval
  wait_for_completion() polled every 3 s, which quantised every clip to a 3 s
  boundary — across 2075 existing clips, 91% of the gaps landed exactly on a
  multiple of 3 s. It now starts at 0.25 s and backs off to 2 s after 10 s, so
  short clips are picked up immediately without hammering the server on long
  ones. Measured over 34 clips: 4.75 s actual vs 6.35 s under the old poll,
  a 25% cut in TTS wait (~18 min on a 693-clip episode). Runs now print real
  generation time, e.g. "done (4.2s)".

  A WebSocket would remove polling entirely but needs a third-party client,
  which would cost this script its dependency-free property.

settings.ini
  voice, speed, temperature, max_tokens, strip_leading_ms, trailing_fade_ms,
  orig_volume, tts_volume, output_dir and comfy_url moved to an INI file next
  to the script. Precedence is CLI flag > settings.ini > built-in default,
  wired by feeding loaded values in as argparse defaults. --settings FILE
  selects an alternative profile.

  INI rather than TOML (tomllib is 3.11+, this runs on system Python 3.10) or
  JSON (no comments). A missing, partial, malformed or corrupt file degrades to
  built-in defaults with a warning instead of killing a long run.

  Run-specific flags are deliberately excluded: --start, --end, --seed,
  --regen, --rebuild, --resume-from, --embedded-subs, --skip-tts.

Per-job folders
  All state for one video now lives in <output_dir>/clips/<video name>/ —
  clips, tts_input.srt, tts_assembled.flac, embedded_sub.srt and
  video_fragment.mkv. Only <stem>_lektor.mkv stays at the top level.

  tts_input.srt moved with the clips because they are a matched pair: block N
  in the SRT is clip_NNNN.flac. Previously both sat at the top level and each
  new job overwrote the last one's, so rebuilding an older film silently
  paired its clips with the newest film's text. Any past job can now be
  rebuilt. A run against the old flat layout gets an explanatory message.

gudowski/ -> voices/
  VOICE_PROMPTS_DIR is now resolved relative to the script rather than
  hardcoded, so moving the project no longer breaks it. Voice filenames are
  unchanged, so --voice gudowski_short still works.

Docs updated throughout for the new layout, settings file and poll behaviour.

Known issue, not addressed here: with a non-zero --start the voiceover plays
early. extract_video_fragment() stream-copies, so it can only cut on a
keyframe and seeks backwards to it, while TTS timestamps are relative to the
requested start. On S01_E08 at --start 07:40 the nearest earlier keyframe is
458.375 s, putting the voiceover 1.625 s ahead of the picture. Runs with
--start 00:00 are unaffected, since 0 is always a keyframe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 21:56:42 +02:00