Spaces:
Runtime error
Runtime error
testing deleting fast api
Browse files
main.py
CHANGED
@@ -9,15 +9,12 @@ import torch
|
|
9 |
import soundfile as sf
|
10 |
from demucs.apply import apply_model
|
11 |
from demucs.pretrained import DEFAULT_MODEL, get_model
|
12 |
-
|
13 |
from huggingface_hub import hf_hub_download, list_repo_files
|
14 |
-
from starlette.responses import StreamingResponse
|
15 |
|
16 |
from so_vits_svc_fork.hparams import HParams
|
17 |
from so_vits_svc_fork.inference.core import Svc
|
18 |
|
19 |
-
app = FastAPI()
|
20 |
-
|
21 |
###################################################################
|
22 |
# REPLACE THESE VALUES TO CHANGE THE MODEL REPO/CKPT NAME/SETTINGS
|
23 |
###################################################################
|
@@ -102,36 +99,20 @@ def predict(
|
|
102 |
return model.target_sample, out
|
103 |
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
with io.BytesIO(audio_bytes) as audio_io:
|
118 |
-
sample_rate, audio_data = predict(
|
119 |
-
speaker,
|
120 |
-
audio_io,
|
121 |
-
transpose=transpose,
|
122 |
-
auto_predict_f0=auto_predict_f0,
|
123 |
-
cluster_infer_ratio=cluster_infer_ratio,
|
124 |
-
noise_scale=noise_scale,
|
125 |
-
f0_method=f0_method
|
126 |
-
)
|
127 |
-
# Create a BytesIO object to hold the audio data
|
128 |
-
audio_byte_stream = io.BytesIO()
|
129 |
-
# Write the audio data to the BytesIO object
|
130 |
-
sf.write(audio_byte_stream, audio_data, sample_rate, format="wav")
|
131 |
-
# Create a StreamingResponse to return the audio
|
132 |
-
return StreamingResponse(io.BytesIO(audio_byte_stream.getvalue()), media_type="audio/wav")
|
133 |
|
|
|
134 |
|
135 |
if __name__ == "__main__":
|
136 |
-
|
137 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
9 |
import soundfile as sf
|
10 |
from demucs.apply import apply_model
|
11 |
from demucs.pretrained import DEFAULT_MODEL, get_model
|
12 |
+
import gradio as gr
|
13 |
from huggingface_hub import hf_hub_download, list_repo_files
|
|
|
14 |
|
15 |
from so_vits_svc_fork.hparams import HParams
|
16 |
from so_vits_svc_fork.inference.core import Svc
|
17 |
|
|
|
|
|
18 |
###################################################################
|
19 |
# REPLACE THESE VALUES TO CHANGE THE MODEL REPO/CKPT NAME/SETTINGS
|
20 |
###################################################################
|
|
|
99 |
return model.target_sample, out
|
100 |
|
101 |
|
102 |
+
def voice_cloning(speaker, audio):
|
103 |
+
sample_rate, audio_data = predict(speaker, audio)
|
104 |
+
return audio_data, sample_rate
|
105 |
+
|
106 |
+
|
107 |
+
# Configure the Gradio interface
|
108 |
+
inputs = [
|
109 |
+
gr.inputs.Dropdown(choices=speakers, label="Speaker"),
|
110 |
+
gr.inputs.Audio(label="Audio")
|
111 |
+
]
|
112 |
+
|
113 |
+
outputs = gr.outputs.Audio(label="Cloned Audio")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
+
iface = gr.Interface(fn=voice_cloning, inputs=inputs, outputs=outputs)
|
116 |
|
117 |
if __name__ == "__main__":
|
118 |
+
iface.launch()
|
|