Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Radio switch voice model.
Browse files
app.py
CHANGED
|
@@ -61,13 +61,14 @@ def run_xvaserver():
|
|
| 61 |
print('xVAServer running on port 8008')
|
| 62 |
|
| 63 |
# load default model
|
| 64 |
-
load_model()
|
|
|
|
| 65 |
|
| 66 |
# Wait for the process to exit
|
| 67 |
xvaserver.wait()
|
| 68 |
|
| 69 |
-
def load_model():
|
| 70 |
-
model_path = models_path +
|
| 71 |
|
| 72 |
model_type = 'xVAPitch'
|
| 73 |
language = 'en'
|
|
@@ -84,15 +85,17 @@ def load_model():
|
|
| 84 |
try:
|
| 85 |
response = requests.post('http://0.0.0.0:8008/loadModel', json=data)
|
| 86 |
response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
|
|
|
|
| 87 |
except requests.exceptions.RequestException as err:
|
| 88 |
print('Failed to load voice model!')
|
|
|
|
| 89 |
return
|
| 90 |
|
| 91 |
-
def predict(input_text, pacing):
|
| 92 |
|
| 93 |
# load voice model if not the current model
|
| 94 |
-
|
| 95 |
-
|
| 96 |
|
| 97 |
model_type = 'xVAPitch'
|
| 98 |
pace = pacing if pacing else 1.0
|
|
@@ -134,12 +137,18 @@ input_textbox = gr.Textbox(
|
|
| 134 |
autofocus=True
|
| 135 |
)
|
| 136 |
pacing_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Pacing")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
gradio_app = gr.Interface(
|
| 139 |
predict,
|
| 140 |
[
|
| 141 |
input_textbox,
|
| 142 |
-
pacing_slider
|
|
|
|
| 143 |
],
|
| 144 |
outputs=gr.Audio(label="22kHz audio", type="filepath"),
|
| 145 |
title="xVASynth (WIP)"
|
|
|
|
| 61 |
print('xVAServer running on port 8008')
|
| 62 |
|
| 63 |
# load default model
|
| 64 |
+
load_model(voice_models[0])
|
| 65 |
+
current_voice_model = voice_models[0]
|
| 66 |
|
| 67 |
# Wait for the process to exit
|
| 68 |
xvaserver.wait()
|
| 69 |
|
| 70 |
+
def load_model(voice_model_name):
|
| 71 |
+
model_path = models_path + voice_model_name
|
| 72 |
|
| 73 |
model_type = 'xVAPitch'
|
| 74 |
language = 'en'
|
|
|
|
| 85 |
try:
|
| 86 |
response = requests.post('http://0.0.0.0:8008/loadModel', json=data)
|
| 87 |
response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
|
| 88 |
+
current_voice_model = voice_model_name
|
| 89 |
except requests.exceptions.RequestException as err:
|
| 90 |
print('Failed to load voice model!')
|
| 91 |
+
|
| 92 |
return
|
| 93 |
|
| 94 |
+
def predict(input_text, pacing, voice):
|
| 95 |
|
| 96 |
# load voice model if not the current model
|
| 97 |
+
if (current_voice_model != voice):
|
| 98 |
+
load_model(voice)
|
| 99 |
|
| 100 |
model_type = 'xVAPitch'
|
| 101 |
pace = pacing if pacing else 1.0
|
|
|
|
| 137 |
autofocus=True
|
| 138 |
)
|
| 139 |
pacing_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Pacing")
|
| 140 |
+
voice_radio = gr.Radio(
|
| 141 |
+
voice_models,
|
| 142 |
+
label="Voice",
|
| 143 |
+
info="NVIDIA HIFI CC-BY-4.0 model"
|
| 144 |
+
),
|
| 145 |
|
| 146 |
gradio_app = gr.Interface(
|
| 147 |
predict,
|
| 148 |
[
|
| 149 |
input_textbox,
|
| 150 |
+
pacing_slider,
|
| 151 |
+
voice_radio
|
| 152 |
],
|
| 153 |
outputs=gr.Audio(label="22kHz audio", type="filepath"),
|
| 154 |
title="xVASynth (WIP)"
|