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/providers/index_tts.py

View on GitHub
"""Self-hosted index-tts JSON-to-WAV transport with no redirect forwarding."""

import contextlib
import io
import json
import os
import socket
import struct
import urllib.error
import urllib.parse
import urllib.request
import wave
from pathlib import Path


MAX_WAV_BYTES = 64 * 1024 * 1024
MAX_ERROR_BYTES = 512
SPEED_POLICY = "provider-default-no-rate-control"


class _SafeResponseError(RuntimeError):
    pass


class _NoRedirectHandler(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None


def _open_without_redirects(request, timeout):
    return urllib.request.build_opener(_NoRedirectHandler()).open(request, timeout=timeout)


def validate_index_tts_config(endpoint, voice):
    """Validate explicit private settings without returning a credential-bearing URL."""
    endpoint = str(endpoint or "")
    voice = str(voice or "").strip()
    if not endpoint:
        raise ValueError("INDEX_TTS_ENDPOINT 必须显式配置")
    if any(ord(char) < 32 or ord(char) == 127 for char in endpoint):
        raise ValueError("INDEX_TTS_ENDPOINT 配置无效或包含禁止字符")
    try:
        parsed = urllib.parse.urlsplit(endpoint)
        port = parsed.port
    except ValueError:
        raise ValueError("INDEX_TTS_ENDPOINT 配置无效") from None
    if parsed.scheme not in {"http", "https"} or not parsed.hostname:
        raise ValueError("INDEX_TTS_ENDPOINT 必须是带主机名的 http/https URL")
    if "@" in parsed.netloc or "?" in endpoint or "#" in endpoint:
        raise ValueError("INDEX_TTS_ENDPOINT 禁止 userinfo、query 或 fragment 携带凭证")
    if port is not None and not 1 <= port <= 65535:
        raise ValueError("INDEX_TTS_ENDPOINT 配置无效")
    if not voice:
        raise ValueError("INDEX_TTS_VOICE 必须显式配置")
    return endpoint, voice


def load_private_config(config, environ):
    """Read the private index-tts settings; validate them once, only when that provider is selected."""
    endpoint = environ.get("INDEX_TTS_ENDPOINT", "").strip()
    voice = environ.get("INDEX_TTS_VOICE", "").strip()
    if config["tts_provider"] == "index-tts":
        endpoint, voice = validate_index_tts_config(endpoint, voice)
    config["index_tts_endpoint"] = endpoint
    config["index_tts_voice"] = voice


def cache_settings(config):
    """Non-secret settings that decide reuse; the endpoint is never written to disk."""
    return {
        "index_tts_voice": config["index_tts_voice"],
        "index_tts_speed_policy": SPEED_POLICY,
    }


def default_controls(segment):
    unsupported = []
    for key, default in (("emotion", None), ("style", None), ("rate", "+0%"), ("pitch", "+0Hz")):
        if segment.get(key) not in (None, "", default):
            unsupported.append(key)
    if unsupported:
        raise RuntimeError(f"已配置的端点不接受段级控制字段: {', '.join(unsupported)}")
    return "+0%", "+0Hz"


def synthesize_configured(text, output_path, config):
    return synthesize_index_tts(
        text, output_path, endpoint=config["index_tts_endpoint"],
        voice=config["index_tts_voice"], timeout=config["tts_timeout"],
    )


def valid_cached_receipt(cache_data, config):
    """A cached index-tts segment must carry the receipt of a request for the current voice."""
    receipt = cache_data.get("provider_receipt")
    return isinstance(receipt, dict) and receipt == {
        "provider": "index-tts",
        "requested_voice": config["index_tts_voice"],
    }


def _discard_http_error_body(error):
    """Drain a bounded slice and close; the body is never surfaced (it may echo private URLs)."""
    with contextlib.suppress(Exception):
        try:
            error.read(MAX_ERROR_BYTES)
        finally:
            error.close()


def _validate_wav(audio):
    if len(audio) <= 44 or audio[:4] != b"RIFF" or audio[8:12] != b"WAVE":
        raise RuntimeError("IndexTTS 返回的内容不是有效 WAV")
    if int.from_bytes(audio[4:8], "little") + 8 > len(audio):
        raise RuntimeError("IndexTTS 返回的 RIFF 声明长度超过响应,音频被截断")
    try:
        with wave.open(io.BytesIO(audio), "rb") as wav:
            channels = wav.getnchannels()
            sample_width = wav.getsampwidth()
            sample_rate = wav.getframerate()
            frames = wav.getnframes()
            decoded = wav.readframes(frames)
    except (EOFError, wave.Error) as exc:
        # Support IEEE float (tag 3) or WAVE_FORMAT_EXTENSIBLE (0xFFFE -> 1/3) WAVs
        offset, fmt, decoded = 12, None, None
        while offset + 8 <= len(audio):
            cid = audio[offset:offset + 4]
            csize = int.from_bytes(audio[offset + 4:offset + 8], "little")
            bstart, bend = offset + 8, offset + 8 + csize
            if bend > len(audio):
                raise RuntimeError("IndexTTS 返回的 WAV 音频数据被截断") from exc
            if cid == b"fmt " and csize >= 16:
                ftag, channels, sample_rate, _, _, bits_per_sample = struct.unpack_from(
                    "<HHIIHH", audio, bstart
                )
                if ftag == 0xFFFE and csize >= 26:
                    ftag = struct.unpack_from("<H", audio, bstart + 24)[0]
                valid_fmt = (
                    (ftag == 1 and bits_per_sample in (8, 16, 24, 32))
                    or (ftag == 3 and bits_per_sample in (32, 64))
                )
                if not valid_fmt or channels < 1 or sample_rate < 1:
                    raise RuntimeError("IndexTTS 返回的 WAV 结构损坏或不受支持") from exc
                sample_width = bits_per_sample // 8
                fmt = True
            elif cid == b"data":
                decoded = audio[bstart:bend]
                break
            offset = bend + (csize & 1)
        if not fmt or decoded is None or channels < 1 or sample_rate < 1 or sample_width <= 0:
            raise RuntimeError("IndexTTS 返回的 WAV 结构损坏或不受支持") from exc
        frames = len(decoded) // (channels * sample_width)
    if not (1 <= channels <= 8 and 1 <= sample_width <= 8 and 8000 <= sample_rate <= 192000):
        raise RuntimeError("IndexTTS 返回的 WAV 音频参数越界")
    if frames <= 0:
        raise RuntimeError("IndexTTS 返回的 WAV 没有音频帧")
    if len(decoded) != frames * channels * sample_width:
        raise RuntimeError("IndexTTS 返回的 WAV 音频数据被截断")


def synthesize_index_tts(text, output_path, *, endpoint, voice, timeout):
    """POST the exact {voice,text} contract and atomically persist an authentic WAV.

    endpoint/voice were validated by load_private_config; timeout by lib's env_int."""
    body = json.dumps({"voice": voice, "text": text}, ensure_ascii=False).encode("utf-8")
    request = urllib.request.Request(
        endpoint,
        data=body,
        headers={
            "Content-Type": "application/json",
            "Accept": "audio/wav",
            "User-Agent": "video-recap/1.0",
        },
        method="POST",
    )
    try:
        with _open_without_redirects(request, timeout) as response:
            content_type = response.headers.get("Content-Type", "").lower()
            content_length = response.headers.get("Content-Length")
            if content_length and int(content_length) > MAX_WAV_BYTES:
                raise _SafeResponseError("IndexTTS 返回 WAV 过大,已拒绝读取")
            audio = response.read(MAX_WAV_BYTES + 1)
    except urllib.error.HTTPError as exc:
        _discard_http_error_body(exc)
        if 300 <= exc.code < 400:
            raise RuntimeError("IndexTTS 禁止 HTTP 重定向,未向其他主机发送待合成文本") from None
        raise RuntimeError(f"IndexTTS 请求失败 (HTTP {exc.code}),远端返回错误状态") from None
    except urllib.error.URLError as exc:
        kind = "超时" if isinstance(exc.reason, (TimeoutError, socket.timeout)) else "网络"
        raise RuntimeError(f"IndexTTS {kind}错误,未返回音频") from None
    except (TimeoutError, socket.timeout):
        raise RuntimeError("IndexTTS 超时错误,未返回音频") from None
    except ValueError:
        raise RuntimeError("IndexTTS 返回了无效的 Content-Length") from None
    except _SafeResponseError as exc:
        raise RuntimeError(str(exc)) from None
    except Exception:
        raise RuntimeError("IndexTTS 响应读取或关闭失败,未保存音频") from None

    if len(audio) > MAX_WAV_BYTES:
        raise RuntimeError("IndexTTS 返回 WAV 过大,已拒绝保存")
    if "json" in content_type:
        raise RuntimeError("IndexTTS 返回了 JSON 错误响应而不是音频;正文已隐藏")
    _validate_wav(audio)

    output = Path(output_path)
    partial = Path(str(output) + ".part")
    try:
        partial.write_bytes(audio)
        os.replace(partial, output)
    finally:
        partial.unlink(missing_ok=True)
    return {"provider": "index-tts", "requested_voice": voice}
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