Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,11 +27,8 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
|
|
| 27 |
index_rate
|
| 28 |
):
|
| 29 |
try:
|
| 30 |
-
if
|
| 31 |
-
|
| 32 |
-
else:
|
| 33 |
-
if input_audio is None:
|
| 34 |
-
return "You need to upload an audio", None
|
| 35 |
sampling_rate, audio = input_audio
|
| 36 |
duration = audio.shape[0] / sampling_rate
|
| 37 |
if duration > 10000000:
|
|
@@ -41,6 +38,9 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
|
|
| 41 |
audio = librosa.to_mono(audio.transpose(1, 0))
|
| 42 |
if sampling_rate != 16000:
|
| 43 |
audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
|
|
|
|
|
|
|
|
|
|
| 44 |
times = [0, 0, 0]
|
| 45 |
f0_up_key = int(f0_up_key)
|
| 46 |
audio_opt = vc.pipeline(
|
|
@@ -66,6 +66,7 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
|
|
| 66 |
return info, (None, None)
|
| 67 |
return vc_fn
|
| 68 |
|
|
|
|
| 69 |
def load_hubert():
|
| 70 |
global hubert_model
|
| 71 |
models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
|
|
@@ -154,4 +155,16 @@ if __name__ == '__main__':
|
|
| 154 |
vc_output1 = gr.Textbox(label="Output Message")
|
| 155 |
vc_output2 = gr.Audio(label="Output Audio")
|
| 156 |
vc_submit.click(vc_fn, [vc_input, vc_transpose, vc_f0method, vc_index_ratio], [vc_output1, vc_output2])
|
| 157 |
-
app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
index_rate
|
| 28 |
):
|
| 29 |
try:
|
| 30 |
+
# Check if input_audio is a tuple (Gradio input)
|
| 31 |
+
if isinstance(input_audio, tuple):
|
|
|
|
|
|
|
|
|
|
| 32 |
sampling_rate, audio = input_audio
|
| 33 |
duration = audio.shape[0] / sampling_rate
|
| 34 |
if duration > 10000000:
|
|
|
|
| 38 |
audio = librosa.to_mono(audio.transpose(1, 0))
|
| 39 |
if sampling_rate != 16000:
|
| 40 |
audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
|
| 41 |
+
else: # Assume it's a file path
|
| 42 |
+
audio, sr = librosa.load(input_audio, sr=16000, mono=True)
|
| 43 |
+
|
| 44 |
times = [0, 0, 0]
|
| 45 |
f0_up_key = int(f0_up_key)
|
| 46 |
audio_opt = vc.pipeline(
|
|
|
|
| 66 |
return info, (None, None)
|
| 67 |
return vc_fn
|
| 68 |
|
| 69 |
+
|
| 70 |
def load_hubert():
|
| 71 |
global hubert_model
|
| 72 |
models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
|
|
|
|
| 155 |
vc_output1 = gr.Textbox(label="Output Message")
|
| 156 |
vc_output2 = gr.Audio(label="Output Audio")
|
| 157 |
vc_submit.click(vc_fn, [vc_input, vc_transpose, vc_f0method, vc_index_ratio], [vc_output1, vc_output2])
|
| 158 |
+
app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)
|
| 159 |
+
iface = gr.Interface(
|
| 160 |
+
fn=create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy),
|
| 161 |
+
inputs=[
|
| 162 |
+
gr.inputs.Audio(source="microphone", type="numpy", sample_rate=16000),
|
| 163 |
+
gr.inputs.Slider(minimum=-12, maximum=12, step=1, default=0),
|
| 164 |
+
gr.inputs.Radio(["world", "dio"], label="F0 method"),
|
| 165 |
+
gr.inputs.Slider(minimum=0, maximum=1, step=0.01, default=0.5)
|
| 166 |
+
],
|
| 167 |
+
outputs="text",
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
iface.launch()
|