Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Sentence-clean highlight boundaries + no auto-outro for highlight profiles

Nika Siradze35e3ce907e62
diff --git a/backend/cli.py b/backend/cli.py
index c54be32..2f53fa9 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -470,7 +470,9 @@ def cmd_process(args):
else:
print(f" Warning: Logo '{args.logo}' not found (checked assets and filesystem)", file=sys.stderr)
config["logo_path"] = args.logo # pass through anyway
- if args.outro:
+ if getattr(args, "no_outro", False):
+ config["outro_path"] = ""
+ elif args.outro:
from services.asset_store import resolve as resolve_asset_outro
resolved = resolve_asset_outro(args.outro)
if resolved:
@@ -479,10 +481,14 @@ def cmd_process(args):
print(f" Warning: Outro '{args.outro}' not found (checked assets and filesystem)", file=sys.stderr)
config["outro_path"] = args.outro
elif not config.get("outro_path"):
- from services.asset_store import default_outro
- auto_outro = default_outro()
- if auto_outro:
- config["outro_path"] = auto_outro
+ # Highlight profiles (party/action) are raw moments, not branded shorts, so they
+ # skip the auto-outro; the podcast flow keeps it.
+ from services.profiles import get_profile as _get_profile
+ if _get_profile(config.get("profile")).candidate_source != "saliency":
+ from services.asset_store import default_outro
+ auto_outro = default_outro()
+ if auto_outro:
+ config["outro_path"] = auto_outro
if args.time_adjust is not None:
config["time_adjust"] = args.time_adjust
if args.no_energy:
@@ -742,6 +748,7 @@ def cmd_process(args):
min_dur=15.0,
max_dur=min(60.0, float(spec.dur_max)),
segments=segments or None,
+ words=words or None,
progress_callback=lambda pct, msg: print(f" {msg}") if msg else None,
)
if clips:
@@ -3398,6 +3405,7 @@ def main():
proc.add_argument("--profile", choices=["podcast", "party", "action"], help="Detection profile: podcast (transcript-first, default), party/action (laughter/energy highlights)")
proc.add_argument("--logo", help="Logo image (asset name or path)")
proc.add_argument("--outro", help="Outro video (asset name or path)")
+ proc.add_argument("--no-outro", action="store_true", help="Do not append an outro (default for highlight profiles)")
proc.add_argument("--time-adjust", type=float, help="Timestamp offset in seconds")
proc.add_argument("--no-energy", action="store_true", help="Skip audio energy analysis")
proc.add_argument("--no-speakers", action="store_true", help="Skip speaker detection (faster, uses face detection only)")
diff --git a/backend/services/saliency.py b/backend/services/saliency.py
index 1fa0ff1..3771d59 100644
--- a/backend/services/saliency.py
+++ b/backend/services/saliency.py
@@ -117,6 +117,31 @@ def _snap_to_quiet(target_sec: float, energy_curve: np.ndarray, window_sec: floa
return (lo + int(np.argmin(local))) / GRID_HZ
+def sentences_from_words(words: list[dict]) -> list[dict]:
+ """Group word-level timestamps into sentences on terminal punctuation.
+
+ Whisper *segments* often straddle a sentence boundary ("...was. But then..."), so
+ snapping to them still starts a clip mid-thought. Splitting on .?! gives real
+ sentence edges to snap to.
+ """
+ sents: list[dict] = []
+ start = None
+ end = None
+ for w in words:
+ text = str(w.get("word", "")).strip()
+ if not text:
+ continue
+ if start is None:
+ start = w.get("start", 0.0)
+ end = w.get("end", start)
+ if text.endswith((".", "?", "!")):
+ sents.append({"start": start, "end": end})
+ start = None
+ if start is not None:
+ sents.append({"start": start, "end": end})
+ return sents
+
+
def _seg_index_at(t: float, segments: list[dict]) -> int:
"""Index of the segment covering t, else the nearest segment start."""
for i, s in enumerate(segments):
@@ -201,17 +226,20 @@ def detect_highlights(
max_dur: float = 60.0,
height_z: float = 1.0,
segments: Optional[list[dict]] = None,
+ words: Optional[list[dict]] = None,
progress_callback: Optional[Callable] = None,
) -> list[dict]:
"""
Generate highlight clips from a video's fused signal curve.
- If `segments` (a transcript) is provided, clip boundaries snap to whole sentences
- so each clip is a complete thought; without it, boundaries snap to audio lulls.
+ If a transcript is provided, clip boundaries snap to whole sentences so each clip
+ is a complete thought; `words` (with punctuation) gives true sentence edges and is
+ preferred over `segments`. Without any transcript, boundaries snap to audio lulls.
Returns clip dicts compatible with the render pipeline:
{title, start_second, end_second, duration, score, reasons, preview}.
"""
profile = get_profile(profile_name)
+ snap_units = sentences_from_words(words) if words else segments
if progress_callback:
progress_callback(10, "Analyzing audio energy...")
@@ -269,7 +297,7 @@ def detect_highlights(
peak_sec = i / GRID_HZ
reaction_level = float(reaction_curve[i]) if want_reaction else 0.0
start, end, is_reaction = _window_for_peak(
- peak_sec, reaction_level, profile, duration, energy_curve, min_dur, max_dur, segments
+ peak_sec, reaction_level, profile, duration, energy_curve, min_dur, max_dur, snap_units
)
if end - start < min_dur * 0.75:
continue