Spaces:
Runtime error
Runtime error
pengdaqian
commited on
Commit
·
134cf2b
1
Parent(s):
f5b2ba1
fix
Browse files
app.py
CHANGED
|
@@ -90,6 +90,9 @@ separator = Separator('spleeter:2stems')
|
|
| 90 |
audio_loader = AudioAdapter.default()
|
| 91 |
whisper_model = whisper.inference.load_model(os.path.join("whisper_pretrain", "medium.pt"))
|
| 92 |
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
def svc_change(argswave, argsspk):
|
| 95 |
argsppg = "svc_tmp.ppg.npy"
|
|
@@ -183,17 +186,6 @@ def np_to_audio_segment(fp_arr):
|
|
| 183 |
return sound
|
| 184 |
|
| 185 |
|
| 186 |
-
def get_dtype_max_value(dtype):
|
| 187 |
-
if np.issubdtype(dtype, np.integer):
|
| 188 |
-
info = np.iinfo(dtype)
|
| 189 |
-
return info.max
|
| 190 |
-
elif np.issubdtype(dtype, np.floating):
|
| 191 |
-
info = np.finfo(dtype)
|
| 192 |
-
return info.max
|
| 193 |
-
else:
|
| 194 |
-
raise ValueError("不支持的 dtype 类型")
|
| 195 |
-
|
| 196 |
-
|
| 197 |
def svc_main(sid, input_audio):
|
| 198 |
if input_audio is None:
|
| 199 |
return "You need to upload an audio", None
|
|
@@ -248,11 +240,13 @@ def auto_search(name):
|
|
| 248 |
os.makedirs(save_music_path)
|
| 249 |
config = {'logfilepath': 'musicdl.log', save_music_path: 'downloaded', 'search_size_per_source': 5, 'proxies': {}}
|
| 250 |
albums = get_albums(keywords=name, config=config)
|
|
|
|
|
|
|
| 251 |
album = random.choice(albums)
|
| 252 |
save_path = get_random_spit(album)
|
| 253 |
fp = save_path
|
| 254 |
signal, sampling_rate = soundfile.read(fp)
|
| 255 |
-
return sampling_rate, signal
|
| 256 |
|
| 257 |
|
| 258 |
app = gr.Blocks()
|
|
@@ -321,12 +315,13 @@ with app:
|
|
| 321 |
|
| 322 |
with gr.Column():
|
| 323 |
vc_input3 = gr.Audio(label="Upload Music Yourself")
|
| 324 |
-
vc_search.click(auto_search, [vc_input2], [vc_input3])
|
| 325 |
vc_submit = gr.Button("Convert", variant="primary")
|
| 326 |
|
| 327 |
with gr.Column():
|
| 328 |
vc_output1 = gr.Textbox(label="Run Status")
|
| 329 |
vc_output2 = gr.Audio(label="Result Audio")
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
|
| 332 |
app.launch()
|
|
|
|
| 90 |
audio_loader = AudioAdapter.default()
|
| 91 |
whisper_model = whisper.inference.load_model(os.path.join("whisper_pretrain", "medium.pt"))
|
| 92 |
|
| 93 |
+
# warm up
|
| 94 |
+
separator.separate_to_file('warm.wav', '/tmp/warm')
|
| 95 |
+
|
| 96 |
|
| 97 |
def svc_change(argswave, argsspk):
|
| 98 |
argsppg = "svc_tmp.ppg.npy"
|
|
|
|
| 186 |
return sound
|
| 187 |
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
def svc_main(sid, input_audio):
|
| 190 |
if input_audio is None:
|
| 191 |
return "You need to upload an audio", None
|
|
|
|
| 240 |
os.makedirs(save_music_path)
|
| 241 |
config = {'logfilepath': 'musicdl.log', save_music_path: 'downloaded', 'search_size_per_source': 5, 'proxies': {}}
|
| 242 |
albums = get_albums(keywords=name, config=config)
|
| 243 |
+
if len(albums) == 0:
|
| 244 |
+
return "No music found", None
|
| 245 |
album = random.choice(albums)
|
| 246 |
save_path = get_random_spit(album)
|
| 247 |
fp = save_path
|
| 248 |
signal, sampling_rate = soundfile.read(fp)
|
| 249 |
+
return "Found a music", (sampling_rate, signal)
|
| 250 |
|
| 251 |
|
| 252 |
app = gr.Blocks()
|
|
|
|
| 315 |
|
| 316 |
with gr.Column():
|
| 317 |
vc_input3 = gr.Audio(label="Upload Music Yourself")
|
|
|
|
| 318 |
vc_submit = gr.Button("Convert", variant="primary")
|
| 319 |
|
| 320 |
with gr.Column():
|
| 321 |
vc_output1 = gr.Textbox(label="Run Status")
|
| 322 |
vc_output2 = gr.Audio(label="Result Audio")
|
| 323 |
+
|
| 324 |
+
vc_search.click(auto_search, [vc_input2], [vc_output1, vc_input3])
|
| 325 |
+
vc_submit.click(svc_main, [sid, vc_input3], [vc_output1, vc_output2])
|
| 326 |
|
| 327 |
app.launch()
|