gosummer commited on
Commit
2410fdb
·
verified ·
1 Parent(s): 117c66f

Upload 5 files

Browse files
BS一键全流程-混音.sh ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Change directory
4
+ cd /mnt/workspace/uvr5/MDX23v24
5
+
6
+ # 设置 HF_ENDPOINT 环境变量
7
+ export HF_ENDPOINT="https://hf-mirror.com"
8
+
9
+ input_folder="/mnt/workspace/input"
10
+ output_folder="/mnt/workspace/uvr5/output"
11
+
12
+ for file_path in $(ls -1 $input_folder); do
13
+ filename=$(basename "$file_path" | cut -d. -f1)
14
+ # 调用 inference.py,并传入环境变量 HF_ENDPOINT
15
+ # bigshifts 代表精度 3~11之间选择,但并不是越大越好
16
+ python inference.py --large_gpu \
17
+ --vocals_only \
18
+ --use_BSRoformer \
19
+ --use_InstVoc \
20
+ --BSRoformer_model ep_317_1297 \
21
+ --weight_BSRoformer 10 \
22
+ --weight_InstVoc 1 \
23
+ --BigShifts 6 \
24
+ --filter_vocals \
25
+ --input_audio "$input_folder/$file_path" \
26
+ --output_folder "$output_folder"
27
+ done
28
+
29
+ # Move and convert files
30
+ source_folder="/mnt/workspace/uvr5/output"
31
+ target_folder="/mnt/workspace/uvr5/伴奏"
32
+ for file_name in $(ls $source_folder)
33
+ do
34
+ if [[ $file_name == *"_instrum.wav" ]]
35
+ then
36
+ file_path="$source_folder/$file_name"
37
+ target_path="$target_folder/$file_name"
38
+ mv $file_path $target_path
39
+ mp3_file_path="${target_path%.wav}.mp3"
40
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $mp3_file_path
41
+ rm $target_path
42
+ fi
43
+ done
44
+
45
+ # Change directory
46
+ cd /mnt/workspace/uvr5
47
+
48
+ # Run uvr.py
49
+ python uvr.py
50
+
51
+ # Move and convert files
52
+ source_folder="/mnt/workspace/uvr5/echo"
53
+ target_folder="/mnt/workspace/uvr5/伴奏"
54
+ for file_name in $(ls $source_folder)
55
+ do
56
+ if [[ $file_name == *"和声_"* && $file_name == *.wav ]]
57
+ then
58
+ file_path="$source_folder/$file_name"
59
+ target_path="$target_folder/$file_name"
60
+ mv $file_path $target_path
61
+ mp3_file_path="${target_path%.wav}.mp3"
62
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $mp3_file_path
63
+ rm $target_path
64
+ fi
65
+ done
66
+
67
+ # Run deecho.py
68
+ python deecho.py -d cuda -model_path /mnt/workspace/uvr5/uvr5_weights/VR-DeEchoAggressive.pth -audio_path /mnt/workspace/uvr5/echo/ -is_half False -save_path /mnt/workspace/uvr5/人声/ -model_params 4band_v3
69
+
70
+ # Convert files to mp3 and remove wav files
71
+ input_folder='/mnt/workspace/uvr5/人声/'
72
+ output_folder='/mnt/workspace/uvr5/人声/'
73
+ for file in $(ls $input_folder)
74
+ do
75
+ if [[ $file == *"人声_"* && $file == *.wav ]]
76
+ then
77
+ input_path="$input_folder/$file"
78
+ output_file="${file%.wav}.mp3"
79
+ output_path="$output_folder/$output_file"
80
+ ffmpeg -i $input_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $output_path
81
+ fi
82
+ done
83
+
84
+ # Remove wav files
85
+ for file in $(ls $input_folder)
86
+ do
87
+ if [[ $file == *.wav ]]
88
+ then
89
+ file_path="$input_folder/$file"
90
+ rm $file_path
91
+ fi
92
+ done
93
+
94
+ # 重命名人声文件
95
+ for file in $(ls $output_folder)
96
+ do
97
+ if [[ $file == 人声_*_vocals.mp3 ]]
98
+ then
99
+ original_file="$output_folder/$file"
100
+
101
+ # Extract X from the original filename
102
+ X="${file#人声_}" # Remove "人声_" prefix
103
+ X="${X%_vocals.mp3}" # Remove "_vocals.mp3" suffix
104
+
105
+ # New filename
106
+ new_filename="${X}-人声.mp3"
107
+ new_file="$output_folder/$new_filename"
108
+
109
+ # Rename the file
110
+ mv "$original_file" "$new_file"
111
+ fi
112
+ done
113
+
114
+ # 将伴奏内的和声和伴奏混成一个文件
115
+ python3 <<EOF
116
+ import os
117
+ from pydub import AudioSegment
118
+
119
+ # 指定音频文件夹路径
120
+ audio_folder = "/mnt/workspace/uvr5/伴奏"
121
+ # 获取文件夹内所有的音频文件名
122
+ audio_files = os.listdir(audio_folder)
123
+ # 遍历每个音频文件
124
+ for vocals_filename in audio_files:
125
+ if vocals_filename.startswith("和声_") and vocals_filename.endswith("_vocals.mp3"):
126
+ # 构建对应的伴奏文件名
127
+ instrumental_filename = vocals_filename.replace("和声_", "").replace("_vocals.mp3", "_instrum.mp3")
128
+ instrumental_path = os.path.join(audio_folder, instrumental_filename)
129
+ # 检查伴奏文件是否存在
130
+ if os.path.isfile(instrumental_path):
131
+ # 使用pydub打开音频文件
132
+ instrumental = AudioSegment.from_file(instrumental_path)
133
+ vocals_path = os.path.join(audio_folder, vocals_filename)
134
+ vocals = AudioSegment.from_file(vocals_path)
135
+ # 确保两个音频文件的长度相同,进行裁剪或填充操作
136
+ if len(instrumental) != len(vocals):
137
+ if len(instrumental) > len(vocals):
138
+ vocals = vocals + AudioSegment.silent(duration=len(instrumental) - len(vocals))
139
+ else:
140
+ instrumental = instrumental + AudioSegment.silent(duration=len(vocals) - len(instrumental))
141
+ # 混合音频文件
142
+ mixed_audio = instrumental.overlay(vocals)
143
+ # 构建输出文件名,例如 "XX-伴奏.mp3"
144
+ output_filename = vocals_filename.replace("和声_", "").replace("_vocals.mp3", "-伴奏.mp3")
145
+ output_path = os.path.join(audio_folder, output_filename)
146
+ # 保存混音后的文件
147
+ mixed_audio.export(output_path, format="mp3")
148
+ # 删除原始的和声和伴奏文件
149
+ os.remove(vocals_path)
150
+ os.remove(instrumental_path)
151
+ print(f"混音完成,保存在 {output_path},原始文件已删除")
152
+ else:
153
+ print(f"找不到对应的伴奏文件 {instrumental_filename}")
154
+ EOF
155
+
156
+ echo -e "\033[32m> 已将所有input文件夹内的音频完成分离,人声在 /mnt/workspace/uvr5/人声/ 文件夹内,伴奏及和声在 /mnt/workspace/uvr5/伴奏/ 文件夹内。 \033[0m"
BS一键全流程.sh ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Change directory
4
+ cd /mnt/workspace/uvr5/MDX23v24
5
+
6
+ # 设置 HF_ENDPOINT 环境变量
7
+ export HF_ENDPOINT="https://hf-mirror.com"
8
+
9
+ input_folder="/mnt/workspace/input"
10
+ output_folder="/mnt/workspace/uvr5/output"
11
+
12
+ for file_path in $(ls -1 $input_folder); do
13
+ filename=$(basename "$file_path" | cut -d. -f1)
14
+ # 调用 inference.py,并传入环境变量 HF_ENDPOINT
15
+ # bigshifts 代表精度 3~11之间选择,但并不是越大越好
16
+ python inference.py --large_gpu \
17
+ --vocals_only \
18
+ --use_BSRoformer \
19
+ --use_InstVoc \
20
+ --BSRoformer_model ep_317_1297 \
21
+ --weight_BSRoformer 10 \
22
+ --weight_InstVoc 1 \
23
+ --BigShifts 6 \
24
+ --filter_vocals \
25
+ --input_audio "$input_folder/$file_path" \
26
+ --output_folder "$output_folder"
27
+ done
28
+
29
+ # Move and convert files
30
+ source_folder="/mnt/workspace/uvr5/output"
31
+ target_folder="/mnt/workspace/uvr5/伴奏"
32
+ for file_name in $(ls $source_folder)
33
+ do
34
+ if [[ $file_name == *"_instrum.wav" ]]
35
+ then
36
+ file_path="$source_folder/$file_name"
37
+ target_path="$target_folder/$file_name"
38
+ mv $file_path $target_path
39
+ mp3_file_path="${target_path%.wav}.mp3"
40
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $mp3_file_path
41
+ rm $target_path
42
+ fi
43
+ done
44
+
45
+ # Change directory
46
+ cd /mnt/workspace/uvr5
47
+
48
+ # Run uvr.py
49
+ python uvr.py
50
+
51
+ # Move and convert files
52
+ source_folder="/mnt/workspace/uvr5/echo"
53
+ target_folder="/mnt/workspace/uvr5/伴奏"
54
+ for file_name in $(ls $source_folder)
55
+ do
56
+ if [[ $file_name == *"和声_"* && $file_name == *.wav ]]
57
+ then
58
+ file_path="$source_folder/$file_name"
59
+ target_path="$target_folder/$file_name"
60
+ mv $file_path $target_path
61
+ mp3_file_path="${target_path%.wav}.mp3"
62
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $mp3_file_path
63
+ rm $target_path
64
+ fi
65
+ done
66
+
67
+ # Run deecho.py
68
+ python deecho.py -d cuda -model_path /mnt/workspace/uvr5/uvr5_weights/VR-DeEchoAggressive.pth -audio_path /mnt/workspace/uvr5/echo/ -is_half False -save_path /mnt/workspace/uvr5/人声/ -model_params 4band_v3
69
+
70
+ # Convert files to mp3 and remove wav files
71
+ input_folder='/mnt/workspace/uvr5/人声/'
72
+ output_folder='/mnt/workspace/uvr5/人声/'
73
+ for file in $(ls $input_folder)
74
+ do
75
+ if [[ $file == *"人声_"* && $file == *.wav ]]
76
+ then
77
+ input_path="$input_folder/$file"
78
+ output_file="${file%.wav}.mp3"
79
+ output_path="$output_folder/$output_file"
80
+ ffmpeg -i $input_path -vn -ar 44100 -ac 2 -b:a 320k -loglevel panic $output_path
81
+ fi
82
+ done
83
+
84
+ # Remove wav files
85
+ for file in $(ls $input_folder)
86
+ do
87
+ if [[ $file == *.wav ]]
88
+ then
89
+ file_path="$input_folder/$file"
90
+ rm $file_path
91
+ fi
92
+ done
93
+
94
+ # 重命名人声文件
95
+ for file in $(ls $output_folder)
96
+ do
97
+ if [[ $file == 人声_*_vocals.mp3 ]]
98
+ then
99
+ original_file="$output_folder/$file"
100
+
101
+ # Extract X from the original filename
102
+ X="${file#人声_}" # Remove "人声_" prefix
103
+ X="${X%_vocals.mp3}" # Remove "_vocals.mp3" suffix
104
+
105
+ # New filename
106
+ new_filename="${X}-人声.mp3"
107
+ new_file="$output_folder/$new_filename"
108
+
109
+ # Rename the file
110
+ mv "$original_file" "$new_file"
111
+ fi
112
+ done
113
+
114
+
115
+ echo -e "\033[32m> 已将所有input文件夹内的音频完成分离,人声在 /mnt/workspace/uvr5/人声/ 文件夹内,伴奏及和声在 /mnt/workspace/uvr5/伴奏/ 文件夹内。 \033[0m"
仅去和声混响.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Change directory
4
+ cd /mnt/workspace/uvr5
5
+
6
+ # Run 5_HP-Karaoke-UVR.py
7
+ python 5_HP-Karaoke-UVR.py
8
+
9
+ # Convert mp3 files to wav
10
+ source_folder="/mnt/workspace/uvr5/echo"
11
+ for mp3_file in $(ls $source_folder/*.mp3)
12
+ do
13
+ wav_file="${mp3_file%.mp3}.wav"
14
+ mv $mp3_file $wav_file
15
+ done
16
+
17
+ # Move and convert files
18
+ target_folder="/mnt/workspace/uvr5/伴奏"
19
+ for file_name in $(ls $source_folder)
20
+ do
21
+ if [[ $file_name == *"和声_"* && $file_name == *.wav ]]
22
+ then
23
+ file_path="$source_folder/$file_name"
24
+ target_path="$target_folder/$file_name"
25
+ mv $file_path $target_path
26
+ mp3_file_path="${target_path%.wav}.mp3"
27
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $mp3_file_path
28
+ rm $target_path
29
+ fi
30
+ done
31
+
32
+ # Run deecho.py
33
+ python deecho.py -d cuda -model_path /mnt/workspace/uvr5/uvr5_weights/VR-DeEchoAggressive.pth -audio_path /mnt/workspace/uvr5/echo/ -is_half False -save_path /mnt/workspace/uvr5/人声/ -model_params 4band_v3
34
+
35
+ # Convert files to mp3 and remove wav files
36
+ input_folder='/mnt/workspace/uvr5/人声/'
37
+ output_folder='/mnt/workspace/uvr5/人声/'
38
+ for file in $(ls $input_folder)
39
+ do
40
+ if [[ $file == *"人声_"* && $file == *.wav ]]
41
+ then
42
+ input_path="$input_folder/$file"
43
+ output_file="${file%.wav}.mp3"
44
+ output_path="$output_folder/$output_file"
45
+ ffmpeg -i $input_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $output_path
46
+ fi
47
+ done
48
+
49
+ # Remove wav files
50
+ for file in $(ls $input_folder)
51
+ do
52
+ if [[ $file == *.wav ]]
53
+ then
54
+ file_path="$input_folder/$file"
55
+ rm $file_path
56
+ fi
57
+ done
58
+ echo -e "\033[32m> 已将所有input文件夹内的音频去除和声及混响,人声在 /mnt/workspace/uvr5/人声/ 文件夹内,非人声在 /mnt/workspace/uvr5/伴奏/ 文件夹内。 \033[0m"
全流程一键版-混音.sh ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Change directory
4
+ cd /mnt/workspace/uvr5/MVSEP-MDX23-Colab_v2
5
+
6
+ # Set input and output folders
7
+ input_folder='/mnt/workspace/input/'
8
+ output_folder='/mnt/workspace/uvr5/output'
9
+
10
+ # Process each file in the input folder
11
+ for file_path in $(ls -v $input_folder/*)
12
+ do
13
+ filename=$(basename $file_path)
14
+ filename="${filename%.*}"
15
+ python inference.py --large_gpu --weight_MDXv3 8 --weight_VOCFT 3 --weight_HQ3 2 --chunk_size 1999999 --input_audio "$file_path" --overlap_demucs 0.6 --overlap_MDX 0 --overlap_MDXv3 8 --output_format 'PCM_16' --bigshifts 6 --output_folder "$output_folder" --vocals_only true
16
+ done
17
+
18
+ # Move and convert files
19
+ source_folder="/mnt/workspace/uvr5/output"
20
+ target_folder="/mnt/workspace/uvr5/伴奏"
21
+ for file_name in $(ls $source_folder)
22
+ do
23
+ if [[ $file_name == *"_instrum.wav" ]]
24
+ then
25
+ file_path="$source_folder/$file_name"
26
+ target_path="$target_folder/$file_name"
27
+ mv $file_path $target_path
28
+ mp3_file_path="${target_path%.wav}.mp3"
29
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $mp3_file_path
30
+ rm $target_path
31
+ fi
32
+ done
33
+
34
+ # Change directory
35
+ cd /mnt/workspace/uvr5
36
+
37
+ # Run uvr.py
38
+ python uvr.py
39
+
40
+ # Move and convert files
41
+ source_folder="/mnt/workspace/uvr5/echo"
42
+ target_folder="/mnt/workspace/uvr5/伴奏"
43
+ for file_name in $(ls $source_folder)
44
+ do
45
+ if [[ $file_name == *"和声_"* && $file_name == *.wav ]]
46
+ then
47
+ file_path="$source_folder/$file_name"
48
+ target_path="$target_folder/$file_name"
49
+ mv $file_path $target_path
50
+ mp3_file_path="${target_path%.wav}.mp3"
51
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $mp3_file_path
52
+ rm $target_path
53
+ fi
54
+ done
55
+
56
+ # Run deecho.py
57
+ python deecho.py -d cuda -model_path /mnt/workspace/uvr5/uvr5_weights/VR-DeEchoAggressive.pth -audio_path /mnt/workspace/uvr5/echo/ -is_half False -save_path /mnt/workspace/uvr5/人声/ -model_params 4band_v3
58
+
59
+ # Convert files to mp3 and remove wav files
60
+ input_folder='/mnt/workspace/uvr5/人声/'
61
+ output_folder='/mnt/workspace/uvr5/人声/'
62
+ for file in $(ls $input_folder)
63
+ do
64
+ if [[ $file == *"人声_"* && $file == *.wav ]]
65
+ then
66
+ input_path="$input_folder/$file"
67
+ output_file="${file%.wav}.mp3"
68
+ output_path="$output_folder/$output_file"
69
+ ffmpeg -i $input_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $output_path
70
+ fi
71
+ done
72
+
73
+ # Remove wav files
74
+ for file in $(ls $input_folder)
75
+ do
76
+ if [[ $file == *.wav ]]
77
+ then
78
+ file_path="$input_folder/$file"
79
+ rm $file_path
80
+ fi
81
+ done
82
+ # 重命名人声文件
83
+ for file in $(ls $output_folder)
84
+ do
85
+ if [[ $file == 人声_*_vocals.mp3 ]]
86
+ then
87
+ original_file="$output_folder/$file"
88
+
89
+ # Extract X from the original filename
90
+ X="${file#人声_}" # Remove "人声_" prefix
91
+ X="${X%_vocals.mp3}" # Remove "_vocals.mp3" suffix
92
+
93
+ # New filename
94
+ new_filename="${X}-人声.mp3"
95
+ new_file="$output_folder/$new_filename"
96
+
97
+ # Rename the file
98
+ mv "$original_file" "$new_file"
99
+ fi
100
+ done
101
+
102
+ # 将伴奏内的和声和伴奏混成一个文件
103
+ python3 <<EOF
104
+ import os
105
+ from pydub import AudioSegment
106
+
107
+ # 指定音频文件夹路径
108
+ audio_folder = "/mnt/workspace/uvr5/伴奏"
109
+ # 获取文件夹内所有的音频文件名
110
+ audio_files = os.listdir(audio_folder)
111
+ # 遍历每个音频文件
112
+ for vocals_filename in audio_files:
113
+ if vocals_filename.startswith("和声_") and vocals_filename.endswith("_vocals.mp3"):
114
+ # 构建对应的伴奏文件名
115
+ instrumental_filename = vocals_filename.replace("和声_", "").replace("_vocals.mp3", "_instrum.mp3")
116
+ instrumental_path = os.path.join(audio_folder, instrumental_filename)
117
+ # 检查伴奏文件是否存在
118
+ if os.path.isfile(instrumental_path):
119
+ # 使用pydub打开音频文件
120
+ instrumental = AudioSegment.from_file(instrumental_path)
121
+ vocals_path = os.path.join(audio_folder, vocals_filename)
122
+ vocals = AudioSegment.from_file(vocals_path)
123
+ # 确保两个音频文件的长度相同,进行裁剪或填充操作
124
+ if len(instrumental) != len(vocals):
125
+ if len(instrumental) > len(vocals):
126
+ vocals = vocals + AudioSegment.silent(duration=len(instrumental) - len(vocals))
127
+ else:
128
+ instrumental = instrumental + AudioSegment.silent(duration=len(vocals) - len(instrumental))
129
+ # 混合音频文件
130
+ mixed_audio = instrumental.overlay(vocals)
131
+ # 构建输出文件名,例如 "XX-伴奏.mp3"
132
+ output_filename = vocals_filename.replace("和声_", "").replace("_vocals.mp3", "-伴奏.mp3")
133
+ output_path = os.path.join(audio_folder, output_filename)
134
+ # 保存混音后的文件
135
+ mixed_audio.export(output_path, format="mp3")
136
+ # 删除原��的和声和伴奏文件
137
+ os.remove(vocals_path)
138
+ os.remove(instrumental_path)
139
+ print(f"混音完成,保存在 {output_path},原始文件已删除")
140
+ else:
141
+ print(f"找不到对应的伴奏文件 {instrumental_filename}")
142
+ EOF
143
+
144
+ echo -e "\033[32m> 已将所有input文件夹内的音频完成分离,人声在 /mnt/workspace/uvr5/人声/ 文件夹内,伴奏及和声在 /mnt/workspace/uvr5/伴奏/ 文件夹内。 \033[0m"
145
+
全流程一键版.sh ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Change directory
4
+ cd /mnt/workspace/uvr5/MVSEP-MDX23-Colab_v2
5
+
6
+ # Set input and output folders
7
+ input_folder='/mnt/workspace/input/'
8
+ output_folder='/mnt/workspace/uvr5/output'
9
+
10
+ # Process each file in the input folder
11
+ for file_path in $(ls -v $input_folder/*)
12
+ do
13
+ filename=$(basename $file_path)
14
+ filename="${filename%.*}"
15
+ python inference.py --large_gpu --weight_MDXv3 8 --weight_VOCFT 3 --weight_HQ3 2 --chunk_size 1999999 --input_audio "$file_path" --overlap_demucs 0.6 --overlap_MDX 0 --overlap_MDXv3 8 --output_format 'PCM_16' --bigshifts 6 --output_folder "$output_folder" --vocals_only true
16
+ done
17
+
18
+ # Move and convert files
19
+ source_folder="/mnt/workspace/uvr5/output"
20
+ target_folder="/mnt/workspace/uvr5/伴奏"
21
+ for file_name in $(ls $source_folder)
22
+ do
23
+ if [[ $file_name == *"_instrum.wav" ]]
24
+ then
25
+ file_path="$source_folder/$file_name"
26
+ target_path="$target_folder/$file_name"
27
+ mv $file_path $target_path
28
+ mp3_file_path="${target_path%.wav}.mp3"
29
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $mp3_file_path
30
+ rm $target_path
31
+ fi
32
+ done
33
+
34
+ # Change directory
35
+ cd /mnt/workspace/uvr5
36
+
37
+ # Run uvr.py
38
+ python uvr.py
39
+
40
+ # Move and convert files
41
+ source_folder="/mnt/workspace/uvr5/echo"
42
+ target_folder="/mnt/workspace/uvr5/伴奏"
43
+ for file_name in $(ls $source_folder)
44
+ do
45
+ if [[ $file_name == *"和声_"* && $file_name == *.wav ]]
46
+ then
47
+ file_path="$source_folder/$file_name"
48
+ target_path="$target_folder/$file_name"
49
+ mv $file_path $target_path
50
+ mp3_file_path="${target_path%.wav}.mp3"
51
+ ffmpeg -i $target_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $mp3_file_path
52
+ rm $target_path
53
+ fi
54
+ done
55
+
56
+ # Run deecho.py
57
+ python deecho.py -d cuda -model_path /mnt/workspace/uvr5/uvr5_weights/VR-DeEchoAggressive.pth -audio_path /mnt/workspace/uvr5/echo/ -is_half False -save_path /mnt/workspace/uvr5/人声/ -model_params 4band_v3
58
+
59
+ # Convert files to mp3 and remove wav files
60
+ input_folder='/mnt/workspace/uvr5/人声/'
61
+ output_folder='/mnt/workspace/uvr5/人声/'
62
+ for file in $(ls $input_folder)
63
+ do
64
+ if [[ $file == *"人声_"* && $file == *.wav ]]
65
+ then
66
+ input_path="$input_folder/$file"
67
+ output_file="${file%.wav}.mp3"
68
+ output_path="$output_folder/$output_file"
69
+ ffmpeg -i $input_path -vn -ar 44100 -ac 2 -b:a 192k -loglevel panic $output_path
70
+ fi
71
+ done
72
+
73
+ # Remove wav files
74
+ for file in $(ls $input_folder)
75
+ do
76
+ if [[ $file == *.wav ]]
77
+ then
78
+ file_path="$input_folder/$file"
79
+ rm $file_path
80
+ fi
81
+ done
82
+ # 重命名人声文件
83
+ for file in $(ls $output_folder)
84
+ do
85
+ if [[ $file == 人声_*_vocals.mp3 ]]
86
+ then
87
+ original_file="$output_folder/$file"
88
+
89
+ # Extract X from the original filename
90
+ X="${file#人声_}" # Remove "人声_" prefix
91
+ X="${X%_vocals.mp3}" # Remove "_vocals.mp3" suffix
92
+
93
+ # New filename
94
+ new_filename="${X}-人声.mp3"
95
+ new_file="$output_folder/$new_filename"
96
+
97
+ # Rename the file
98
+ mv "$original_file" "$new_file"
99
+ fi
100
+ done
101
+
102
+
103
+ echo -e "\033[32m> 已将所有input文件夹内的音频完成分离,人声在 /mnt/workspace/uvr5/人声/ 文件夹内,伴奏及和声在 /mnt/workspace/uvr5/伴奏/ 文件夹内。 \033[0m"
104
+