From 589abb9e465d2ca9eea5c019838d2435266ca3ac Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Mon, 12 Jun 2023 22:49:45 -0400 Subject: [PATCH] Tweak whisper core/thread count --- bin/transcribe-audio | 16 ++++++++++++---- bin/transcribe-video | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/transcribe-audio b/bin/transcribe-audio index f2be8c4..34ef892 100644 --- a/bin/transcribe-audio +++ b/bin/transcribe-audio @@ -71,16 +71,24 @@ fi output_name="$output_name_without_ext.${model}" -printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | threads: $threads | output: $output_name ${NORMAL}\n" + +# 1 core 31 threads has very fast pcm_to_mel conversion and then just one core doing most of the work. You get more accurate results this way. +# 2 core 16 is about half the time but it can have errors where the two pieces come together. This only gets more likely as the core count is increased. +# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium. + +threads=31 #keep a thread for me +cores=1 + +printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n" whisper_fullname="$(expand_path $(which whisper.exe))" whisper_path="$(dirname $whisper_fullname)" models_path="$whisper_path/models" -whisper.exe --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors +whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress error=$? if [[ error -eq 0 ]]; then - printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | threads: $threads | output: $output_name${NORMAL}\n" + printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | 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" + printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n" fi diff --git a/bin/transcribe-video b/bin/transcribe-video index b300b10..871831f 100644 --- a/bin/transcribe-video +++ b/bin/transcribe-video @@ -29,7 +29,7 @@ shift 2 models=("$@") if [[ $input_video == "" || $output_name_without_ext == "" || ${#models[@]} -eq 0 ]]; then - printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi