Spaces:
Running
Running
File size: 1,154 Bytes
0154ff9 deb2e44 da50094 9716e03 a39f438 939194c 9716e03 0154ff9 deb2e44 0154ff9 c14a9db 0154ff9 9716e03 0154ff9 0a07e49 e607d6c 0154ff9 217b172 0154ff9 2039774 0154ff9 217b172 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import os
import gradio as gr
from scipy.io.wavfile import write
import spaces
import numpy as np
import librosa
def resample_audio(audio, target_sample_rate):
current_sample_rate, audio_data = audio
audio_data = audio_data.astype(np.float32)
if current_sample_rate != target_sample_rate:
resampled_audio_data = librosa.resample(audio_data, orig_sr=current_sample_rate, target_sr=target_sample_rate)
return target_sample_rate, resampled_audio_data
return audio
@spaces.GPU
def inference(audio):
os.system("pwd")
os.makedirs("out", exist_ok=True)
target_sample_rate = 44100
audio = resample_audio(audio, target_sample_rate)
write('test.wav', audio[0], audio[1])
os.system("python3 -m demucs.separate -n mdx_extra_q --two-stems=vocals test.wav -o out")
return "./out/mdx_extra_q/test/vocals.wav","./out/mdx_extra_q/test/no_vocals.wav"
title = "음성 분리"
demo = gr.Interface(
inference,
gr.Audio(type="numpy", label="Input"),
[gr.Audio(type="filepath", label="음성"),gr.Audio(type="filepath", label="배경음")],
title=title,
)
demo.queue(max_size=1)
demo.launch(debug=True) |