mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge branch 'main' into CI
# Conflicts: # requirements.txt
This commit is contained in:
commit
2e9d126777
6 files changed
+68
-24
No files matched your search
@@ -44,6 +44,7 @@ This will help me alot to keep this project alive and improve it.
|
||||
* Type `.venv\Scripts\activate` and press enter.
|
||||
* You should see now a `(.venv)` in front of your console line.
|
||||
* Install the requirements with `pip install -r requirements.txt`.
|
||||
* Install gpu requirements `pip3 install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2+cu117 --index-url https://download.pytorch.org/whl/cu117`
|
||||
* Now you can use the UltraSinger source code with `py UltraSinger.py [opt] [mode] [transcription] [pitcher] [extra]`. See [How to use](#how-to-use) for more information.
|
||||
|
||||
For more information about Python environments look [here](https://code.visualstudio.com/docs/python/environments#_global-virtual-or-conda-environments).
|
||||
@@ -54,6 +55,7 @@ As copy:
|
||||
py -m venv .venv
|
||||
.venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
pip3 install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2+cu117 --index-url https://download.pytorch.org/whl/cu117
|
||||
|
||||
```
|
||||
|
||||
@@ -195,3 +197,38 @@ for low male voices. Accurate is the real tone specified in the txt. I had txt f
|
||||
singable by humans, but you could still reach the 10k points in the game. The accuracy is important here, because from
|
||||
this MIDI and sheet are created. And you also want to have accurate files
|
||||
|
||||
|
||||
### Use GPU
|
||||
|
||||
With an GPU you can speed up the process and also the quality of the transcription and pitching is better.
|
||||
|
||||
You need a cuda device for this to work.
|
||||
For best use you need to install the cuda driver for your gpu see [here](https://developer.nvidia.com/cuda-downloads).
|
||||
Install torch with cuda separately in your `venv`. See this [link](https://pytorch.org/get-started/locally/).
|
||||
|
||||
Command for `pip`:
|
||||
```
|
||||
pip3 install torch~=2.0.1+cu117 torchvision~=0.15.2+cu117 torchaudio~=2.0.2+cu117 --index-url https://download.pytorch.org/whl/cu117
|
||||
```
|
||||
|
||||
When you want to use `conda` instead you need a different installation command. See this [link](https://pytorch.org/get-started/locally/).
|
||||
|
||||
#### Info
|
||||
|
||||
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`.
|
||||
|
||||
### Use GPU
|
||||
|
||||
With an GPU you can speed up the process and also the quality of the transcription and pitching is better.
|
||||
You need a cuda device for this to work.
|
||||
If you use MAC than sorry, there is no cuda device for MAC machinges.
|
||||
|
||||
#### Info
|
||||
|
||||
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
-1
@@ -26,4 +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
|
||||
|
||||
+11
-4
@@ -437,9 +437,9 @@ def get_unused_song_output_dir(path):
|
||||
def transcribe_audio(transcribed_data):
|
||||
"""Docstring"""
|
||||
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
|
||||
)
|
||||
settings.mono_audio_path, settings.whisper_model, device)
|
||||
else: # vosk
|
||||
transcribed_data = transcribe_with_vosk(
|
||||
settings.mono_audio_path, settings.vosk_model_path
|
||||
@@ -450,14 +450,15 @@ def transcribe_audio(transcribed_data):
|
||||
|
||||
|
||||
def separate_vocal_from_audio(
|
||||
basename_without_ext, cache_path, ultrastar_audio_input_path
|
||||
basename_without_ext, cache_path, ultrastar_audio_input_path
|
||||
):
|
||||
"""Docstring"""
|
||||
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)
|
||||
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)
|
||||
@@ -761,6 +762,8 @@ def init_settings(argv):
|
||||
"disable_separation=",
|
||||
"disable_karaoke=",
|
||||
"create_audio_chunks=",
|
||||
"force_whisper_cpu=",
|
||||
"force_separation_cpu="
|
||||
]
|
||||
opts, args = getopt.getopt(argv, short, long)
|
||||
if len(opts) == 0:
|
||||
@@ -790,6 +793,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()
|
||||
|
||||
@@ -19,9 +19,9 @@ def separate_audio(input_file_path: str, output_file: str, device="cpu") -> None
|
||||
# Model selection?
|
||||
# -n mdx_q
|
||||
# -n htdemucs_ft
|
||||
# todo: -d cpu otherwise it automatically uses gpu
|
||||
device = "cpu" if device != "cuda" else "cuda"
|
||||
subprocess.run(
|
||||
["demucs", "--two-stems=vocals", input_file_path], check=True
|
||||
["demucs", "-d", device, "--two-stems=vocals", input_file_path]
|
||||
)
|
||||
separated_folder = path_join(current_executor_path(), "separated")
|
||||
move(separated_folder, output_file)
|
||||
move(separated_folder, output_file)
|
||||
@@ -1,26 +1,21 @@
|
||||
"""Docstring"""
|
||||
|
||||
import tensorflow as tf
|
||||
import torch
|
||||
|
||||
from modules.console_colors import ULTRASINGER_HEAD, red_highlighted
|
||||
|
||||
|
||||
def get_available_device():
|
||||
"""Docstring"""
|
||||
gpus = tf.config.list_physical_devices("GPU")
|
||||
isCuda = torch.cuda.is_available()
|
||||
|
||||
if not gpus:
|
||||
if not isCuda:
|
||||
print(
|
||||
f"{ULTRASINGER_HEAD} There are no GPUs available. Using {red_highlighted('cpu')}."
|
||||
f"{ULTRASINGER_HEAD} There are no {red_highlighted('cuda')} devices available. -> Using {red_highlighted('cpu')}."
|
||||
)
|
||||
|
||||
return "cpu"
|
||||
else:
|
||||
print(f"{ULTRASINGER_HEAD} Using {red_highlighted('cuda')} GPU.")
|
||||
|
||||
print(f"{ULTRASINGER_HEAD} Found available GPUs:")
|
||||
for gpu in gpus:
|
||||
print(f"Name: {gpu.name}, Type: {gpu.device_type}")
|
||||
|
||||
# Todo: Finish this
|
||||
print(
|
||||
f"{ULTRASINGER_HEAD} GPU usage are currently in development. Using {red_highlighted('cpu')}"
|
||||
)
|
||||
return "cpu"
|
||||
return "cuda"
|
||||
+5
-3
@@ -1,11 +1,13 @@
|
||||
crepe==0.0.13
|
||||
librosa==0.9.2
|
||||
pretty_midi==0.2.9
|
||||
pretty_midi~=0.2.10
|
||||
pydub==0.25.1
|
||||
Levenshtein==0.20.9
|
||||
scipy==1.10.0
|
||||
Levenshtein~=0.21.0
|
||||
scipy~=1.10.1
|
||||
vosk==0.3.44
|
||||
tensorflow~=2.12.0
|
||||
#tensorflow-directml-plugin~=0.4.0.dev230202
|
||||
#cudatoolkit==11.8.0
|
||||
matplotlib~=3.7.1
|
||||
yt_dlp~=2023.3.4
|
||||
numpy~=1.23.5
|
||||
|
||||
Reference in new issue
Block a user