mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge branch 'refs/heads/main' into user-defined-ffmpeg
# Conflicts: # src/Settings.py # src/UltraSinger.py
This commit is contained in:
commit
8fd3096c70
5 files changed
+198
-7
No files matched your search
@@ -94,7 +94,8 @@ _Not all options working now!_
|
||||
|
||||
[mode]
|
||||
## if INPUT is audio ##
|
||||
default Creates all
|
||||
default (Full Automatic Mode) - Creates all, depending on command line options
|
||||
--interactive - Interactive Mode. All options are asked at runtime for easier configuration
|
||||
|
||||
# Single file creation selection is in progress, you currently getting all!
|
||||
(-u Create ultrastar txt file) # In Progress
|
||||
@@ -148,6 +149,12 @@ For standard use, you only need to use [opt]. All other options are optional.
|
||||
|
||||
### 🎶 Input
|
||||
|
||||
### Mode
|
||||
default (Full Automatic Mode) - Creates all, depending on command line options
|
||||
--interactive - Interactive Mode. All options are asked at runtime for easier configuration
|
||||
```commandline
|
||||
--interactive
|
||||
```
|
||||
#### Audio (full automatic)
|
||||
|
||||
##### Local file
|
||||
|
||||
@@ -24,6 +24,7 @@ class Settings:
|
||||
ignore_audio = False
|
||||
input_file_is_ultrastar_txt = False # todo: to process_data
|
||||
keep_cache = False
|
||||
interactive_mode = False
|
||||
user_ffmpeg_path = ""
|
||||
|
||||
# Process data Paths
|
||||
|
||||
+8
-3
@@ -9,6 +9,7 @@ import Levenshtein
|
||||
from packaging import version
|
||||
|
||||
from modules import os_helper
|
||||
from modules.init_interactive_mode import init_settings_interactive
|
||||
from modules.Audio.denoise import denoise_vocal_audio
|
||||
from modules.Audio.separation import separate_vocal_from_audio
|
||||
from modules.Audio.vocal_chunks import (
|
||||
@@ -349,7 +350,7 @@ def InitProcessData():
|
||||
|
||||
elif settings.input_file_path.startswith("https:"):
|
||||
# Youtube
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('full automatic mode')}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('Full Automatic Mode')}")
|
||||
process_data = ProcessData()
|
||||
(
|
||||
process_data.basename,
|
||||
@@ -359,7 +360,7 @@ def InitProcessData():
|
||||
) = download_from_youtube(settings.input_file_path, settings.output_folder_path, settings.cookiefile)
|
||||
else:
|
||||
# Audio File
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('full automatic mode')}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('Full Automatic Mode')}")
|
||||
process_data = ProcessData()
|
||||
(
|
||||
process_data.basename,
|
||||
@@ -586,6 +587,8 @@ def main(argv: list[str]) -> None:
|
||||
print_version(settings.APP_VERSION)
|
||||
init_settings(argv)
|
||||
check_requirements()
|
||||
if settings.interactive_mode:
|
||||
init_settings_interactive(settings)
|
||||
run()
|
||||
sys.exit()
|
||||
|
||||
@@ -698,6 +701,8 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
sys.exit()
|
||||
elif opt in ("--cookiefile"):
|
||||
settings.cookiefile = arg
|
||||
elif opt in ("--interactive"):
|
||||
settings.interactive_mode = True
|
||||
elif opt in ("--ffmpeg"):
|
||||
settings.user_ffmpeg_path = arg
|
||||
if settings.output_folder_path == "":
|
||||
@@ -738,11 +743,11 @@ def arg_options():
|
||||
"keep_cache=",
|
||||
"musescore_path=",
|
||||
"keep_numbers",
|
||||
"interactive",
|
||||
"cookiefile=",
|
||||
"ffmpeg="
|
||||
]
|
||||
return long, short
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
@@ -16,7 +16,8 @@ def print_help() -> None:
|
||||
|
||||
[mode]
|
||||
## INPUT is audio ##
|
||||
default Creates all
|
||||
default (Full Automatic Mode) - Creates all, depending on command line options
|
||||
--interactive - Interactive Mode. All options are asked at runtime for easier configuration
|
||||
|
||||
# Single file creation selection is in progress, you currently getting all!
|
||||
(-u Create ultrastar txt file) # In Progress
|
||||
@@ -85,7 +86,9 @@ def print_support() -> None:
|
||||
|
||||
def print_version(app_version: str) -> None:
|
||||
"""Print version text"""
|
||||
versiontext = (f"UltraSinger Version: {app_version}")
|
||||
starquant = "*" * len(versiontext) # set star number to length of version
|
||||
print()
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('*****************************')}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted(starquant)}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('UltraSinger Version:')} {light_blue_highlighted(app_version)}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted('*****************************')}")
|
||||
print(f"{ULTRASINGER_HEAD} {gold_highlighted(starquant)}")
|
||||
@@ -0,0 +1,175 @@
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from Settings import Settings
|
||||
from modules.Audio.separation import DemucsModel
|
||||
from modules.Speech_Recognition.Whisper import WhisperModel
|
||||
from modules.DeviceDetection.device_detection import check_gpu_support
|
||||
|
||||
import os
|
||||
|
||||
def get_input_file(console, settings, header):
|
||||
while True:
|
||||
input_file = console.input(f"{header} Enter the path to the input file ([green]audio file[/green], [green]Ultrastar txt[/green], or [green]YouTube URL[/green]): ").strip()
|
||||
if input_file:
|
||||
settings.input_file_path = input_file
|
||||
print(settings.input_file_path)
|
||||
break
|
||||
else:
|
||||
console.print(f"{header} [bold red]Error:[/bold red] Input file cannot be empty. Please try again.\n")
|
||||
|
||||
def get_output_folder(console, settings, header):
|
||||
output_folder = console.input(f"{header} Enter the output folder path (leave empty for default '[green]output[/green]' folder): ").strip()
|
||||
if output_folder:
|
||||
settings.output_folder_path = output_folder
|
||||
else:
|
||||
dirname = os.getcwd() if settings.input_file_path.startswith("https:") else os.path.dirname(settings.input_file_path)
|
||||
settings.output_folder_path = os.path.join(dirname, "output")
|
||||
|
||||
def select_model(console, header, model_enum, model_type, default_model):
|
||||
models = [model.value for model in model_enum]
|
||||
console.print(f"\n{header} [bold underline]Available {model_type} Models:[/bold underline]\n")
|
||||
|
||||
num_columns = 4
|
||||
table = Table(show_header=False, show_edge=False, padding=(0, 2))
|
||||
for _ in range(num_columns):
|
||||
table.add_column()
|
||||
|
||||
items = [f"[bright_green]{idx}.[/bright_green] {model_name}" for idx, model_name in enumerate(models, start=1)]
|
||||
rows = [items[i:i + num_columns] for i in range(0, len(items), num_columns)]
|
||||
for row in rows:
|
||||
row += [""] * (num_columns - len(row))
|
||||
table.add_row(*row)
|
||||
console.print(table)
|
||||
|
||||
while True:
|
||||
choice = console.input(f"\n{header} Enter the [green]{model_type} model[/green] number corresponding to your choice (1-{len(models)}), or leave empty for default ([cyan]{default_model.value}[/cyan]): ").strip()
|
||||
if not choice:
|
||||
return default_model
|
||||
elif choice.isdigit() and 1 <= int(choice) <= len(models):
|
||||
return model_enum(models[int(choice) - 1])
|
||||
else:
|
||||
console.print(f"{header} [bold red]Error:[/bold red] Invalid choice. Please select a valid number.\n")
|
||||
|
||||
def configure_additional_options(console, settings, header):
|
||||
additional_options_input = console.input(
|
||||
f"\n{header} Do you want to configure [green]additional options[/green]? "
|
||||
f"([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower()
|
||||
|
||||
if additional_options_input == 'y':
|
||||
console.print(f"\n{header} [bold underline]Additional options:[/bold underline]\n")
|
||||
|
||||
# Whisper Batch Size
|
||||
whipser_batch_size_response = console.input(
|
||||
f"{header} Enter the [green]Whisper batch size[/green] (default [cyan]16[/cyan]): "
|
||||
).strip()
|
||||
settings.whisper_batch_size = int(whipser_batch_size_response) if whipser_batch_size_response.isdigit() else 16
|
||||
|
||||
# Whisper Compute Type
|
||||
whisper_compute_choice = console.input(
|
||||
f"{header} Enter the [green]Whisper compute type[/green] (default '[cyan]float16[/cyan]' for CUDA and '[cyan]int8[/cyan]' for CPU): "
|
||||
).strip()
|
||||
if whisper_compute_choice:
|
||||
settings.whisper_compute_type = whisper_compute_choice
|
||||
|
||||
# Create Plot
|
||||
settings.create_plot = console.input(
|
||||
f"{header} Create [green]plot[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Create MIDI
|
||||
settings.create_midi = not (console.input(
|
||||
f"{header} Create [green]MIDI file[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_green]y[/bright_green]'): "
|
||||
).strip().lower() == 'n')
|
||||
|
||||
# Disable Hyphenation
|
||||
settings.hyphenation = not (console.input(
|
||||
f"{header} Disable [green]hyphenation[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y')
|
||||
|
||||
# Disable Vocal Separation
|
||||
settings.use_separated_vocal = not (console.input(
|
||||
f"{header} Disable [green]vocal separation[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y')
|
||||
|
||||
# Disable Karaoke Creation
|
||||
settings.create_karaoke = not (console.input(
|
||||
f"{header} Disable [green]karaoke creation[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y')
|
||||
|
||||
# Create Audio Chunks
|
||||
settings.create_audio_chunks = console.input(
|
||||
f"{header} Create [green]audio chunks[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Ignore Audio
|
||||
settings.ignore_audio = console.input(
|
||||
f"{header} Ignore [green]audio[/green] and use Ultrastar txt only? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Force CPU Usage
|
||||
settings.force_cpu = console.input(
|
||||
f"{header} Force [green]CPU usage[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Device settings based on CPU usage
|
||||
if settings.force_cpu:
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
||||
else:
|
||||
settings.tensorflow_device, settings.pytorch_device = check_gpu_support()
|
||||
|
||||
# Force Whisper CPU Usage
|
||||
settings.force_whisper_cpu = console.input(
|
||||
f"{header} Force [green]Whisper CPU usage[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Force Crepe CPU Usage
|
||||
settings.force_crepe_cpu = console.input(
|
||||
f"{header} Force [green]Crepe CPU usage[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Keep Cache
|
||||
settings.keep_cache = console.input(
|
||||
f"{header} Keep [green]cache[/green] after execution? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower() == 'y'
|
||||
|
||||
# Language
|
||||
language = console.input(
|
||||
f"\n{header} Enter the [green]language code[/green] (e.g., '[cyan]en[/cyan]' for English, '[cyan]es[/cyan]' for Spanish) or leave empty for [cyan]auto-detect[/cyan]: "
|
||||
).strip()
|
||||
if language:
|
||||
settings.language = language
|
||||
|
||||
# Transcribe Numbers as Numerics
|
||||
keep_numbers_input = console.input(
|
||||
f"\n{header} Do you want to transcribe [green]numbers as numerics[/green]? ([bright_green]y[/bright_green]/[bright_red]n[/bright_red], default '[bright_red]n[/bright_red]'): "
|
||||
).strip().lower()
|
||||
settings.keep_numbers = keep_numbers_input == 'y'
|
||||
|
||||
# MuseScore Path
|
||||
musescore_path = console.input(
|
||||
f"\n{header} Enter the path to [green]MuseScore executable[/green] for sheet generation (leave empty to skip): "
|
||||
).strip()
|
||||
if musescore_path:
|
||||
settings.musescore_path = musescore_path
|
||||
|
||||
# Cookie File for YouTube Downloads
|
||||
cookie_file = console.input(
|
||||
f"\n{header} Enter the path to [green]cookies.txt[/green] file (if required for YouTube downloads, leave empty otherwise): "
|
||||
).strip()
|
||||
if cookie_file:
|
||||
settings.cookiefile = cookie_file
|
||||
|
||||
def init_settings_interactive(settings: Settings) -> Settings:
|
||||
ULTRASINGER_HEAD = "[bold green][UltraSinger][/bold green]"
|
||||
console = Console()
|
||||
console.print(f"{ULTRASINGER_HEAD} [yellow]UltraSinger Interactive Mode[/yellow]\n")
|
||||
get_input_file(console, settings, ULTRASINGER_HEAD)
|
||||
get_output_folder(console, settings, ULTRASINGER_HEAD)
|
||||
settings.whisper_model = select_model(console, ULTRASINGER_HEAD, WhisperModel, "Whisper", WhisperModel.LARGE_V2)
|
||||
settings.demucs_model = select_model(console, ULTRASINGER_HEAD, DemucsModel, "Demucs", DemucsModel.HTDEMUCS)
|
||||
|
||||
configure_additional_options(console, settings, ULTRASINGER_HEAD)
|
||||
|
||||
console.print(f"\n{ULTRASINGER_HEAD} [bold cyan]Thank you! Starting processing...[/bold cyan]\n")
|
||||
return settings
|
||||
Reference in new issue
Block a user