Skip to content

zenstory-ai/video-recap-skills / skills/video-recap

video-recap

Verified

把一段或多集视频做成带画框字幕的中文解说成片或纯原声高光短片。用户提供 .mp4 / .mov / .mkv / .webm,要求做影视解说、短剧二创、加旁白配音、跨集混剪或导出剪映草稿时使用;串联完成看片识台词、定主线与留原声、按台词停顿切镜头、写词检查、TTS 配音与混音加字幕。触发词:视频解说、影视解说、视频旁白、生成解说、视频 recap、video recap、voiceover、narration、recap。

FileKindSize
SKILL.mdskill md18.4 KB
assets/dashboard/app.jsscript16.2 KB
assets/dashboard/index.htmlother867 B
assets/dashboard/styles.cssother22.6 KB
assets/dashboard/tokens.cssother8.9 KB
assets/dashboard/views.jsscript31.4 KB
references/audio-modes.mdmarkdown3.6 KB
references/config-playbook.mdmarkdown8.1 KB
references/creative-editing-playbook.mdmarkdown12.3 KB
references/data-schema.mdmarkdown34.6 KB
references/index-tts.mdmarkdown2.1 KB
references/jianying/LICENSE.duo-videoother1.0 KB
references/jianying/SOURCE.mdmarkdown703 B
references/jianying/empty_draft_meta_info.jsonconfig1.7 KB
references/jianying/empty_jy_material_video.jsonconfig1.8 KB
references/jianying/empty_jy_meta_material_value.jsonconfig358 B
references/jianying/empty_jy_project_info.jsonconfig3.6 KB
references/jianying/empty_jy_segment.jsonconfig1.3 KB
references/jianying/empty_jy_text_styles.jsonconfig440 B
references/jianying/empty_yj_material_audio.jsonconfig865 B
references/jianying/empty_yj_material_text.jsonconfig2.4 KB
references/packaging.mdmarkdown6.8 KB
references/promotional-copy.mdmarkdown4.1 KB
references/prompt-templates.mdmarkdown2.0 KB
references/research-guide.mdmarkdown2.7 KB
references/resource-library.mdmarkdown12.1 KB
references/shot-review.mdmarkdown4.8 KB
scripts/agent_text.pyscript2.7 KB
scripts/artifacts.pyscript972 B
scripts/asr.pyscript12.5 KB
scripts/asr_timing_evidence.pyscript4.2 KB
scripts/assemble.pyscript31.0 KB
scripts/assemble_constants.pyscript894 B
scripts/assembly_contract.pyscript10.3 KB
scripts/assembly_settings.pyscript3.8 KB
scripts/audio_automation.pyscript6.6 KB
scripts/audio_mix.pyscript18.5 KB
scripts/briefing/__init__.pyscript101 B
scripts/briefing/builder.pyscript31.1 KB
scripts/briefing/context.pyscript6.1 KB
scripts/briefing/timeline.pyscript23.0 KB
scripts/codec_peak.pyscript5.1 KB
scripts/cut.pyscript148 B
scripts/cut_cli.pyscript12.4 KB
scripts/cut_contract.pyscript13.3 KB
scripts/cut_qc.pyscript1.9 KB
scripts/cut_render.pyscript13.2 KB
scripts/dashboard/__init__.pyscript159 B
scripts/dashboard/data.pyscript24.6 KB
scripts/dashboard/io.pyscript7.1 KB
scripts/dashboard/runs.pyscript21.8 KB
scripts/dashboard/templates.pyscript9.6 KB
scripts/dashboard_server.pyscript9.3 KB
scripts/detect.pyscript22.2 KB
scripts/doctor.pyexecutablescript12.9 KB
scripts/entry_suggestion.pyscript4.6 KB
scripts/export_jianying.pyscript5.6 KB
scripts/extract.pyscript2.5 KB
scripts/final_qc.pyscript19.0 KB
scripts/frame_grid.pyscript10.6 KB
scripts/jianying/__init__.pyscript49 B
scripts/jianying/builders.pyscript11.3 KB
scripts/jianying/model.pyscript2.7 KB
scripts/jianying/optional.pyscript1012 B
scripts/jianying/schema.pyscript2.5 KB
scripts/jianying/templates.pyscript1.0 KB
scripts/jianying/timeline_contract.pyscript5.8 KB
scripts/jianying/tracks.pyscript2.0 KB
scripts/jianying/writer.pyscript7.8 KB
scripts/lib.pyscript29.6 KB
scripts/library.pyscript31.1 KB
scripts/lint_summary.pyscript5.0 KB
scripts/loudness.pyscript14.7 KB
scripts/materials.pyscript22.1 KB
scripts/media.pyscript18.8 KB
scripts/narration_audio.pyscript13.5 KB
scripts/narration_lint.pyscript24.1 KB
scripts/narrative_selection.pyscript8.9 KB
scripts/packaging.pyscript6.1 KB
scripts/packaging_fonts.pyscript12.0 KB
scripts/packaging_plates.pyscript31.2 KB
scripts/packaging_studio.pyscript34.1 KB
scripts/providers/__init__.pyscript72 B
scripts/providers/fish_audio.pyscript3.1 KB
scripts/providers/index_tts.pyscript8.8 KB
scripts/recap.pyscript183 B
scripts/recap_cli.pyscript6.9 KB
scripts/recap_inspect.pyscript16.5 KB
scripts/recap_runner.pyscript22.0 KB
scripts/recap_runtime.pyscript11.8 KB
scripts/recap_source.pyscript1.8 KB
scripts/recap_stage_qc.pyscript2.7 KB
scripts/recap_timeline.pyscript7.7 KB
scripts/render_preflight.pyscript1.7 KB
scripts/resources/__init__.pyscript200 B
scripts/resources/lock.pyscript6.8 KB
scripts/resources/project_binding.pyscript16.1 KB
scripts/sentence_boundaries.pyscript28.8 KB
scripts/sentence_gate.pyscript8.6 KB
scripts/sfx_mix.pyscript14.6 KB
scripts/shot_review.pyscript18.9 KB
scripts/source_subtitles.pyscript7.2 KB
scripts/speech_ownership.pyscript9.3 KB
scripts/storyboard.pyscript21.8 KB
scripts/subtitles/__init__.pyscript56 B
scripts/subtitles/core.pyscript19.0 KB
scripts/subtitles/render.pyscript8.0 KB
scripts/timeline.pyscript8.2 KB
scripts/timeline_emit.pyscript5.4 KB
scripts/tts_audio.pyscript9.6 KB
scripts/tts_cache.pyscript4.5 KB
scripts/understand.pyscript171 B
scripts/understanding_brief.pyscript6.3 KB
scripts/understanding_cache.pyscript8.0 KB
scripts/understanding_runner.pyscript9.8 KB
scripts/understanding_storyboard.pyscript11.9 KB
scripts/validate.pyscript5.7 KB
scripts/visual_render.pyscript10.1 KB
scripts/vlm.pyscript16.4 KB
scripts/voiceover.pyscript28.0 KB

