|
import gradio as gr |
|
import os, subprocess |
|
from pydub import AudioSegment |
|
|
|
def convert(input_file): |
|
|
|
path = "/app/input/audio/" |
|
os.makedirs(path) |
|
|
|
sound = AudioSegment.from_mp3(input_file.name) |
|
|
|
|
|
sound = AudioSegment.from_file(input_file.name) |
|
sound = sound.set_frame_rate(44100).set_channels(1) |
|
sound.export("/app/input/audio/upload.wav", format="wav") |
|
|
|
model_name = "bmo-rev2" |
|
model_path = "/app/DDSP-SVC/models" |
|
keychange = "0" |
|
|
|
subprocess.run(['python', '/app/DDSP-SVC/main.py', '-i', "/app/input/audio/upload.wav", '-m', f'{model_path}/{model_name}.pt', '-o', '/app/result.wav', '-k', keychange, '-eak', '0']) |
|
|
|
|
|
sound = AudioSegment.from_wav("/result.wav") |
|
sound.export("/app/result.mp3", format="mp3", codec="libmp3lame", bitrate="128k") |
|
|
|
return "/app/result.mp3" |
|
|
|
iface = gr.Interface(fn=convert, inputs=gr.File(label="Upload MP3"), outputs=gr.File(label="Download Opus")) |
|
iface.launch() |