2023-06-03 21:21:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if which tput >/dev/null 2>&1; then
|
|
|
|
ncolors=$(tput colors)
|
|
|
|
fi
|
|
|
|
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
|
|
|
RED="$(tput setaf 1)"
|
|
|
|
GREEN="$(tput setaf 2)"
|
|
|
|
YELLOW="$(tput setaf 3)"
|
|
|
|
BLUE="$(tput setaf 4)"
|
|
|
|
MAGENTA="$(tput setaf 5)"
|
|
|
|
CYAN="$(tput setaf 6)"
|
|
|
|
BOLD="$(tput bold)"
|
|
|
|
NORMAL="$(tput sgr0)"
|
|
|
|
else
|
|
|
|
RED=""
|
|
|
|
GREEN=""
|
|
|
|
YELLOW=""
|
|
|
|
BLUE=""
|
|
|
|
MAGENTA=""
|
|
|
|
CYAN=""
|
|
|
|
BOLD=""
|
|
|
|
NORMAL=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
input_video="$1"
|
|
|
|
output_name_without_ext="$2"
|
2023-06-04 15:57:32 +00:00
|
|
|
shift 2
|
|
|
|
models="$@"
|
2023-06-03 21:21:16 +00:00
|
|
|
|
2023-06-04 15:57:32 +00:00
|
|
|
if [[ $input_video == "" || $output_name_without_ext == "" || $models == "" ]]; then
|
|
|
|
printf "${BOLD}${RED}Usage: $0 <input.wav> <output name without extension> <list of model names to use>${NORMAL}\n"
|
2023-06-03 21:21:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
wav_name="${output_name_without_ext}_audio_${RANDOM}"
|
|
|
|
|
|
|
|
# Add extension if not provided.
|
|
|
|
input_basename=$(basename -- "$wav_name")
|
|
|
|
input_extension="${input_basename##*.}"
|
|
|
|
if [[ input_extension != "wav" ]]; then
|
|
|
|
wav_name="${wav_name}.wav"
|
|
|
|
fi
|
|
|
|
|
|
|
|
extract-16bit-wav-from-video "$input_video" "$wav_name"
|
|
|
|
if [[ $? == 1 ]]; then exit 1; fi
|
|
|
|
|
2023-06-04 15:57:32 +00:00
|
|
|
for model in "$@"; do
|
|
|
|
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}"
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2023-06-03 21:21:16 +00:00
|
|
|
|
|
|
|
rm "$wav_name"
|
|
|
|
|