- added option to force cpu for separation and whisper

This commit is contained in:
Vadim committed 2023-05-22 21:40:06 +02:00
1 parent b3c9bb235e
commit 7e978a2814
3 files changed
+17 -5

No files matched your search

+4
View File
@@ -61,6 +61,8 @@ _Not all options working now!_
--disable_separation True|False >> ((default) is False)
--disable_karaoke True|False >> ((default) is False)
--create_audio_chunks True|False >> ((default) is False)
--force_whisper_cpu True|False >> ((default) is False)
--force_separation_cpu True|False >> ((default) is False)
[pitcher]
# Default is crepe full
@@ -190,3 +192,5 @@ When you want to use `conda` instead you need a different installation command.
If somthing crash because of low VRAM than use a smaller model.
Whisper needs more than 8GB VRAM in the `large` model!
But you can force cpu usage with the extra options `--force_whisper_cpu` and `--force_separation_cpu`.
+4 -2
View File
@@ -15,7 +15,7 @@ class Settings:
# Whisper
transcriber = 'whisper' # whisper|vosk
whisper_model = 'large' # Multilingual model tiny|base|small|medium|large
whisper_model = 'large' # Multilingual model tiny|base|small|medium|large
# English-only model tiny.en|base.en|small.en|medium.en
# Vosk
@@ -26,5 +26,7 @@ class Settings:
crepe_step_size = 10
# Device
device = 'cpu' # cpu|cuda|gpu
device = 'cpu' # cpu|cuda
force_whisper_cpu = False
force_separation_cpu = False
+9 -3
View File
@@ -280,8 +280,9 @@ def run():
def transcribe_audio(transcribed_data):
if settings.transcriber == "whisper":
device = "cpu" if settings.force_whisper_cpu else settings.device
transcribed_data, language = transcribe_with_whisper(settings.mono_audio_path, settings.whisper_model,
settings.device)
device)
else: # vosk
transcribed_data = transcribe_with_vosk(settings.mono_audio_path, settings.vosk_model_path)
# todo: make language selectable
@@ -291,8 +292,9 @@ def transcribe_audio(transcribed_data):
def separate_vocal_from_audio(basename_without_ext, cache_path, ultrastar_audio_input_path):
audio_separation_path = os.path.join(cache_path, "separated", "htdemucs", basename_without_ext)
device = "cpu" if settings.force_separation_cpu else settings.device
if settings.use_separated_vocal or settings.create_karaoke:
separate_audio(ultrastar_audio_input_path, cache_path, settings.device)
separate_audio(ultrastar_audio_input_path, cache_path, device)
if settings.use_separated_vocal:
vocals_path = os.path.join(audio_separation_path, "vocals.wav")
convert_audio_to_mono_wav(vocals_path, settings.mono_audio_path)
@@ -433,7 +435,7 @@ def main(argv):
def init_settings(argv):
short = "hi:o:amv:"
long = ["ifile=", "ofile=", "crepe=", "vosk=", "whisper=", "hyphenation=", "disable_separation=",
"disable_karaoke=", "create_audio_chunks="]
"disable_karaoke=", "create_audio_chunks=", "force_whisper_cpu=", "force_separation_cpu="]
opts, args = getopt.getopt(argv, short, long)
if len(opts) == 0:
print_help()
@@ -462,6 +464,10 @@ def init_settings(argv):
settings.create_karaoke = not arg
elif opt in ("--create_audio_chunks"):
settings.create_audio_chunks = arg
elif opt in ("--force_whisper_cpu"):
settings.force_whisper_cpu = arg
elif opt in ("--force_separation_cpu"):
settings.force_separation_cpu = arg
if settings.output_file_path == '':
if settings.input_file_path.startswith('https:'):
dirname = os.getcwd()