Files
openclaw/bin/transcribe-audio
2026-03-01 17:44:19 +03:00

44 lines
996 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ]; then
echo "Использование: transcribe-audio <аудиофайл> [lang:auto|ru|en] [mode:txt|srt|json|all]"
exit 1
fi
AUDIO="$1"
LANG="${2:-auto}"
MODE="${3:-all}"
if [ ! -f "$AUDIO" ]; then
echo "Файл не найден: $AUDIO"
exit 1
fi
WHISPER_BIN="${WHISPER_BIN:-$HOME/.local/bin/whisper}"
MODEL="${WHISPER_MODEL:-$HOME/.cache/whisper-cpp/ggml-small.bin}"
OUT_BASE="${AUDIO%.*}"
FLAGS=( -m "$MODEL" -f "$AUDIO" -l "$LANG" -pp )
case "$MODE" in
txt)
"$WHISPER_BIN" "${FLAGS[@]}" -otxt -of "$OUT_BASE"
;;
srt)
"$WHISPER_BIN" "${FLAGS[@]}" -osrt -of "$OUT_BASE"
;;
json)
"$WHISPER_BIN" "${FLAGS[@]}" -oj -of "$OUT_BASE"
;;
all)
"$WHISPER_BIN" "${FLAGS[@]}" -otxt -osrt -oj -of "$OUT_BASE"
;;
*)
echo "Неизвестный режим: $MODE"
exit 1
;;
esac
echo "Готово. Результаты рядом с файлом: ${OUT_BASE}.txt/.srt/.json"