scripts/speech_ownership.py

View on GitHub
"""Load measured source-speech evidence and classify narration ownership."""

import json
import re
from pathlib import Path

from lib import CONFIG, file_identity


def _empty_evidence(mode):
    return {
        "anchors": [],
        "speech_spans": [],
        "dialogue_spans": [],
        "quiet_windows": [],
        "require_measured": mode == "cut_output",
    }


# Interjections and common ASR artifacts on screams/music. A window whose text is only these
# is not dialogue at a clip edge or narration entry; real short lines such as "救我!" still are.
# Shared across cut, script validation and assemble within video-recap.
_NON_DIALOGUE_TOKENS = frozenset(
    "啊 嗯 哼 哦 呃 唉 嘿 呦 哈 呀 hi yeah ok okay oh uh ah hmm".split()
)
_NON_DIALOGUE_CJK = frozenset("啊嗯哼哦呃唉嘿呦哈呀")
# Lines cross 15s ASR window edges (a line may run 13.2–15.4 while its window ends at 15.0),
# so an interjection-only window next to real dialogue keeps this much of its shared edge.
_INTERJECTION_GUARD_SECONDS = 1.0


def _interjection_only(text):
    tokens = [token for token in re.split(r"[\W_]+", text.lower()) if token]
    # Punctuation-only rows ("……", "?") are often ASR for unintelligible speech: keep them.
    return bool(tokens) and all(
        token in _NON_DIALOGUE_TOKENS or set(token) <= _NON_DIALOGUE_CJK for token in tokens
    )


