Skip to content

chore(format): run black on master #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from tabs.full_inference import full_inference_tab
from tabs.download_model import download_model_tab
from tabs.settings import theme_tab, lang_tab, restart_tab
from programs.applio_code.rvc.lib.tools.prerequisites_download import prequisites_download_pipeline
from programs.applio_code.rvc.lib.tools.prerequisites_download import (
prequisites_download_pipeline,
)
from tabs.presence import load_config_presence, presence_tab

now_dir = os.getcwd()
Expand All @@ -15,7 +17,7 @@
prequisites_download_pipeline(
False,
False,
True,
True,
False,
)

Expand All @@ -32,15 +34,14 @@
RPCManager.start_presence()



rvc_theme = loadThemes.load_theme() or "NoCrypt/miku"

with gr.Blocks(
theme=rvc_theme, title="Advanced RVC Inference"
) as rvc:
with gr.Blocks(theme=rvc_theme, title="Advanced RVC Inference") as rvc:
gr.Markdown('<div align="center"><h1>Advanced RVC Inference</h1></a></div>')
gr.Markdown('<div align="center">this project Maintained by <a href="https://discord.com/1314204512814235689">NeoDev</a></div>')

gr.Markdown(
'<div align="center">this project Maintained by <a href="https://discord.com/1314204512814235689">NeoDev</a></div>'
)

with gr.Tab(i18n("Full Inference")):
full_inference_tab()
with gr.Tab(i18n("Download Model")):
Expand Down
10 changes: 8 additions & 2 deletions assets/discord_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ def update_presence(self):
state="Advanced-RVC",
details="Advaced voice cloning with UVR5 feature",
buttons=[
{"label": "Home", "url": "https://github.com/ArkanDash/Advanced-RVC-Inference"},
{"label": "Download", "url": "https://github.com/ArkanDash/Advanced-RVC-Inference/archive/refs/heads/master.zip"},
{
"label": "Home",
"url": "https://github.com/ArkanDash/Advanced-RVC-Inference",
},
{
"label": "Download",
"url": "https://github.com/ArkanDash/Advanced-RVC-Inference/archive/refs/heads/master.zip",
},
],
large_image="logo",
large_text="Experimenting with Advanced-RVC",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/languages/id_ID.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
"Export Audio": "Ekspor Audio",
"Music URL": "URL Musik",
"Download": "Unduh",
"Model URL": "URL Model"
"Model URL": "URL Model",
}
1 change: 0 additions & 1 deletion assets/themes/Grheme.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations
import time

from typing import Iterable
import gradio as gr
Expand Down
12 changes: 6 additions & 6 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from programs.music_separation_code.inference import proc_file

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s"
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
now_dir = os.getcwd()
sys.path.append(now_dir)
Expand Down Expand Up @@ -1015,7 +1014,6 @@ def download_model(link):
return "Model downloaded with success"



def download_music(link):
if not link or not isinstance(link, str):
logging.error("Invalid link provided.")
Expand All @@ -1035,9 +1033,11 @@ def download_music(link):
command = [
"yt-dlp",
"-x",
"--audio-format", "wav",
"--output", output_template,
link
"--audio-format",
"wav",
"--output",
output_template,
link,
]

try:
Expand Down
71 changes: 46 additions & 25 deletions programs/music_separation_code/ensemble.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
__author__ = 'Roman Solovyev (ZFTurbo): https://github.com/ZFTurbo/'
__author__ = "Roman Solovyev (ZFTurbo): https://github.com/ZFTurbo/"

import os
import librosa
Expand Down Expand Up @@ -81,42 +81,42 @@ def average_waveforms(pred_track, weights, algorithm):

mod_track = []
for i in range(pred_track.shape[0]):
if algorithm == 'avg_wave':
if algorithm == "avg_wave":
mod_track.append(pred_track[i] * weights[i])
elif algorithm in ['median_wave', 'min_wave', 'max_wave']:
elif algorithm in ["median_wave", "min_wave", "max_wave"]:
mod_track.append(pred_track[i])
elif algorithm in ['avg_fft', 'min_fft', 'max_fft', 'median_fft']:
elif algorithm in ["avg_fft", "min_fft", "max_fft", "median_fft"]:
spec = stft(pred_track[i], nfft=2048, hl=1024)
if algorithm in ['avg_fft']:
if algorithm in ["avg_fft"]:
mod_track.append(spec * weights[i])
else:
mod_track.append(spec)
pred_track = np.array(mod_track)

