Small bugfix
This commit is contained in:
+15
-12
@@ -4637,14 +4637,19 @@ def _files_modified_since(root: Path, since: float, pattern: str) -> bool:
|
|||||||
def _trim_outputs_current(project_path: Path) -> bool:
|
def _trim_outputs_current(project_path: Path) -> bool:
|
||||||
"""Return True if the trim stage can be safely skipped for every segment.
|
"""Return True if the trim stage can be safely skipped for every segment.
|
||||||
|
|
||||||
A segment is considered resolved when narration.json already records an
|
A segment is resolved only when its trim *output* is actually present on
|
||||||
explicit skip/take for it, or a cached Whisper transcript exists at
|
BOTH sides — begin (a user 'begin'/'start' pin or a written 'skip') AND end
|
||||||
narration/transcripts/{seg_id}.json (from which trim would just recompute
|
(a user 'end' pin or a written 'take'). This mirrors the per-side resolution
|
||||||
the same skip/take). Used by the 'all' pipeline to avoid re-running the
|
logic in cmd_trim itself.
|
||||||
expensive transcription stage when nothing upstream changed.
|
|
||||||
|
A cached transcript is deliberately NOT treated as "resolved": the transcript
|
||||||
|
existing does not mean skip/take were ever written (an interrupted run, a
|
||||||
|
manual edit, or a begin-only pin can leave the end un-trimmed). Trim will
|
||||||
|
still reuse the cached transcript when it runs, so skipping re-transcription
|
||||||
|
stays cheap — we just no longer skip trim while real work remains.
|
||||||
|
|
||||||
Returns False (i.e. "run trim") if narration can't be read or any segment
|
Returns False (i.e. "run trim") if narration can't be read or any segment
|
||||||
is still unresolved.
|
is still unresolved on either side.
|
||||||
"""
|
"""
|
||||||
from .parser import parse_project_config, parse_narration
|
from .parser import parse_project_config, parse_narration
|
||||||
|
|
||||||
@@ -4657,7 +4662,6 @@ def _trim_outputs_current(project_path: Path) -> bool:
|
|||||||
if not narration:
|
if not narration:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
transcripts_dir = narration_dir / "transcripts"
|
|
||||||
try:
|
try:
|
||||||
raw_data = _read_json(narration_dir / "narration.json")
|
raw_data = _read_json(narration_dir / "narration.json")
|
||||||
except (OSError, json.JSONDecodeError):
|
except (OSError, json.JSONDecodeError):
|
||||||
@@ -4665,11 +4669,10 @@ def _trim_outputs_current(project_path: Path) -> bool:
|
|||||||
|
|
||||||
for seg_id in narration:
|
for seg_id in narration:
|
||||||
entry = raw_data.get(seg_id, {})
|
entry = raw_data.get(seg_id, {})
|
||||||
if "skip" in entry or "take" in entry:
|
begin_resolved = bool(entry.get("begin") or entry.get("start")) or "skip" in entry
|
||||||
continue # already trimmed
|
end_resolved = bool(entry.get("end")) or "take" in entry
|
||||||
if (transcripts_dir / f"{seg_id}.json").exists():
|
if not (begin_resolved and end_resolved):
|
||||||
continue # transcript cached — trim would just reuse it
|
return False # a side still needs trimming
|
||||||
return False # unresolved segment: trim still has work to do
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user