aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tools/video.sh
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tools/video.sh')
-rwxr-xr-xexamples/tools/video.sh13
1 files changed, 11 insertions, 2 deletions
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}"