def _dialogue_speech_spans(rows):
    """Merged dialogue spans from timed ASR rows.

    A row holding only interjections ("啊!", "Hi.") is not dialogue, except a
    `_INTERJECTION_GUARD_SECONDS` guard on an edge it shares with a dialogue row. A row
    whose text is empty or whitespace (ASR heard no words) is timing-only evidence: it is
    skipped here and guards nothing. A row with no `text` field is measured timing whose
    words are unknown and counts as dialogue.
    """
    rows = sorted(
        (
            {
                "start": row["start"],
                "end": row["end"],
                "dialogue": not _interjection_only(row.get("text", "")),
            }
            for row in rows
            if "text" not in row or row["text"].strip()
        ),
        key=lambda row: (row["start"], row["end"]),
    )
    spans = []
    for idx, row in enumerate(rows):
        if row["dialogue"]:
            spans.append({"start": row["start"], "end": row["end"]})
            continue
        before = rows[idx - 1] if idx > 0 else None
        after = rows[idx + 1] if idx + 1 < len(rows) else None
        if before and before["dialogue"] and row["start"] - before["end"] <= 0.05:
            end = min(row["end"], row["start"] + _INTERJECTION_GUARD_SECONDS)
            spans.append({"start": row["start"], "end": end})
        if after and after["dialogue"] and after["start"] - row["end"] <= 0.05:
            start = max(row["start"], row["end"] - _INTERJECTION_GUARD_SECONDS)
            spans.append({"start": start, "end": row["end"]})
    spans.sort(key=lambda row: (row["start"], row["end"]))
    merged = []
    for span in spans:
        if merged and span["start"] <= merged[-1]["end"] + 0.05:
            merged[-1]["end"] = max(merged[-1]["end"], span["end"])
        else:
            merged.append(span)
    return merged


def _read_json(path):
    """JSON artifact, or None when the optional file was never written."""
    return json.loads(path.read_text(encoding="utf-8")) if path.exists() else None


def _source_asr_rows(work_dir):
    """Raw asr_result.json, the one transcript lint, cut and assemble verdicts read.

    Blank-text rows are timing-only evidence (ASR heard no words) and are not source speech.
    """
    rows = _read_json(work_dir / "asr_result.json")
    return [row for row in rows or [] if row["text"].strip()]


def _output_payload_is_current(payload, work_dir):
    plan_path = Path(work_dir) / "clip_plan_validated.json"
    return (
        payload is not None
        and plan_path.exists()
        and payload["clip_plan_identity"] == file_identity(plan_path)
    )


def anchor_boundary_use(anchor):
    """`boundary_use` (schema 2) keeps coarse-ASR estimates usable as `unverified`; schema-1
    anchors (no `boundary_use`) were all coarse estimates: high/medium are `unverified`."""
    return anchor.get("boundary_use") or (
        "unverified" if anchor["confidence"] in {"high", "medium"} else "none"
    )


