← Catalog

pi-transcribe

One transcribe() tool: speech in audio/video (talks, conversations, media URLs) becomes timestamped text. Two lanes (platform AI subtitles / local ASR), the calling model is the router. Fully local: no VLM, no cloud ASR. Not for video with…

Extension

Install

Install with PiG

pig install npm:pi-transcribe

Install with Pi

pi install npm:pi-transcribe
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./transcribe.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.2 (README.md). PiG does not review it.

English · 简体中文

pi-transcribe

One transcribe() tool (npm package pi-transcribe): speech in audio or video — talks, conversations, media URLs — becomes timestamped text. Two lanes, the calling model is the router. Fully local: no VLM, no cloud ASR. Video without speech is out of scope (NO SPEECH DETECTED, not a description).

Renamed from pi-hear (now deprecated on npm); the config file was renamed too — see Install.

transcribe(source)                source = URL → AI subtitles first (instant,
                                        quality UNVERIFIED — model judges);
                                 source = local file → local ASR
transcribe(source, mode="asr")     ffmpeg → 16k mono → engine, timestamps forced
transcribe(source, mode="subtitle") force subtitle lane (URL only)

Lanes

LaneEngineCostNotes
subtitleyt-dlp subs~seconds (network)Bilibili AI subs (ai-zh) need login cookies and ride the regular subtitles flag (--write-subs); both subs flags are on, so YouTube-style auto-subs work too. Quality unverified — the calling model reads the first ~200 chars before trusting
asr (default engine)SenseVoiceSmall + fsmn-vad stitchingRTF 0.04–0.07 @ 4 threads, CPUzh/yue/en/ja/ko; punctuation + ITN built in; no native timestamps → VAD stitching (validated)
asr (engine=whisper)faster-whisper (optional install)est. RTF 0.1–0.3native timestamps; keeps English loanwords better

Engine trade-off (fixture-judged): pure Chinese → sensevoice; mixed zh/en technical speech → whisper ("CodeReview" comes out as "coded review" under sensevoice). No overall winner — switchable via config.

Install

# 1) analyzer deps — install into a Python venv (torch MUST come from the CPU
#    index: the PyPI linux default bundles gigabytes of CUDA you don't need)
uv pip install -p ~/.virtualenvs/main/bin/python -r scripts/requirements.txt
uv pip install -p ~/.virtualenvs/main/bin/python "torch==2.9.1" \
    --index-url https://download.pytorch.org/whl/cpu

# 2) the extension
pi install npm:pi-transcribe

(scripts/requirements.txt ships in the npm package next to transcribe.ts; run step 1 from the repo, or from the installed package dir.)

Or try it once without persisting:

pi -e git:github.com/codelllc09/pi-transcribe

System deps (not pip): ffmpeg/ffprobe, yt-dlp.

Config ~/.pi/agent/pi-transcribe.json (all keys optional; the legacy pi-hear.json is read when the new file is absent):

{
  "engine": "sensevoice",
  "whisperModel": "small",
  "device": "cpu",          // "cuda" puts ASR on GPU; VAD stays CPU (benchmarked split)
  "threads": 4,
  "language": "zh",
  "gapMs": 800,             // VAD stitch: merge utterances with gaps below this
  "maxSegS": 30,            // VAD stitch: force-split segments longer than this
  "pythonPath": "~/.virtualenvs/main/bin/python",
  "cookiesFile": "~/secrets/bilibili-cookies.txt",  // member-only sources
  "proxy": "http://127.0.0.1:7897"                   // plumbed to yt-dlp
}

Design

  • Pure measurement: verbatim transcripts, no semantic judgment — subtitle quality checks belong to the calling model, corrections belong to the downstream pipeline.
  • SenseVoice has no native timestamps → millisecond VAD boundaries + forced splits (> maxSegS) + gap merging (< gapMs) + batched transcription + stitching. Timestamps must exist and be monotonic (test-enforced).
  • ASR is CPU-heavy: roughly 3–6 min per hour of audio at 4 threads — the tool description orders the model to warn the user with a duration×RTF estimate before long media.
  • Long transcripts render truncated (> 12k chars); a .transcript.md artifact is written next to local sources with a 50-segment preview. Batch/production work should use a batch pipeline, not this interactive tool.
  • No-speech media (silent screen demos, music-only) is a normal result: NO SPEECH DETECTED + empty segments, exit 0 — the caller model must go visual, not retry. SenseVoice is not even loaded (VAD decides alone).
  • Visual frames are out of scope — ffmpeg sampling + look composes.

Validated against a cross-engine fixture (see tests/fixtures/MANIFEST.md).

License

MIT — see LICENSE.