Restore Loud match logic
This commit is contained in:
parent
811fabfcdd
commit
49a3b0f2ae
|
@ -106,10 +106,10 @@ def process_one(filename, hmodel,f0p,diff=False,mel_extractor=None):
|
|||
|
||||
|
||||
def process_batch(filenames,f0p,diff=False,mel_extractor=None):
|
||||
print("Loading hubert for content...")
|
||||
print("Loading speech encoder for content...")
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
hmodel = utils.get_speech_encoder(speech_encoder,device=device)
|
||||
print("Loaded hubert.")
|
||||
print("Loaded speech encoder.")
|
||||
for filename in tqdm(filenames):
|
||||
process_one(filename, hmodel,f0p,diff,mel_extractor)
|
||||
|
||||
|
|
|
@ -20,5 +20,4 @@ tensorboard
|
|||
tensorboardX
|
||||
edge_tts
|
||||
pyyaml
|
||||
pynvml
|
||||
pyloudnorm
|
||||
pynvml
|
|
@ -23,5 +23,4 @@ onnxoptimizer
|
|||
tensorboardX
|
||||
edge_tts
|
||||
pyyaml
|
||||
pynvml
|
||||
pyloudnorm
|
||||
pynvml
|
21
resample.py
21
resample.py
|
@ -5,7 +5,6 @@ import numpy as np
|
|||
from multiprocessing import Pool, cpu_count
|
||||
from scipy.io import wavfile
|
||||
from tqdm import tqdm
|
||||
import pyloudnorm as pyln
|
||||
|
||||
|
||||
def process(item):
|
||||
|
@ -22,19 +21,13 @@ def process(item):
|
|||
wav = 0.98 * wav / peak
|
||||
wav2 = librosa.resample(wav, orig_sr=sr, target_sr=args.sr2)
|
||||
wav2 /= max(wav2.max(), -wav2.min())
|
||||
try:
|
||||
meter = pyln.Meter(args.sr2)
|
||||
loudness = meter.integrated_loudness(wav2)
|
||||
wav2 = pyln.normalize.loudness(wav2, loudness, -23.0)
|
||||
# wav2 /= max(wav2.max(), -wav2.min())
|
||||
save_name = wav_name
|
||||
save_path2 = os.path.join(args.out_dir2, speaker, save_name)
|
||||
wavfile.write(
|
||||
save_path2,
|
||||
args.sr2,
|
||||
(wav2 * np.iinfo(np.int16).max).astype(np.int16))
|
||||
except ValueError as e:
|
||||
print(f"{wav_path} is too short(<400ms), the wav skip")
|
||||
save_name = wav_name
|
||||
save_path2 = os.path.join(args.out_dir2, speaker, save_name)
|
||||
wavfile.write(
|
||||
save_path2,
|
||||
args.sr2,
|
||||
(wav2 * np.iinfo(np.int16).max).astype(np.int16)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue