CtrlK
BlogDocsLog inGet started
Tessl Logo

jbaruch/speaker-toolkit

Seven-skill presentation system: ingest talks into a rhetoric vault, run interactive clarification, generate a speaker profile, create presentations that match your documented patterns, produce the deck illustrations + thumbnail visual layer, publish talk pages to a Jekyll shownotes site, and verify a recorded screencast against its storyboard. Includes a 113-entry Presentation Patterns taxonomy (83 observable: 64 patterns + 19 antipatterns; 30 unobservable: 21 patterns + 9 antipatterns) for scoring, brainstorming, and go-live preparation.

74

Quality

93%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

local_media_sampling.pyskills/vault-ingress/scripts/

"""Bounded audio clipping inside the authenticated ingress transcription worker.

The caller holds the admitted original descriptor and verifies its generation
around this operation. The parent owns the private workspace and its cleanup,
including timeout/kill paths. Only a decoded interval is materialized here;
source media is never changed. PCM byte count establishes actual clip duration.
"""

from __future__ import annotations

from dataclasses import dataclass
import hashlib
import os
from pathlib import Path
import shutil
import stat
from typing import Any
import wave

from artifact_supervisor import FileGeneration
from local_media_contract import LocalMediaError, refuse
from local_media_evidence import _inspect, _require_descriptor
from local_media_process import run_media_tool
from local_media_words import WORDS_MAX_SAMPLE_SECONDS, WORDS_MAX_SOURCE_SECONDS


SAMPLE_RATE = 16000
PCM_BYTES_PER_SECOND = SAMPLE_RATE * 2
SAMPLE_DIAGNOSTIC_BYTES = 64 * 1024
CHUNK_BYTES = 64 * 1024


@dataclass(frozen=True)
class SpeechClip:
    path: Path
    generation: FileGeneration
    sha256: str
    duration_seconds: float


def validate_sample_window(start: Any, duration: Any, source_duration: Any) -> None:
    if (
        type(source_duration) not in (int, float)
        or not 0 < source_duration <= WORDS_MAX_SOURCE_SECONDS
        or type(start) not in (int, float)
        or not 0 <= start < source_duration
        or type(duration) not in (int, float)
        or not 0 < duration <= WORDS_MAX_SAMPLE_SECONDS
        or start + duration > source_duration
    ):
        refuse("whisper_sample_window_invalid")


def extract_speech_clip(
    path: Path, workspace: Path, *, start: float, duration: float
) -> SpeechClip:
    """Worker-only: decode one bounded interval to private 16-kHz mono PCM/WAV."""
    validate_sample_window(start, duration, WORDS_MAX_SOURCE_SECONDS)
    ffmpeg = shutil.which("ffmpeg")
    if ffmpeg is None:
        refuse("media_dependency_unavailable")
    pcm, wav = workspace / "sample.pcm", workspace / "sample.wav"
    result = run_media_tool(
        [
            ffmpeg,
            "-nostdin",
            "-hide_banner",
            "-loglevel",
            "error",
            "-xerror",
            "-ss",
            str(start),
            "-i",
            str(path),
            "-t",
            str(duration),
            "-map",
            "0:a:0",
            "-vn",
            "-ac",
            "1",
            "-ar",
            str(SAMPLE_RATE),
            "-c:a",
            "pcm_s16le",
            "-f",
            "s16le",
            "pipe:1",
        ],
        stdout_limit=int(duration * PCM_BYTES_PER_SECOND) + 2,
        stderr_limit=SAMPLE_DIAGNOSTIC_BYTES,
        output=pcm,
        cwd=workspace,
    )
    if result.returncode or result.diagnostics.byte_count:
        refuse("whisper_sample_decode_failed")
    size = result.streamed_bytes
    actual_duration = size / PCM_BYTES_PER_SECOND
    if size <= 0 or size % 2 or abs(actual_duration - duration) > 1 / SAMPLE_RATE:
        refuse("whisper_sample_duration_mismatch")
    try:
        os.chmod(pcm, 0o600)
        with pcm.open("rb") as source, wav.open("xb") as output:
            os.chmod(wav, 0o600)
            with wave.open(output, "wb") as audio:
                audio.setnchannels(1)
                audio.setsampwidth(2)
                audio.setframerate(SAMPLE_RATE)
                audio.setnframes(size // 2)
                while chunk := source.read(CHUNK_BYTES):
                    audio.writeframesraw(chunk)
            output.flush()
            os.fsync(output.fileno())
        os.chmod(wav, stat.S_IREAD)
        generation = _inspect(wav, None).generation
        digest = hashlib.sha256()
        with wav.open("rb") as source:
            _require_descriptor(source.fileno(), generation)
            while chunk := source.read(CHUNK_BYTES):
                digest.update(chunk)
            _require_descriptor(source.fileno(), generation)
        if _inspect(wav, None).generation != generation:
            refuse("media_generation_changed")
    except (OSError, wave.Error) as exc:
        raise LocalMediaError("whisper_sample_decode_failed") from exc
    return SpeechClip(wav, generation, digest.hexdigest(), actual_duration)

skills

vault-ingress

scripts

adherence_baseline.py

aggregate-catalog-feedback.py

apply-source-repairs.py

artifact_locator.py

artifact_metadata.py

artifact_supervisor.py

audit-pattern-catalog.py

audit-persisted-pattern-observations.py

audit-source-identities.py

batch-download-videos.py

build-contact-sheet.py

build-crop-reviewer.py

build-score-basis.py

catalog_dimension_registry.py

catalog_io.py

catalog_normalization.py

check-runtime.py

classify-pptx-evidence.py

cloud_artifacts.py

cooperative_lock.py

crop_frames.py

crop-reviewer-shell.html

crop-reviewer-shell.html.txt

crop-reviewer.js

crop-reviewer.js.txt

establish-date-provenance.py

failure_diagnostics.py

fetch-transcript.py

ingress_contract.py

local_media_contract.py

local_media_download.py

local_media_evidence.py

local_media_process.py

local_media_sampling.py

local_media_transcription.py

local_media_words.py

markdown_deck.py

migrate-tracking-database.py

mutate-tracking-database.py

pattern_evidence.py

pdf_evidence.py

persist-results.py

persisted_pattern_observations.py

pptx_catalog_selection.py

pptx_deck_facts.py

pptx_discovery_contract.py

pptx_evidence.py

pptx_talk_identity.py

pptx-extraction.py

preflight-vault.py

queue_claim_contract.py

queue-state.py

read-tracking-database.py

render-markdown-deck.py

render-vault-status.py

retained_stage.py

return_validation.py

scan-shownotes.py

source_alias_contract.py

source_identity_matching.py

summary_lock.py

sweep-pptx-talk-identity.py

tracking_database_io.py

tracking_database.py

transcript_quality.py

transcript_timing.py

validate-returns.py

vault_root_authority.py

video_evidence.py

video_integrity.py

video-slide-extraction.py

vtt-cleanup.py

write-analysis.py

ytdlp_runtime.py

SKILL.md

README.md

tile.json