| import os
|
| import glob
|
| import subprocess
|
|
|
| def de_echo(input_sound, output_dir):
|
| """MP3 256kps"""
|
| command = [
|
| "audio-separator", input_sound,
|
| "--model_filename", "UVR-De-Echo-Aggressive.pth",
|
| "--vr_window_size", "512",
|
| "--vr_batch_size", "16",
|
| "--vr_aggression", "5",
|
| "--output_format", "MP3",
|
| "--output_dir", output_dir
|
| ]
|
|
|
| try:
|
| subprocess.run(command, check=True, stderr=subprocess.DEVNULL)
|
|
|
| except subprocess.CalledProcessError as error:
|
| print(f"Conversion failed: {error}")
|
|
|
|
|
| def de_echo_normal(input_sound, output_dir):
|
| """MP3 256kps"""
|
| command = [
|
| "audio-separator", input_sound,
|
| "--model_filename", "UVR-De-Echo-Normal.pth",
|
| "--vr_window_size", "512",
|
| "--vr_batch_size", "16",
|
| "--vr_aggression", "5",
|
| "--output_format", "MP3",
|
| "--output_dir", output_dir
|
| ]
|
|
|
| try:
|
| subprocess.run(command, check=True, stderr=subprocess.DEVNULL)
|
|
|
| except subprocess.CalledProcessError as error:
|
| print(f"Conversion failed: {error}")
|
|
|
|
|
| def main():
|
| import argparse
|
| parser = argparse.ArgumentParser(description='')
|
|
|
| parser.add_argument('--in_dir', type=str, help='')
|
| parser.add_argument('--out_dir', type=str, help='')
|
| args = parser.parse_args()
|
|
|
|
|
| os.makedirs(args.out_dir, exist_ok=True)
|
|
|
| files = glob.glob(f'{args.in_dir}/*.mp3')
|
| files.sort()
|
| print(f'num_files: {len(files)}')
|
|
|
| for i,file in enumerate(files):
|
| print(f'{i}/{len(files)}: {file}')
|
|
|
| de_echo_normal(file, f'{args.out_dir}')
|
| os.system(f'rm -f {args.out_dir}/*Instrumental*')
|
|
|
| file_name = os.path.basename(file)
|
| name = os.path.splitext(file_name)[0]
|
|
|
|
|
| src_file = os.path.join(args.out_dir, f'{name}_(No Echo)_UVR-De-Echo-Normal.mp3')
|
| dst_file = os.path.join(args.out_dir, f'{name}.mp3')
|
| try:
|
| os.rename(src_file, dst_file)
|
| except:
|
| pass
|
|
|
|
|
|
|
| if __name__ == '__main__':
|
| main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|