File size: 954 Bytes
798b4d1
f052899
1ded5ed
798b4d1
a2cc1ee
f052899
c213b7f
f052899
 
 
 
 
c213b7f
f052899
 
241ae1b
f052899
 
c213b7f
f052899
 
c213b7f
 
f052899
c213b7f
798b4d1
2a521ec
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
import gradio as gr
import os, subprocess
from pydub import AudioSegment

def convert(input_file):
    # 저장할 경로 지정
    path = "input/audio/"
    os.makedirs(path)

    # 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 = "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 Input Voice"), outputs=gr.File(label="Download Result"))
iface.launch()