Improve transcribe api and add alias to transcribe twitch stream downloads
This commit is contained in:
@@ -23,6 +23,23 @@ else
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
# Will return a symlink path in its expanded form. If the path's root is the
|
||||
# home directory symbol "~" then it'll be replaced by the full home path.
|
||||
expand_path() {
|
||||
local ret="$1"
|
||||
|
||||
IFS="/" read -ra parts <<< "$ret"
|
||||
if [[ "${parts[0]}" == "~" ]]; then
|
||||
ret="$HOME"
|
||||
for ((i=1; i < ${#parts[@]}; i++))
|
||||
do
|
||||
ret="$ret/${parts[$i]}"
|
||||
done
|
||||
fi
|
||||
ret=$(readlink -m "$ret")
|
||||
echo $ret
|
||||
}
|
||||
|
||||
input_wav="$1"
|
||||
output_name_without_ext="$2"
|
||||
model="$3"
|
||||
@@ -49,6 +66,14 @@ output_name="$output_name_without_ext.${model}"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | threads: $threads | output: $output_name ${NORMAL}\n"
|
||||
|
||||
whisper.exe --threads ${threads} -m $JELLYPIXEL_OPENSOURCE_DEV/whisper.cpp/models/ggml-${model}.en.bin -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors
|
||||
whisper_fullname="$(expand_path $(which whisper.exe))"
|
||||
whisper_path="$(dirname $whisper_fullname)"
|
||||
models_path="$whisper_path/models"
|
||||
|
||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
whisper.exe --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors
|
||||
error=$?
|
||||
if [[ error -eq 0 ]]; then
|
||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
else
|
||||
printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user