if algorithm in ['avg_wave']:
if algorithm in ["avg_wave"]:
pred_track = pred_track.sum(axis=0)
pred_track /= np.array(weights).sum().T
elif algorithm in ['median_wave']:
elif algorithm in ["median_wave"]:
pred_track = np.median(pred_track, axis=0)
elif algorithm in ['min_wave']:
elif algorithm in ["min_wave"]:
pred_track = np.array(pred_track)
pred_track = lambda_min(pred_track, axis=0, key=np.abs)
elif algorithm in ['max_wave']:
elif algorithm in ["max_wave"]:
pred_track = np.array(pred_track)
pred_track = lambda_max(pred_track, axis=0, key=np.abs)
elif algorithm in ['avg_fft']:
elif algorithm in ["avg_fft"]:
pred_track = pred_track.sum(axis=0)
pred_track /= np.array(weights).sum()
pred_track = istft(pred_track, 1024, final_length)
elif algorithm in ['min_fft']:
elif algorithm in ["min_fft"]:
pred_track = np.array(pred_track)
pred_track = lambda_min(pred_track, axis=0, key=np.abs)
pred_track = istft(pred_track, 1024, final_length)
elif algorithm in ['max_fft']:
elif algorithm in ["max_fft"]:
pred_track = np.array(pred_track)
pred_track = absmax(pred_track, axis=0)
pred_track = istft(pred_track, 1024, final_length)
elif algorithm in ['median_fft']:
elif algorithm in ["median_fft"]:
pred_track = np.array(pred_track)
pred_track = np.median(pred_track, axis=0)
pred_track = istft(pred_track, 1024, final_length)
Expand All @@ -125,37 +125,58 @@ def average_waveforms(pred_track, weights, algorithm):

def ensemble_files(args):
parser = argparse.ArgumentParser()
parser.add_argument("--files", type=str, required=True, nargs='+', help="Path to all audio-files to ensemble")
parser.add_argument("--type", type=str, default='avg_wave', help="One of avg_wave, median_wave, min_wave, max_wave, avg_fft, median_fft, min_fft, max_fft")
parser.add_argument("--weights", type=float, nargs='+', help="Weights to create ensemble. Number of weights must be equal to number of files")
parser.add_argument("--output", default="res.wav", type=str, help="Path to wav file where ensemble result will be stored")
parser.add_argument(
"--files",
type=str,
required=True,
nargs="+",
help="Path to all audio-files to ensemble",
)
parser.add_argument(
"--type",
type=str,
default="avg_wave",
help="One of avg_wave, median_wave, min_wave, max_wave, avg_fft, median_fft, min_fft, max_fft",
)
parser.add_argument(
"--weights",
type=float,
nargs="+",
help="Weights to create ensemble. Number of weights must be equal to number of files",
)
parser.add_argument(
"--output",
default="res.wav",
type=str,
help="Path to wav file where ensemble result will be stored",
)
if args is None:
args = parser.parse_args()
else:
args = parser.parse_args(args)

print('Ensemble type: {}'.format(args.type))
print('Number of input files: {}'.format(len(args.files)))
print("Ensemble type: {}".format(args.type))
print("Number of input files: {}".format(len(args.files)))
if args.weights is not None:
weights = args.weights
else:
weights = np.ones(len(args.files))
print('Weights: {}'.format(weights))
print('Output file: {}'.format(args.output))
print("Weights: {}".format(weights))
print("Output file: {}".format(args.output))
data = []
for f in args.files:
if not os.path.isfile(f):
print('Error. Can\'t find file: {}. Check paths.'.format(f))
print("Error. Can't find file: {}. Check paths.".format(f))
exit()
print('Reading file: {}'.format(f))
print("Reading file: {}".format(f))
wav, sr = librosa.load(f, sr=None, mono=False)
# wav, sr = sf.read(f)
print("Waveform shape: {} sample rate: {}".format(wav.shape, sr))
data.append(wav)
data = np.array(data)
res = average_waveforms(data, weights, args.type)
print('Result shape: {}'.format(res.shape))
sf.write(args.output, res.T, sr, 'FLOAT')
print("Result shape: {}".format(res.shape))
sf.write(args.output, res.T, sr, "FLOAT")


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion programs/music_separation_code/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from tqdm import tqdm
import sys
import os
import glob
import torch
import numpy as np
import soundfile as sf
Expand Down
Loading
Loading