From 6e2c7ad2d5e376b286e910f29a8b3ce4e3b9d4f4 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 17 Nov 2026 11:48:15 +0100 Subject: docs: video transcript tool spec Output folder setting (out_dir in config.toml, edited in keystone, passed to tools as ASSISTANT_DIR), then a video tool: uploader subtitles or whisper large-v3-turbo on the CPU, transcript written as Markdown, the model gets the path and the start. Co-Authored-By: Claude Opus 5.5 --- .../specs/2026-11-17-video-transcript-design.md | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 docs/superpowers/specs/2026-11-17-video-transcript-design.md diff --git a/docs/superpowers/specs/2026-11-17-video-transcript-design.md b/docs/superpowers/specs/2026-11-17-video-transcript-design.md new file mode 100644 index 0000000..748d87f --- /dev/null +++ b/docs/superpowers/specs/2026-11-17-video-transcript-design.md @@ -0,0 +1,167 @@ +# Video transcript tool: design + +Date: 2026-11-17. Status: proposed. + +## Goal + +Ask the assistant to transcribe a video, local or a public URL (YouTube, +social media, any page yt-dlp can read), and get the transcript as a +Markdown file in the assistant's output folder. The model sees the start +and the path; to summarize or question the whole text, the user attaches +the file. + +Two parts: an output folder setting shared by the daemon, its tools and +the canvas, then the tool itself. + +## Part 1: output folder setting + +Today the canvas alone decides where written files go: +`$(xdg-user-dir DOCUMENTS)/Assistant`, falling back to +`~/Documents/Assistant` (`quickshell/desktop/assistant/Assistant.qml`). +Tools cannot see it. + +### Daemon (`assistant.py`) + +- `DEFAULTS["out_dir"] = ""`. Empty means `xdg-user-dir DOCUMENTS` + + `/Assistant`, and `~/Documents/Assistant` when that answers `$HOME` + (no documents folder set), the canvas's current rule. A set value must + be absolute, `~` expanded; anything else is refused at load like other + bad config values. +- Resolved once at startup into `CFG["out_dir"]`. Not created until + something writes there. +- `run_tool` adds `ASSISTANT_DIR=` to every tool's environment, + next to `CFG["env"]`. +- `hello` carries `out_dir`. + +### Keystone (quickshell repo) + +- `desktop/modules/assistant/AssistantPage.qml`: an "Output folder" text + field, `setKey("out_dir", quoted path)`, `null` when cleared. The + placeholder shows the XDG default. Applied at the daemon's next + restart, like every config key. +- `desktop/assistant/Assistant.qml`: `outDir` comes from `hello`; the + `xdg-user-dir` Process goes. One rule, in the daemon. + +### Check + +`--test`: default resolution, a configured value, a relative value +refused, `ASSISTANT_DIR` reaching a tool, `out_dir` in `hello`. + +## Part 2: the tool + +`examples/tools/video.toml` and `examples/tools/video.sh`, installed to +`~/.config/desktop-assistant/tools/`. + +```toml +description = "Transcribe the speech in a video, a local file or a public URL (YouTube, social media, web pages). Writes the full transcript to a Markdown file and opens it. Returns the file's path and the start of the text only: you have NOT read the whole transcript, so to summarize or answer questions about it, ask the user to attach the file. Videos over 20 minutes are refused until the user agrees: tell them the length and that it takes a few minutes, then call again with long=1." +command = ["video.sh", "{source}", "{long}"] +cloud = ["hetzner"] +timeout = 1800 + +[params.source] +type = "string" +description = "Absolute path of a local video, from its file block or the user's words, or an http(s) URL." + +[params.long] +type = "string" +description = "1 only after the user agreed to transcribe a video over 20 minutes; empty otherwise." +``` + +### Flow + +1. **Source.** An absolute existing path is local; `http://` or + `https://` is a URL; anything else is an error. URLs are passed to + yt-dlp as one argv element after `--`, never to a shell. +2. **Length and title.** Local: `ffprobe` duration, title is the file + name. URL: `yt-dlp --print duration --print title --no-playlist`. + Over 20 minutes without `long=1`: print `long: , <mm:ss>. + Ask the user before transcribing.` and exit 0, nothing written. + A source with no audio stream is an error. +3. **Subtitles first (URL only).** `yt-dlp --write-subs --sub-langs + 'it.*,en.*' --sub-format vtt --skip-download`: if the uploader + provided subtitles, their text (cue timings and markup stripped) is + the transcript, in seconds. Auto-generated subtitles are not used: + their rolling cues repeat every line, and whisper turbo is better. +4. **Audio.** URL: `yt-dlp -f bestaudio --no-playlist -o` into a fresh + `mktemp -d` under `$XDG_RUNTIME_DIR`, removed on exit (trap). Local: + the file itself. +5. **Transcribe.** `whisper-cli -m + /data/voice-models/whisper/ggml-large-v3-turbo-q5_0.bin -ng -t 8 -l auto + -np -otxt -of <tmp>/t -f <audio>`. whisper reads through ffmpeg, so + any container works; beam 5 is its default. + - **CPU, no GPU** (`-ng`): no VRAM, so it can never push the loaded + model out of the Arc or fail beside it. Measured 2026-11-17 on the + 9700X: a 120 s clip in 13.2 s wall (about 0.11x real time, so ~7 min + for an hour), ~1 GB RSS; a 10 s clip 10.6 s, mostly model load. + 8 threads beat 16 (11.98 s on the 10 s clip). + - Not the daemon's Gemma `input_audio` path: capped at 60 s by the + ubatch, so long audio needs cutting at silences, which can still + drift language between pieces; it needs an audio-capable model + loaded and holds llama-server for the whole run. +6. **Write.** `$ASSISTANT_DIR/<slug>.md`, slug from the title (lowercase, + `[a-z0-9-]`, 60 chars max), `-2`, `-3`... if taken. Content: + + ```markdown + # <title> + + Source: <path or URL> + Duration: <mm:ss>. Transcribed <date> with <whisper large-v3-turbo | uploader subtitles>. + + <text, one paragraph per whisper segment line> + ``` + + Opened with `xdg-open`, detached. +7. **Output.** Path line first, so `run_tool`'s 2000-character cap can + never cut it: + + ``` + transcript: <path> (<N> words, <mm:ss>, <source of text>) + start, not the whole text: + <first ~1500 characters> + ``` + +### Errors + +One line, nothing written: bad source, private or unavailable video +(yt-dlp's last stderr line), no audio stream, whisper failure, +unwritable output folder. Login-only videos are not supported: no +cookies are passed. + +### Daemon change: video attachments + +`kind_of` returns `video` for `video/*` MIME types. `attach()` adds only +`--- video: <name> (<abs path>) ---`, like an image block without the +image: the model gets the path for the tool, nothing else. Chip kind +`video`; the canvas shows an unknown kind as a plain file chip (to check). + +### Check + +`video.sh --test`, like `test-clone.sh`: a generated 5 s clip (`ffmpeg +-f lavfi` sine plus `flite` or a stored speech sample from outside the +repo) as mp4 and mkv; a source with no audio; a relative path; the +20-minute refusal on a fake duration; slug collisions; the output +starting with the path line. URL steps against a `file://` source are +not possible with yt-dlp's generic extractor rules, so they are covered +by the live check only. + +### Live check + +Through a second daemon on a scratch socket, config and data dir, Gemma: + +- A local video, it and en, "trascrivi questo video" with the file + attached and with the path typed. +- A YouTube video with uploader subtitles, one without, one over 20 + minutes (refused, asked, then done). +- A public video from one social site. +- Then attach the written file and ask for a summary. +- Measure: wall time per minute of a real single-language video on the + CPU (the 120 s measurement was a repeated it/en sample, whose last + 30 s window came out garbled from the mixed languages). + +## Not doing + +- Raising the 2000-character tool cap: the attach step covers it. Add a + per-tool `limit` key if the two steps get tedious. +- Auto-generated subtitles, cookies for login-only videos, playlists, + timestamps in the transcript, translation. +- Updating yt-dlp: packaging, `my-slackbuilds`. -- cgit v1.2.3