Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
@@ -5,10 +5,8 @@ import sys
|
|
5 |
sys.path.append('.')
|
6 |
import gradio as gr
|
7 |
os.system('pip install -U torchtext==0.8.0')
|
8 |
-
os.system('pip install pydub') # 添加对pydub库的依赖
|
9 |
#os.system('python setup.py install --install-dir .')
|
10 |
from scipy.io import wavfile
|
11 |
-
from pydub import AudioSegment
|
12 |
|
13 |
os.system('chmod a+x ./separate_scripts/*.sh')
|
14 |
os.system('chmod a+x ./scripts/*.sh')
|
@@ -16,19 +14,14 @@ os.system('chmod a+x ./scripts/*/*.sh')
|
|
16 |
os.system('./separate_scripts/download_checkpoints.sh')
|
17 |
|
18 |
def inference(audio):
|
19 |
-
# convert mp3 to wav if needed
|
20 |
-
if audio.name.endswith(".mp3"):
|
21 |
-
audio_wav = audio.name[:-4] + ".wav"
|
22 |
-
AudioSegment.from_file(audio.name).export(audio_wav, format="wav")
|
23 |
-
audio.name = audio_wav
|
24 |
# read the file and get the sample rate and data
|
25 |
rate, data = wavfile.read(audio.name)
|
26 |
|
27 |
# save the result
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
os.system("""python bytesep/inference.py --config_yaml=./scripts/4_train/musdb18/configs/accompaniment-vocals,resunet_subbandtime.yaml --checkpoint_path=./downloaded_checkpoints/resunet143_subbtandtime_accompaniment_16.4dB_350k_steps.pth --audio_path=
|
32 |
#os.system('./separate_scripts/separate_accompaniment.sh ' + audio.name + ' "sep_accompaniment.mp3"')
|
33 |
#os.system('python separate_scripts/separate.py --audio_path=' +audio.name+' --source_type="accompaniment"')
|
34 |
#os.system('python separate_scripts/separate.py --audio_path=' +audio.name+' --source_type="vocals"')
|
|
|
5 |
sys.path.append('.')
|
6 |
import gradio as gr
|
7 |
os.system('pip install -U torchtext==0.8.0')
|
|
|
8 |
#os.system('python setup.py install --install-dir .')
|
9 |
from scipy.io import wavfile
|
|
|
10 |
|
11 |
os.system('chmod a+x ./separate_scripts/*.sh')
|
12 |
os.system('chmod a+x ./scripts/*.sh')
|
|
|
14 |
os.system('./separate_scripts/download_checkpoints.sh')
|
15 |
|
16 |
def inference(audio):
|
|
|
|
|
|
|
|
|
|
|
17 |
# read the file and get the sample rate and data
|
18 |
rate, data = wavfile.read(audio.name)
|
19 |
|
20 |
# save the result
|
21 |
+
filename = 'foo_left' + os.path.splitext(audio.name)[-1] # 构造文件名,使用原文件名的后缀
|
22 |
+
wavfile.write(filename, rate, data)
|
23 |
+
os.system(f"""python bytesep/inference.py --config_yaml=./scripts/4_train/musdb18/configs/vocals-accompaniment,resunet_subbandtime.yaml --checkpoint_path=./downloaded_checkpoints/resunet143_subbtandtime_vocals_8.8dB_350k_steps.pth --audio_path={filename} --output_path=sep_vocals.mp3""")
|
24 |
+
os.system(f"""python bytesep/inference.py --config_yaml=./scripts/4_train/musdb18/configs/accompaniment-vocals,resunet_subbandtime.yaml --checkpoint_path=./downloaded_checkpoints/resunet143_subbtandtime_accompaniment_16.4dB_350k_steps.pth --audio_path={filename} --output_path=sep_accompaniment.mp3""")
|
25 |
#os.system('./separate_scripts/separate_accompaniment.sh ' + audio.name + ' "sep_accompaniment.mp3"')
|
26 |
#os.system('python separate_scripts/separate.py --audio_path=' +audio.name+' --source_type="accompaniment"')
|
27 |
#os.system('python separate_scripts/separate.py --audio_path=' +audio.name+' --source_type="vocals"')
|