def load_source_sentence_evidence(work_dir, mode="full"):
    """Load sentence boundaries plus speech/quiet spans on the narration clock."""
    if work_dir is None:
        return _empty_evidence(mode)
    work_dir = Path(work_dir)
    if mode == "full":
        payload = _read_json(work_dir / "speech_boundary_anchors.json") or {
            "sentence_anchors": []
        }
        speech_spans = _source_asr_rows(work_dir)
        asr_evidence = _read_json(work_dir / "asr_timing_evidence.json") or {}
        asr_result_ok = True
        if isinstance(asr_evidence, dict) and "asr_result" in asr_evidence:
            expected_res = asr_evidence.get("asr_result")
            res_path = work_dir / "asr_result.json"
            asr_result_ok = (
                isinstance(expected_res, dict)
                and res_path.is_file()
                and dict(expected_res) == file_identity(res_path)
            )
        speech_absent = (
            isinstance(asr_evidence, dict)
            and asr_result_ok
            and asr_evidence.get("status") == "NO_AUDIO_STREAM"
        )
        if speech_absent:
            quiet_windows = [{"start": 0.0, "end": 1e9, "has_speech": False}]
        else:
            quiet_windows = [
                row
                for row in _read_json(work_dir / "silence_periods.json") or []
                if not row["has_speech"]
            ]
    else:
        payload = _read_json(work_dir / "speech_boundary_anchors_output.json")
        if not _output_payload_is_current(payload, work_dir):
            return _empty_evidence(mode)
        speech_spans = payload["speech_spans"]
        quiet_windows = payload["quiet_windows"]
        speech_absent = bool(payload.get("speech_absent")) and not speech_spans
    anchors = [
        anchor for anchor in payload["sentence_anchors"] if anchor_boundary_use(anchor) != "none"
    ]
    return {
        "anchors": sorted(anchors, key=lambda item: item["time"]),
        "speech_spans": speech_spans,
        # Entry ownership only: an interjection-only window has no sentence to interrupt.
        "dialogue_spans": _dialogue_speech_spans(speech_spans),
        "quiet_windows": quiet_windows,
        "require_measured": mode == "cut_output",
        "speech_absent": speech_absent,
    }


def _merged_intervals(start, end, rows):
    intervals = sorted(
        (max(start, row["start"]), min(end, row["end"]))
        for row in rows
        if row["end"] > start and row["start"] < end
    )
    merged = []
    for left, right in intervals:
        if right <= left:
            continue
        if merged and left <= merged[-1][1]:
            merged[-1] = (merged[-1][0], max(merged[-1][1], right))
        else:
            merged.append((left, right))
    return merged


def _interval_overlap(start, end, rows):
    return sum(right - left for left, right in _merged_intervals(start, end, rows))


def _speech_overlap_excluding_quiet(start, end, speech, quiet):
    speech_intervals = _merged_intervals(start, end, speech)
    quiet_intervals = _merged_intervals(start, end, quiet)
    overlap = sum(right - left for left, right in speech_intervals)
    for speech_left, speech_right in speech_intervals:
        overlap -= sum(
            max(0.0, min(speech_right, quiet_right) - max(speech_left, quiet_left))
            for quiet_left, quiet_right in quiet_intervals
        )
    return max(0.0, overlap)


def segment_overlaps_source_speech(seg, evidence):
    """Classify aggregate mix ownership across the complete narration interval."""
    if evidence.get("speech_absent"):
        return False
    start, end = seg["start"], seg["end"]
    quiet = evidence["quiet_windows"]
    quiet_min = max(0.3, (end - start) * CONFIG["quiet_overlap_min_ratio"])
    speech = evidence["speech_spans"]
    if speech:
        return _speech_overlap_excluding_quiet(start, end, speech, quiet) > 0.05
    if quiet and _interval_overlap(start, end, quiet) >= quiet_min:
        return False
    if evidence["anchors"] or evidence["require_measured"]:
        return True
    return bool(seg.get("overlaps_speech", True))


def entry_overlaps_source_speech(start, evidence, *, authored_overlap=True, tolerance=0.05):
    """Classify the entry instant; later quiet time cannot erase an unsafe start."""
    if evidence.get("speech_absent"):
        return False
    if any(
        row["start"] - tolerance <= start <= row["end"] + tolerance
        for row in evidence["quiet_windows"]
    ):
        return False
    if any(
        row["start"] - tolerance <= start < row["end"] - tolerance
        for row in evidence["dialogue_spans"]
    ):
        return True
    if evidence["speech_spans"]:
        return False
    if evidence["anchors"] or evidence["require_measured"]:
        return True
    return bool(authored_overlap)


def measure_narration_speech_ownership(narration, work_dir, mode="full"):
    """Return narration copies with aggregate ownership derived from evidence."""
    evidence = load_source_sentence_evidence(work_dir, mode=mode)
    return [
        {**seg, "overlaps_speech": segment_overlaps_source_speech(seg, evidence)}
        for seg in narration
    ]
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 196kUpdated Claude CodeCodexVerifiedInstall