pdjdev commited on
Commit
f052899
1 Parent(s): 3003326

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -1,10 +1,30 @@
1
  import gradio as gr
 
2
  from pydub import AudioSegment
3
 
4
  def convert(input_file):
 
 
 
 
5
  sound = AudioSegment.from_mp3(input_file.name)
6
- sound.export("output.opus", format="opus")
7
- return "output.opus"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  iface = gr.Interface(fn=convert, inputs=gr.File(label="Upload MP3"), outputs=gr.File(label="Download Opus"))
10
  iface.launch()
 
1
  import gradio as gr
2
+ import os, subprocess
3
  from pydub import AudioSegment
4
 
5
  def convert(input_file):
6
+ # 저장할 경로 지정
7
+ path = "/input/audio/"
8
+ os.makedirs(path)
9
+
10
  sound = AudioSegment.from_mp3(input_file.name)
11
+
12
+ # pydub를 사용하여 변환
13
+ sound = AudioSegment.from_file(input_file.name)
14
+ sound = sound.set_frame_rate(44100).set_channels(1)
15
+ sound.export("/input/audio/upload.wav", format="wav")
16
+
17
+ model_name = "bmo-rev2"
18
+ model_path = "/DDSP-SVC/models"
19
+ keychange = "0"
20
+
21
+ 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'])
22
+
23
+ # pydub를 사용하여 변환
24
+ sound = AudioSegment.from_wav("/result.wav")
25
+ sound.export("/result.mp3", format="mp3", codec="libmp3lame", bitrate="128k")
26
+
27
+ return "/result.mp3"
28
 
29
  iface = gr.Interface(fn=convert, inputs=gr.File(label="Upload MP3"), outputs=gr.File(label="Download Opus"))
30
  iface.launch()