mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge branch 'main' into feature_interactive_mode
This commit is contained in:
13 files changed
+246
-69
No files matched your search
@@ -1,9 +1,10 @@
|
||||
[](https://discord.gg/rYz9wsxYYK)
|
||||
[](https://colab.research.google.com/github/rakuri255/UltraSinger/blob/master/colab/UltraSinger.ipynb)
|
||||

|
||||
|
||||

|
||||
[](https://github.com/rakuri255/UltraSinger/blob/main/LICENSE)
|
||||
[](https://www.codefactor.io/repository/github/rakuri255/ultrasinger)
|
||||
|
||||
[](https://github.com/rakuri255/UltraSinger/actions/workflows/main.yml)
|
||||
[](https://github.com/rakuri255/UltraSinger/actions/workflows/pytest.yml)
|
||||
[](https://hub.docker.com/r/rakuri255/ultrasinger)
|
||||
@@ -104,14 +105,19 @@ _Not all options working now!_
|
||||
## if INPUT is ultrastar.txt ##
|
||||
default Creates all
|
||||
|
||||
[separation]
|
||||
# Default is htdemucs
|
||||
--demucs Model name htdemucs|htdemucs_ft|htdemucs_6s|hdemucs_mmi|mdx|mdx_extra|mdx_q|mdx_extra_q >> ((default) is htdemucs)
|
||||
|
||||
[transcription]
|
||||
# Default is whisper
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2|large-v3 >> ((default) is large-v2)
|
||||
English-only model > tiny.en|base.en|small.en|medium.en
|
||||
--whisper_align_model Use other languages model for Whisper provided from huggingface.co
|
||||
--language Override the language detected by whisper, does not affect transcription but steps after transcription
|
||||
--whisper_batch_size Reduce if low on GPU mem >> ((default) is 16)
|
||||
--whisper_compute_type Change to "int8" if low on GPU mem (may reduce accuracy) >> ((default) is "float16" for cuda devices, "int8" for cpu)
|
||||
--keep_numbers Numbers will be transcribed as numerics instead of as words
|
||||
|
||||
[pitcher]
|
||||
# Default is crepe
|
||||
@@ -119,24 +125,23 @@ _Not all options working now!_
|
||||
--crepe_step_size unit is miliseconds >> ((default) is 10)
|
||||
|
||||
[extra]
|
||||
--hyphenation Use automatic hyphenation > True|False >> ((default) is True)
|
||||
--disable_separation Disable track separation > True|False >> ((default) is False)
|
||||
--disable_karaoke True|False >> ((default) is False)
|
||||
--ignore_audio True|False >> ((default) is False)
|
||||
--create_audio_chunks True|False >> ((default) is False)
|
||||
--keep_cache Keep cache folder after generation > True|False >> ((default) is False)
|
||||
--plot Create a pitch plot > True|False >> ((default) is False)
|
||||
--disable_hyphenation Disable word hyphenation. Hyphenation is enabled by default.
|
||||
--disable_separation Disable track separation. Track separation is enabled by default.
|
||||
--disable_karaoke Disable creation of karaoke style txt file. Karaoke is enabled by default.
|
||||
--create_audio_chunks Enable creation of audio chunks. Audio chunks are disabled by default.
|
||||
--keep_cache Keep cache folder after creation. Cache folder is removed by default.
|
||||
--plot Enable creation of plots. Plots are disabled by default.
|
||||
--format_version 0.3.0|1.0.0|1.1.0|1.2.0 >> ((default) is 1.2.0)
|
||||
--musescore_path path to MuseScore executable
|
||||
--keep_numbers Transcribe numbers as digits and not words > True|False >> ((default) is False)
|
||||
--keep_numbers Transcribe numbers as digits and not words
|
||||
|
||||
[yt-dlp]
|
||||
--cookiefile File name where cookies should be read from
|
||||
|
||||
[device]
|
||||
--force_cpu True|False >> ((default) is False) All steps will be forced to cpu
|
||||
--force_whisper_cpu True|False >> ((default) is False) Only whisper will be forced to cpu
|
||||
--force_crepe_cpu True|False >> ((default) is False) Only crepe will be forced to cpu
|
||||
--force_cpu Force all steps to be processed on CPU.
|
||||
--force_whisper_cpu Only whisper will be forced to cpu
|
||||
--force_crepe_cpu Only crepe will be forced to cpu
|
||||
```
|
||||
|
||||
For standard use, you only need to use [opt]. All other options are optional.
|
||||
@@ -160,7 +165,7 @@ default (Full Automatic Mode) - Creates all, depending on command line options
|
||||
##### Youtube
|
||||
|
||||
```commandline
|
||||
-i https://www.youtube.com/watch?v=BaW_jenozKc
|
||||
-i https://www.youtube.com/watch?v=YwNs1Z0qRY0
|
||||
```
|
||||
|
||||
Note that if you run into a yt-dlp error such as `Sign in to confirm you’re not a bot. This helps protect our community` ([yt-dlp issue](https://github.com/yt-dlp/yt-dlp/issues/10128)) you can follow these steps:
|
||||
@@ -204,10 +209,10 @@ Example for romanian:
|
||||
Is on by default. Can also be deactivated if hyphenation does not produce
|
||||
anything useful. Note that the word is simply split,
|
||||
without paying attention to whether the separated word really
|
||||
starts at the place or is heard.
|
||||
starts at the place or is heard. To disable:
|
||||
|
||||
```commandline
|
||||
-i XYZ --hyphenation True
|
||||
-i XYZ --disable_hyphenation
|
||||
```
|
||||
|
||||
### 👂 Pitcher
|
||||
@@ -227,7 +232,7 @@ The vocals are separated from the audio before they are passed to the models. If
|
||||
you have the option to disable this function; in which case the original audio file is used instead.
|
||||
|
||||
```commandline
|
||||
-i XYZ --disable_separation True
|
||||
-i XYZ --disable_separation
|
||||
```
|
||||
|
||||
### Sheet Music
|
||||
|
||||
+5
-1
@@ -1,8 +1,12 @@
|
||||
# Version: 0.0.13dev1
|
||||
# Version: 0.0.13dev2
|
||||
Date: 2024.12.22
|
||||
- Changes:
|
||||
- Download Cover from MusicBrainz
|
||||
- Fix selection of whisper model
|
||||
- Added colab notebook
|
||||
- Optimized whisper language check with confidence
|
||||
- Improved arguments, so you dont need to use true or false
|
||||
- Added interactive mode
|
||||
|
||||
# Version: 0.0.12
|
||||
Date: 2024.12.19
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": [],
|
||||
"gpuType": "T4"
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
},
|
||||
"accelerator": "GPU"
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Hki_kX_kSbZX"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%cd /content\n",
|
||||
"!git clone https://github.com/rakuri255/UltraSinger.git\n",
|
||||
"%cd /content/UltraSinger\n",
|
||||
"!pip install --no-cache-dir -r requirements.txt\n",
|
||||
"!pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121\n",
|
||||
"!pip install --no-cache-dir tensorflow[and-cuda]==2.17.1\n",
|
||||
"%cd /content/UltraSinger/src"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!python UltraSinger.py -i https://www.youtube.com/watch?v=YwNs1Z0qRY0 -o /content/output"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "O0j4vUW0YAG2"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
@echo off
|
||||
setlocal
|
||||
cd ..
|
||||
cd ..
|
||||
py -3.10 -m venv .venv
|
||||
call .venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2
|
||||
SET VenvPythonPath=%CD%\.venv\Scripts\python.exe
|
||||
call %VenvPythonPath% -m pip install -r requirements.txt
|
||||
call %VenvPythonPath% -m pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2
|
||||
endlocal
|
||||
@@ -1,7 +1,9 @@
|
||||
@echo off
|
||||
setlocal
|
||||
cd ..
|
||||
cd ..
|
||||
py -3.10 -m venv .venv
|
||||
call .venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2+cu117 --index-url https://download.pytorch.org/whl/cu117
|
||||
SET VenvPythonPath=%CD%\.venv\Scripts\python.exe
|
||||
call %VenvPythonPath% -m pip install -r requirements.txt
|
||||
call %VenvPythonPath% -m pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2+cu117 --index-url https://download.pytorch.org/whl/cu117
|
||||
endlocal
|
||||
+2
-1
@@ -30,4 +30,5 @@ music21
|
||||
unidecode
|
||||
dataclasses
|
||||
dataclasses_json
|
||||
num2words
|
||||
num2words
|
||||
inputimeout
|
||||
+5
-1
@@ -71,7 +71,9 @@ contourpy==1.2.1
|
||||
crepe==0.0.15
|
||||
# via -r requirements.in
|
||||
ctranslate2==4.4.0
|
||||
# via faster-whisper
|
||||
# via
|
||||
# faster-whisper
|
||||
# whisperx
|
||||
cycler==0.12.1
|
||||
# via matplotlib
|
||||
dataclasses==0.6
|
||||
@@ -166,6 +168,8 @@ imageio==2.34.2
|
||||
# via crepe
|
||||
iniconfig==2.0.0
|
||||
# via pytest
|
||||
inputimeout==1.0.4
|
||||
# via -r requirements.in
|
||||
isort==5.13.2
|
||||
# via
|
||||
# -r requirements.in
|
||||
|
||||
+3
-1
@@ -10,7 +10,9 @@ from modules.Ultrastar.ultrastar_txt import FormatVersion
|
||||
@dataclass_json
|
||||
@dataclass
|
||||
class Settings:
|
||||
APP_VERSION = "0.0.13-dev1"
|
||||
APP_VERSION = "0.0.13-dev2"
|
||||
CONFIDENCE_THRESHOLD = 0.6
|
||||
CONFIDENCE_PROMPT_TIMEOUT = 4
|
||||
|
||||
create_midi = True
|
||||
create_plot = False
|
||||
|
||||
+58
-27
@@ -17,6 +17,8 @@ from modules.Audio.vocal_chunks import (
|
||||
create_audio_chunks_from_ultrastar_data,
|
||||
)
|
||||
from modules.Audio.silence_processing import remove_silence_from_transcription_data, mute_no_singing_parts
|
||||
from modules.Speech_Recognition.Whisper import WhisperModel
|
||||
from modules.Audio.separation import DemucsModel
|
||||
|
||||
from modules.Audio.convert_audio import convert_audio_to_mono_wav, convert_wav_to_mp3
|
||||
from modules.Audio.youtube import (
|
||||
@@ -29,7 +31,8 @@ from modules.console_colors import (
|
||||
gold_highlighted,
|
||||
red_highlighted,
|
||||
green_highlighted,
|
||||
cyan_highlighted
|
||||
cyan_highlighted,
|
||||
bright_green_highlighted,
|
||||
)
|
||||
from modules.Midi.midi_creator import (
|
||||
create_midi_segments_from_transcribed_data,
|
||||
@@ -135,7 +138,20 @@ def run() -> tuple[str, Score, Score]:
|
||||
"""The processing function of this program"""
|
||||
#List selected options (can add more later)
|
||||
if settings.keep_numbers:
|
||||
print(f"{ULTRASINGER_HEAD} {cyan_highlighted('Option:')} Numbers will be transcribed as numerics (i.e. 1, 2, 3, etc.)")
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Numbers will be transcribed as numerics (i.e. 1, 2, 3, etc.)')}")
|
||||
if settings.create_plot:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Plot will be created')}")
|
||||
if settings.keep_cache:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Cache folder will not be deleted')}")
|
||||
if settings.create_audio_chunks:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Audio chunks will be created')}")
|
||||
if not settings.create_karaoke:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Karaoke txt will not be created')}")
|
||||
if not settings.use_separated_vocal:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Vocals will not be separated')}")
|
||||
if not settings.hyphenation:
|
||||
print(f"{ULTRASINGER_HEAD} {bright_green_highlighted('Option:')} {cyan_highlighted('Hyphenation will not be applied')}")
|
||||
|
||||
process_data = InitProcessData()
|
||||
|
||||
process_data.process_data_paths.cache_folder_path = (
|
||||
@@ -143,7 +159,7 @@ def run() -> tuple[str, Score, Score]:
|
||||
if settings.cache_override_path is None
|
||||
else settings.cache_override_path
|
||||
)
|
||||
|
||||
|
||||
# Create process audio
|
||||
process_data.process_data_paths.processing_audio_path = CreateProcessAudio(process_data)
|
||||
|
||||
@@ -197,7 +213,7 @@ def run() -> tuple[str, Score, Score]:
|
||||
# Cleanup
|
||||
if not settings.keep_cache:
|
||||
remove_cache_folder(process_data.process_data_paths.cache_folder_path)
|
||||
|
||||
|
||||
# Print Support
|
||||
print_support()
|
||||
return ultrastar_file_output, simple_score, accurate_score
|
||||
@@ -598,7 +614,13 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
settings.output_folder_path = arg
|
||||
elif opt in ("--whisper"):
|
||||
settings.transcriber = "whisper"
|
||||
settings.whisper_model = WhisperModel(arg)
|
||||
|
||||
#Addition of whisper model choice. Added error handling for unknown models.
|
||||
try:
|
||||
settings.whisper_model = WhisperModel(arg)
|
||||
except ValueError as ve:
|
||||
print(f"{ULTRASINGER_HEAD} The model {arg} is not a valid whisper model selection. Please use one of the following models: {blue_highlighted(', '.join([m.value for m in WhisperModel]))}")
|
||||
sys.exit()
|
||||
elif opt in ("--whisper_align_model"):
|
||||
settings.whisper_align_model = arg
|
||||
elif opt in ("--whisper_batch_size"):
|
||||
@@ -606,7 +628,7 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
elif opt in ("--whisper_compute_type"):
|
||||
settings.whisper_compute_type = arg
|
||||
elif opt in ("--keep_numbers"):
|
||||
settings.keep_numbers = arg in ["True", "true"]
|
||||
settings.keep_numbers = True
|
||||
elif opt in ("--language"):
|
||||
settings.language = arg
|
||||
elif opt in ("--crepe"):
|
||||
@@ -614,27 +636,27 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
elif opt in ("--crepe_step_size"):
|
||||
settings.crepe_step_size = int(arg)
|
||||
elif opt in ("--plot"):
|
||||
settings.create_plot = arg in ["True", "true"]
|
||||
settings.create_plot = True
|
||||
elif opt in ("--midi"):
|
||||
settings.create_midi = arg in ["True", "true"]
|
||||
elif opt in ("--hyphenation"):
|
||||
settings.hyphenation = eval(arg.title())
|
||||
settings.create_midi = True
|
||||
elif opt in ("--disable_hyphenation"):
|
||||
settings.hyphenation = False
|
||||
elif opt in ("--disable_separation"):
|
||||
settings.use_separated_vocal = not arg
|
||||
settings.use_separated_vocal = False
|
||||
elif opt in ("--disable_karaoke"):
|
||||
settings.create_karaoke = not arg
|
||||
settings.create_karaoke = False
|
||||
elif opt in ("--create_audio_chunks"):
|
||||
settings.create_audio_chunks = arg
|
||||
elif opt in ("--ignore_audio"):
|
||||
settings.ignore_audio = arg in ["True", "true"]
|
||||
settings.ignore_audio = True
|
||||
elif opt in ("--force_cpu"):
|
||||
settings.force_cpu = arg
|
||||
settings.force_cpu = True
|
||||
if settings.force_cpu:
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
||||
elif opt in ("--force_whisper_cpu"):
|
||||
settings.force_whisper_cpu = eval(arg.title())
|
||||
settings.force_whisper_cpu = True
|
||||
elif opt in ("--force_crepe_cpu"):
|
||||
settings.force_crepe_cpu = eval(arg.title())
|
||||
settings.force_crepe_cpu = True
|
||||
elif opt in ("--format_version"):
|
||||
if arg == FormatVersion.V0_3_0.value:
|
||||
settings.format_version = FormatVersion.V0_3_0
|
||||
@@ -649,10 +671,17 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
f"{ULTRASINGER_HEAD} {red_highlighted('Error: Format version')} {blue_highlighted(arg)} {red_highlighted('is not supported.')}"
|
||||
)
|
||||
sys.exit(1)
|
||||
elif opt in ("--keep_cache"):
|
||||
settings.keep_cache = arg
|
||||
elif opt in ("--keep_cache"):
|
||||
settings.keep_cache = True
|
||||
elif opt in ("--musescore_path"):
|
||||
settings.musescore_path = arg
|
||||
#Addition of demucs model choice. Work seems to be needed to make sure syntax is same for models. Added error handling for unknown models
|
||||
elif opt in ("--demucs"):
|
||||
try:
|
||||
settings.demucs_model = DemucsModel(arg)
|
||||
except ValueError as ve:
|
||||
print(f"{ULTRASINGER_HEAD} The model {arg} is not a valid demucs model selection. Please use one of the following models: {blue_highlighted(', '.join([m.value for m in DemucsModel]))}")
|
||||
sys.exit()
|
||||
elif opt in ("--cookiefile"):
|
||||
settings.cookiefile = arg
|
||||
elif opt in ("--interactive"):
|
||||
@@ -670,6 +699,7 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
return settings
|
||||
|
||||
|
||||
#For convenience, made True/False options into noargs
|
||||
def arg_options():
|
||||
short = "hi:o:amv:"
|
||||
long = [
|
||||
@@ -685,20 +715,21 @@ def arg_options():
|
||||
"language=",
|
||||
"plot=",
|
||||
"midi=",
|
||||
"hyphenation=",
|
||||
"disable_separation=",
|
||||
"disable_karaoke=",
|
||||
"create_audio_chunks=",
|
||||
"disable_hyphenation",
|
||||
"disable_separation",
|
||||
"disable_karaoke",
|
||||
"create_audio_chunks",
|
||||
"ignore_audio=",
|
||||
"force_cpu=",
|
||||
"force_whisper_cpu=",
|
||||
"force_crepe_cpu=",
|
||||
"force_cpu",
|
||||
"force_whisper_cpu",
|
||||
"force_crepe_cpu",
|
||||
"format_version=",
|
||||
"keep_cache=",
|
||||
"musescore_path=",
|
||||
"cookiefile=",
|
||||
"keep_numbers=",
|
||||
"interactive"
|
||||
"interactive",
|
||||
"keep_numbers",
|
||||
"cookiefile="
|
||||
]
|
||||
return long, short
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Whisper Speech Recognition Module"""
|
||||
|
||||
import sys
|
||||
|
||||
import inspect
|
||||
import textwrap
|
||||
import torch
|
||||
import whisperx
|
||||
from enum import Enum
|
||||
@@ -52,6 +51,24 @@ def number_to_words(line,language='en'):
|
||||
out_tokens.append(token)
|
||||
return ''.join(out_tokens)
|
||||
|
||||
def replace_code_lines(source, start_token, end_token,
|
||||
replacement, escape_tokens=True):
|
||||
"""Replace the source code between `start_token` and `end_token`
|
||||
in `source` with `replacement`. The `start_token` portion is included
|
||||
in the replaced code. If `escape_tokens` is True (default),
|
||||
escape the tokens to avoid them being treated as a regular expression."""
|
||||
|
||||
if escape_tokens:
|
||||
start_token = re.escape(start_token)
|
||||
end_token = re.escape(end_token)
|
||||
|
||||
def replace_with_indent(match):
|
||||
indent = match.group(1)
|
||||
return textwrap.indent(replacement, indent)
|
||||
|
||||
return re.sub(r"^(\s+)({}[\s\S]+?)(?=^\1{})".format(start_token, end_token),
|
||||
replace_with_indent, source, flags=re.MULTILINE)
|
||||
|
||||
def transcribe_with_whisper(
|
||||
audio_path: str,
|
||||
model: WhisperModel,
|
||||
@@ -63,6 +80,59 @@ def transcribe_with_whisper(
|
||||
keep_numbers: bool = False,
|
||||
) -> TranscriptionResult:
|
||||
"""Transcribe with whisper"""
|
||||
# Info: Monkey Patch FasterWhisperPipeline.detect_language to include error handling for low confidence
|
||||
src = textwrap.dedent(inspect.getsource(whisperx.asr.FasterWhisperPipeline.detect_language))
|
||||
# Replace the relevant part of the method
|
||||
start_token = "if audio.shape[0] < N_SAMPLES:"
|
||||
end_token = "return language"
|
||||
replacement = """\
|
||||
#Added imports
|
||||
from modules.console_colors import ULTRASINGER_HEAD, blue_highlighted, red_highlighted
|
||||
from Settings import Settings
|
||||
from inputimeout import inputimeout, TimeoutOccurred
|
||||
#End Import addition
|
||||
if audio.shape[0] < N_SAMPLES:
|
||||
print("Warning: audio is shorter than 30s, language detection may be inaccurate.")
|
||||
model_n_mels = self.model.feat_kwargs.get("feature_size")
|
||||
segment = log_mel_spectrogram(audio[: N_SAMPLES],
|
||||
n_mels=model_n_mels if model_n_mels is not None else 80,
|
||||
padding=0 if audio.shape[0] >= N_SAMPLES else N_SAMPLES - audio.shape[0])
|
||||
encoder_output = self.model.encode(segment)
|
||||
results = self.model.model.detect_language(encoder_output)
|
||||
language_token, language_probability = results[0][0]
|
||||
language = language_token[2:-2]
|
||||
print(f"Detected language: {language} ({language_probability:.2f}) in first 30s of audio...")
|
||||
#Added handling for low detection probability
|
||||
if language_probability < Settings.CONFIDENCE_THRESHOLD:
|
||||
print(f"{ULTRASINGER_HEAD} {red_highlighted('Warning:')} Language detection probability for detected language {language} is below {Settings.CONFIDENCE_THRESHOLD}, results may be inaccurate.")
|
||||
print(f"{ULTRASINGER_HEAD} Override the language below or re-run with parameter {blue_highlighted('--language xx')} to specify the song language...")
|
||||
try:
|
||||
response = inputimeout(
|
||||
prompt=f"{ULTRASINGER_HEAD} Do you want to continue with {language} (default) or override with another language (y)? (y/n): ",
|
||||
timeout=Settings.CONFIDENCE_PROMPT_TIMEOUT
|
||||
).strip().lower()
|
||||
except TimeoutOccurred:
|
||||
import locale
|
||||
print(f"{ULTRASINGER_HEAD} No user input received in {Settings.CONFIDENCE_PROMPT_TIMEOUT} seconds. Attempting automatic override with system locale.")
|
||||
print(f"{ULTRASINGER_HEAD} Trying to get language from default locale...")
|
||||
current_locale = locale.getlocale()
|
||||
if current_locale[0]:
|
||||
language_code = current_locale[0][:2].strip().lower()
|
||||
print(f"{ULTRASINGER_HEAD} Found language code: {language_code} in locale. Setting language to {blue_highlighted(language_code)}...")
|
||||
language = language_code
|
||||
else:
|
||||
print(f"{ULTRASINGER_HEAD} No locale is set.")
|
||||
response = 'n'
|
||||
language_response = response == 'y'
|
||||
if language_response:
|
||||
language = input(f"{ULTRASINGER_HEAD} Please enter the language code for the language you want to use (e.g. 'en', 'de', 'es', etc.): ").strip().lower()
|
||||
#End addition
|
||||
"""
|
||||
new_src = replace_code_lines(src, start_token, end_token, replacement)
|
||||
# Compile it and execute it in the target module's namespace
|
||||
exec(compile(new_src, "<string>", "exec"), whisperx.asr.__dict__)
|
||||
whisperx.asr.FasterWhisperPipeline.detect_language = whisperx.asr.detect_language
|
||||
#End Monkey Patch
|
||||
|
||||
# Info: Regardless of the audio sampling rate used in the original audio file, whisper resample the audio signal to 16kHz (via ffmpeg). So the standard input from (44.1 or 48 kHz) should work.
|
||||
|
||||
|
||||
+15
-10
@@ -27,9 +27,14 @@ def print_help() -> None:
|
||||
## INPUT is ultrastar.txt ##
|
||||
default Creates all
|
||||
|
||||
|
||||
[separation]
|
||||
# Default is htdemucs
|
||||
--demucs Model name htdemucs|htdemucs_ft|htdemucs_6s|hdemucs_mmi|mdx|mdx_extra|mdx_q|mdx_extra_q >> ((default) is htdemucs)
|
||||
|
||||
[transcription]
|
||||
# Default is whisper
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2|large-v3 >> ((default) is large-v2)
|
||||
English-only model > tiny.en|base.en|small.en|medium.en
|
||||
--whisper_align_model Use other languages model for Whisper provided from huggingface.co
|
||||
--language Override the language detected by whisper, does not affect transcription but steps after transcription
|
||||
@@ -43,12 +48,12 @@ def print_help() -> None:
|
||||
--crepe_step_size unit is miliseconds >> ((default) is 10)
|
||||
|
||||
[extra]
|
||||
--hyphenation Use automatic hyphenation > True|False >> ((default) is True)
|
||||
--disable_separation Disable track separation > True|False >> ((default) is False)
|
||||
--disable_karaoke True|False >> ((default) is False)
|
||||
--create_audio_chunks True|False >> ((default) is False)
|
||||
--keep_cache Keep cache folder after generation > True|False >> ((default) is False)
|
||||
--plot Create a pitch plot > True|False >> ((default) is False)
|
||||
--disable_hyphenation Disable word hyphenation. Hyphenation is enabled by default.
|
||||
--disable_separation Disable track separation. Track separation is enabled by default.
|
||||
--disable_karaoke Disable creation of karaoke style txt file. Karaoke is enabled by default.
|
||||
--create_audio_chunks Enable creation of audio chunks. Audio chunks are disabled by default.
|
||||
--keep_cache Keep cache folder after creation. Cache folder is removed by default.
|
||||
--plot Enable creation of plots. Plots are disabled by default.
|
||||
--format_version 0.3.0|1.0.0|1.1.0|1.2.0 >> ((default) is 1.2.0)
|
||||
--musescore_path path to MuseScore executable
|
||||
|
||||
@@ -56,9 +61,9 @@ def print_help() -> None:
|
||||
--cookiefile File name where cookies should be read from and dumped to.
|
||||
|
||||
[device]
|
||||
--force_cpu True|False >> ((default) is False) All steps will be forced to cpu
|
||||
--force_whisper_cpu True|False >> ((default) is False) Only whisper will be forced to cpu
|
||||
--force_crepe_cpu True|False >> ((default) is False) Only crepe will be forced to cpu
|
||||
--force_cpu Force all steps to be processed on CPU.
|
||||
--force_whisper_cpu Force whisper transcription to be processed on CPU.
|
||||
--force_crepe_cpu Force crepe pitch detection to be processed on CPU.
|
||||
"""
|
||||
print(help_string)
|
||||
|
||||
|
||||
@@ -32,11 +32,13 @@ def red_highlighted(text: str) -> str:
|
||||
"""Returns a red highlighted text"""
|
||||
return f"{Bcolors.red}{text}{Bcolors.endc}"
|
||||
|
||||
|
||||
def cyan_highlighted(text: str) -> str:
|
||||
"""Returns a cyan highlighted text"""
|
||||
return f"{Bcolors.cyan}{text}{Bcolors.endc}"
|
||||
|
||||
def bright_green_highlighted(text: str) -> str:
|
||||
"""Returns a cyan highlighted text"""
|
||||
return f"{Bcolors.bright_green}{text}{Bcolors.endc}"
|
||||
|
||||
class Bcolors:
|
||||
"""Colors for the console"""
|
||||
@@ -49,3 +51,4 @@ class Bcolors:
|
||||
gold = "\033[93m"
|
||||
underline = "\033[4m"
|
||||
endc = "\033[0m"
|
||||
bright_green = "\033[38;2;204;255;204m"
|
||||
@@ -3,7 +3,7 @@ import string
|
||||
from Levenshtein import ratio
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from src.Settings import Settings
|
||||
from Settings import Settings
|
||||
|
||||
from modules.console_colors import ULTRASINGER_HEAD, blue_highlighted, red_highlighted
|
||||
|
||||
|
||||
Reference in new issue
Block a user