From 9bf9024ab0d2a74926599fef3a4853f4e09c384b Mon Sep 17 00:00:00 2001 From: litagin02 Date: Fri, 29 Dec 2023 23:39:04 +0900 Subject: [PATCH] Feat: trim option for resample --- resample.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resample.py b/resample.py index e80da9c..28a2991 100644 --- a/resample.py +++ b/resample.py @@ -27,6 +27,9 @@ def process(item): wav, sr = librosa.load(wav_path, sr=args.sr) if args.normalize: wav = normalize_audio(wav, sr) + if args.trim: + wav, _ = librosa.effects.trim(wav, top_db=30) + logger.debug(f"trim: {wav_name}") soundfile.write(os.path.join(args.out_dir, spkdir, wav_name), wav, sr) @@ -59,9 +62,15 @@ if __name__ == "__main__": parser.add_argument( "--normalize", action="store_true", - default=True, + default=False, help="loudness normalize audio", ) + parser.add_argument( + "--trim", + action="store_true", + default=False, + help="trim silence (start and end only)", + ) args, _ = parser.parse_known_args() # autodl 无卡模式会识别出46个cpu if args.num_processes == 0: