Merge pull request #190 from svc-develop-team/4.1-Stable

Restore Loud match logic
This commit is contained in:
YuriHead 2023-05-25 02:05:59 +08:00 committed by GitHub
commit 71814e488d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 19 deletions

View File

@ -20,5 +20,4 @@ tensorboard
tensorboardX
edge_tts
pyyaml
pynvml
pyloudnorm
pynvml

View File

@ -23,5 +23,4 @@ onnxoptimizer
tensorboardX
edge_tts
pyyaml
pynvml
pyloudnorm
pynvml

View File

@ -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,20 +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,block_size=0.2)
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(<200ms), 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)
)
if __name__ == "__main__":