Skip to content

Commit 51c85fc

Browse files
chore(format): run black on dev (#101)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 5969314 commit 51c85fc

File tree

6 files changed

+46
-20
lines changed

6 files changed

+46
-20
lines changed

infer/lib/audio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def frame_iter(container):
142142

143143
np.copyto(decoded_audio[..., offset:end_index], frame_data)
144144
offset += len(frame_data[0])
145-
145+
146146
container.close()
147147

148148
# Truncate the array to the actual size
@@ -188,7 +188,6 @@ def resample_audio(
188188
output_container.close()
189189

190190

191-
192191
def get_audio_properties(input_path: str) -> Tuple[int, int]:
193192
container = av.open(input_path)
194193
audio_stream = next(s for s in container.streams if s.type == "audio")

infer/lib/train/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ def summarize(
104104

105105
def latest_checkpoint_path(dir_path, regex="G_*.pth"):
106106
f_list = glob.glob(os.path.join(dir_path, regex))
107-
f_list.sort(key=lambda f: 999999999999 if isinstance(f, str) and f == "latest" else int("0"+"".join(filter(str.isdigit, f))))
107+
f_list.sort(
108+
key=lambda f: (
109+
999999999999
110+
if isinstance(f, str) and f == "latest"
111+
else int("0" + "".join(filter(str.isdigit, f)))
112+
)
113+
)
108114
x = f_list[-1]
109115
logger.debug(x)
110116
return x

infer/lib/uvr5_pack/lib_v5/spec_utils.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def crop_center(h1, h2):
2424
return h1
2525

2626

27-
def split_lr_waves(
28-
wave, mid_side=False, mid_side_b2=False, reverse=False
29-
):
27+
def split_lr_waves(wave, mid_side=False, mid_side_b2=False, reverse=False):
3028
if reverse:
3129
wave_left = np.flip(np.asfortranarray(wave[0]))
3230
wave_right = np.flip(np.asfortranarray(wave[1]))
@@ -48,17 +46,23 @@ def run_librosa_stft(wv, n_fft, hop_length, reverse):
4846
return librosa.stft(wv, n_fft=n_fft, hop_length=hop_length)
4947
return librosa.stft(np.asfortranarray(wv), n_fft=n_fft, hop_length=hop_length)
5048

49+
5150
def wave_to_spectrogram_mt(
5251
wave, hop_length, n_fft, mid_side=False, mid_side_b2=False, reverse=False
5352
):
5453

5554
with ThreadPoolExecutor(max_workers=2) as tp:
5655
spec = np.asfortranarray(
57-
[spec for spec in tp.map(
58-
run_librosa_stft,
59-
split_lr_waves(wave, mid_side, mid_side_b2, reverse),
60-
[n_fft, n_fft], [hop_length, hop_length], [reverse, reverse]
61-
)]
56+
[
57+
spec
58+
for spec in tp.map(
59+
run_librosa_stft,
60+
split_lr_waves(wave, mid_side, mid_side_b2, reverse),
61+
[n_fft, n_fft],
62+
[hop_length, hop_length],
63+
[reverse, reverse],
64+
)
65+
]
6266
)
6367

6468
return spec
@@ -144,10 +148,13 @@ def mask_silence(mag, ref, thres=0.2, min_range=64, fade_size=32):
144148
def run_librosa_istft(specx, hop_length):
145149
return librosa.istft(np.asfortranarray(specx), hop_length=hop_length)
146150

151+
147152
def spectrogram_to_wave(spec, hop_length, mid_side, mid_side_b2, reverse):
148153

149154
with ThreadPoolExecutor(max_workers=2) as tp:
150-
wave_left, wave_right = tp.map(run_librosa_istft, spec, [hop_length, hop_length])
155+
wave_left, wave_right = tp.map(
156+
run_librosa_istft, spec, [hop_length, hop_length]
157+
)
151158

152159
if reverse:
153160
return np.asfortranarray([np.flip(wave_left), np.flip(wave_right)])

infer/modules/uvr5/mdxnet.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,21 @@ def prediction(self, m, vocal_root, others_root, format):
207207
sources = self.demix(mix.T)
208208
opt = sources[0].T
209209
save_audio(
210-
"%s/vocal_%s.%s" % (vocal_root, basename, format), mix - opt, rate, True, format=format,
210+
"%s/vocal_%s.%s" % (vocal_root, basename, format),
211+
mix - opt,
212+
rate,
213+
True,
214+
format=format,
211215
)
212216
save_audio(
213-
"%s/instrument_%s.%s" % (others_root, basename, format), opt, rate, True, format=format,
217+
"%s/instrument_%s.%s" % (others_root, basename, format),
218+
opt,
219+
rate,
220+
True,
221+
format=format,
214222
)
215223

224+
216225
class MDXNetDereverb:
217226
def __init__(self, chunks, device):
218227
self.onnx = "assets/uvr5_weights/onnx_dereverb_By_FoxJoy"

infer/modules/uvr5/vr.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None, format="flac"
119119
if ins_root is not None:
120120
if self.data["high_end_process"].startswith("mirroring"):
121121
input_high_end_ = spec_utils.mirroring(
122-
self.data["high_end_process"], y_spec_m, input_high_end, self.mp.param["pre_filter_start"]
122+
self.data["high_end_process"],
123+
y_spec_m,
124+
input_high_end,
125+
self.mp.param["pre_filter_start"],
123126
)
124127
wav_instrument = spec_utils.cmb_spectrogram_to_wave(
125128
y_spec_m, self.mp, input_high_end_h, input_high_end_
@@ -139,7 +142,7 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None, format="flac"
139142
wav_instrument,
140143
self.mp.param["sr"],
141144
f32=True,
142-
format=format
145+
format=format,
143146
)
144147
if vocal_root is not None:
145148
if self.is_reverse:
@@ -148,7 +151,10 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None, format="flac"
148151
head = "vocal_"
149152
if self.data["high_end_process"].startswith("mirroring"):
150153
input_high_end_ = spec_utils.mirroring(
151-
self.data["high_end_process"], v_spec_m, input_high_end, self.mp.param["pre_filter_start"]
154+
self.data["high_end_process"],
155+
v_spec_m,
156+
input_high_end,
157+
self.mp.param["pre_filter_start"],
152158
)
153159
wav_vocals = spec_utils.cmb_spectrogram_to_wave(
154160
v_spec_m, self.mp, input_high_end_h, input_high_end_
@@ -164,5 +170,5 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None, format="flac"
164170
wav_vocals,
165171
self.mp.param["sr"],
166172
f32=True,
167-
format=format
173+
format=format,
168174
)

infer/modules/vc/modules.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ def vc_multi(
252252
try:
253253
tgt_sr, audio_opt = opt
254254
save_audio(
255-
"%s/%s.%s"
256-
% (opt_root, os.path.basename(path), format1),
255+
"%s/%s.%s" % (opt_root, os.path.basename(path), format1),
257256
audio_opt,
258257
tgt_sr,
259258
f32=True,

0 commit comments

Comments
 (0)