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