binhnx8 commited on
Commit
2caea7d
·
verified ·
1 Parent(s): 52cdc95

Upload de_echo_cli.py

Browse files
Files changed (1) hide show
  1. de_echo_cli.py +84 -0
de_echo_cli.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+ import subprocess
4
+
5
+ def de_echo(input_sound, output_dir):
6
+ """MP3 256kps"""
7
+ command = [
8
+ "audio-separator", input_sound,
9
+ "--model_filename", "UVR-De-Echo-Aggressive.pth",
10
+ "--vr_window_size", "512",
11
+ "--vr_batch_size", "16",
12
+ "--vr_aggression", "5",
13
+ "--output_format", "MP3",
14
+ "--output_dir", output_dir
15
+ ]
16
+
17
+ try:
18
+ subprocess.run(command, check=True, stderr=subprocess.DEVNULL)
19
+ #print(f"Conversion successful: {output_sound}")
20
+ except subprocess.CalledProcessError as error:
21
+ print(f"Conversion failed: {error}")
22
+
23
+
24
+ def de_echo_normal(input_sound, output_dir):
25
+ """MP3 256kps"""
26
+ command = [
27
+ "audio-separator", input_sound,
28
+ "--model_filename", "UVR-De-Echo-Normal.pth",
29
+ "--vr_window_size", "512",
30
+ "--vr_batch_size", "16",
31
+ "--vr_aggression", "5",
32
+ "--output_format", "MP3",
33
+ "--output_dir", output_dir
34
+ ]
35
+
36
+ try:
37
+ subprocess.run(command, check=True, stderr=subprocess.DEVNULL)
38
+ #print(f"Conversion successful: {output_sound}")
39
+ except subprocess.CalledProcessError as error:
40
+ print(f"Conversion failed: {error}")
41
+
42
+
43
+ def main():
44
+ import argparse
45
+ parser = argparse.ArgumentParser(description='')
46
+
47
+ parser.add_argument('--in_dir', type=str, help='')
48
+ parser.add_argument('--out_dir', type=str, help='')
49
+ args = parser.parse_args()
50
+ #print(args)
51
+ #########################
52
+ os.makedirs(args.out_dir, exist_ok=True)
53
+
54
+ files = glob.glob(f'{args.in_dir}/*.mp3')
55
+ files.sort()
56
+ print(f'num_files: {len(files)}')
57
+
58
+ for i,file in enumerate(files):
59
+ print(f'{i}/{len(files)}: {file}')
60
+ #de_echo(file, f'{args.out_dir}')
61
+ de_echo_normal(file, f'{args.out_dir}')
62
+ os.system(f'rm -f {args.out_dir}/*Instrumental*')
63
+
64
+ file_name = os.path.basename(file)
65
+ name = os.path.splitext(file_name)[0]
66
+
67
+ #src_file = os.path.join(args.out_dir, f'{name}_(No Echo)_UVR-De-Echo-Aggressive.mp3')
68
+ src_file = os.path.join(args.out_dir, f'{name}_(No Echo)_UVR-De-Echo-Normal.mp3')
69
+ dst_file = os.path.join(args.out_dir, f'{name}.mp3')
70
+ try:
71
+ os.rename(src_file, dst_file)
72
+ except:
73
+ pass
74
+
75
+ #########################
76
+
77
+ if __name__ == '__main__':
78
+ main()
79
+
80
+
81
+
82
+
83
+
84
+