File size: 1,014 Bytes
798b4d1 f052899 1ded5ed 798b4d1 a2cc1ee f052899 a2cc1ee f052899 798b4d1 3003326 249cf57 |
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 |
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() |