aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-17 14:36:47 +0100
committerDanilo M. <danix@danix.xyz>2026-11-17 14:36:47 +0100
commit82e74d8eb80ae5778b929e2074d2735d40f710ca (patch)
tree169846de917cfb021c4ee1a1f1278796b9ad3d8a /examples
parent27a673d4504b77b47986247cdaf3e3bd41f67c15 (diff)
downloaddesktop-assistant-82e74d8eb80ae5778b929e2074d2735d40f710ca.tar.gz
desktop-assistant-82e74d8eb80ae5778b929e2074d2735d40f710ca.zip
tools: video, collapse whisper's repeated words; live check
whisper turbo repeats words, often across two segments ("it's it's"), and loops over intro music: a word said twice in a row collapses to one, after the segments are joined. A transcript that fits the preview is labelled "full text"; the description forbids summarizing from the start alone. Live check findings in AGENTS.md: 0.18x real time on a real talk, stop kills whisper in 0.07 s, a summary works from the attached file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/tools/test-video.sh12
-rwxr-xr-xexamples/tools/video.sh13
-rw-r--r--examples/tools/video.toml2
3 files changed, 24 insertions, 3 deletions
diff --git a/examples/tools/test-video.sh b/examples/tools/test-video.sh
index 55a16d3..cca1aeb 100755
--- a/examples/tools/test-video.sh
+++ b/examples/tools/test-video.sh
@@ -73,6 +73,16 @@ check "own tmp removed" "$(command ls -d "$XDG_RUNTIME_DIR"/video-* | wc -l)" 1
out=$(v "$tmp/Hello Clip.mp4")
contains "collision" "$(head -1 <<<"$out")" "$ASSISTANT_DIR/hello-clip-2.md "
+# Words whisper repeats collapse; a stand-in whisper writes them.
+mkdir -p "$tmp/wbin"
+printf '%s\n' '#!/bin/bash' 'while [ $# -gt 0 ]; do [ "$1" = -of ] && of=$2; shift; done' \
+ "printf ' Revis Revis Revis Good morning.\\n three themes themes, running\\n running through it.\\n' > \"\$of.txt\"" \
+ > "$tmp/wbin/whisper-cli"
+chmod +x "$tmp/wbin/whisper-cli"
+PATH=$tmp/wbin:$PATH v "$tmp/Hello Clip.mp4" >/dev/null
+contains "dedupe" "$(cat "$ASSISTANT_DIR/hello-clip-3.md" 2>/dev/null)" \
+ "Revis Good morning. three themes, running through it."
+
# Refusals: one error line, exit 1, nothing written.
before=$(command ls "$ASSISTANT_DIR" | wc -l)
out=$(v "$tmp/silent.mkv"); check "no audio rc" $? 1
@@ -116,6 +126,7 @@ check "subs no note" "$(grep -c 'comment\|spans' <<<"$md")" 0
sed 's/$/\r/' "$tmp/it.vtt" > "$tmp/crlf.vtt"
out=$(STUB_META=$'125\tFalse\tNA\tCRLF' STUB_VTT="$tmp/crlf.vtt" v "https://example.org/v/9")
md=$(cat "$ASSISTANT_DIR/crlf.md" 2>/dev/null)
+contains "short full" "$out" $'\nfull text:\n'
contains "crlf text" "$md" 'Ciao a tutti & benvenuti Oggi parliamo di Slackware.'
check "crlf no cue ids" "$(grep -c '^[0-9] \| 2 ' <<<"$md")" 0
@@ -143,6 +154,7 @@ contains "no length, long" "$out" "long: Long reel, 31:00."
{ printf 'WEBVTT\n\n'; for i in $(seq 400); do printf '00:00:%02d.000 --> 00:00:%02d.500\nline number %d of the talk.\n\n' $((i % 60)) $((i % 60)) "$i"; done; } > "$tmp/big.vtt"
out=$(STUB_META=$'600\tFalse\ten\tBig Talk' STUB_VTT="$tmp/big.vtt" v "https://example.org/v/6")
contains "big path" "$(head -1 <<<"$out")" "big-talk.md (2400 words"
+contains "big start only" "$out" "start, not the whole text"
check "big under cap" "$(( ${#out} < 2000 ))" 1
para=$(awk 'NR > 5 && NF' "$ASSISTANT_DIR/big-talk.md" | head -1)
check "paragraph joined to a sentence end" "$(( ${#para} > 400 && ${#para} < 440 ))" 1
diff --git a/examples/tools/video.sh b/examples/tools/video.sh
index 1c34593..002c123 100755
--- a/examples/tools/video.sh
+++ b/examples/tools/video.sh
@@ -145,7 +145,12 @@ if [[ -z $text ]]; then
# whisper reads any container through ffmpeg. -ng: CPU, 8 threads beat 16.
whisper-cli -m "$MODEL" -ng -t 8 -l auto -np -otxt -of "$tmp/t" -f "$audio" \
>/dev/null 2>"$tmp/err" || die "whisper: $(tail -1 "$tmp/err")"
- text=$(sed 's/^[[:space:]]*//; /^$/d' "$tmp/t.txt" | paragraphs)
+ # turbo repeats words ("themes themes", "Revis Revis Revis" over music):
+ # a word said twice in a row collapses to one, after the join: a repeat
+ # often straddles two segments.
+ # ponytail: a real "very very" goes too; whisper's --vad may fix the cause.
+ text=$(sed 's/^[[:space:]]*//; /^$/d' "$tmp/t.txt" \
+ | paragraphs | sed -E "s/\b([[:alpha:]']+)([ ,]+\1\b)+/\1/g")
[[ -n $text ]] || die "no speech found"
how="whisper large-v3-turbo"
fi
@@ -166,5 +171,9 @@ mv "$tmp/out.md" "$out" || die "cannot write $out"
words=$(wc -w <<<"$text")
# The path first: the daemon cuts tool output at 2000 characters.
echo "transcript: $out ($words words, $(hms "$dur"), $how)"
-echo "start, not the whole text; to summarize or question it, the user attaches the file:"
+if (( ${#text} <= PREVIEW )); then
+ echo "full text:"
+else
+ echo "start, not the whole text; to summarize or question it, the user attaches the file:"
+fi
printf '%s\n' "${text:0:PREVIEW}"
diff --git a/examples/tools/video.toml b/examples/tools/video.toml
index 450669d..c9c227e 100644
--- a/examples/tools/video.toml
+++ b/examples/tools/video.toml
@@ -1,4 +1,4 @@
-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 30 minutes are refused until the user agrees: tell them the length and that it takes a few minutes, then call again with long=1."
+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. To summarize it or answer questions about it, the user must attach the file: never summarize or answer from the start alone. Videos over 30 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