Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
xVASynth synthesize return JSON
Browse files- app.py +10 -2
- resources/app/python/xvapitch/model.py +13 -11
- resources/app/server.py +1 -1
app.py
CHANGED
|
@@ -200,11 +200,16 @@ def predict(
|
|
| 200 |
response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
|
| 201 |
except requests.exceptions.RequestException as err:
|
| 202 |
print('Failed to synthesize!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
print('server.log contents:')
|
| 204 |
with open('resources/app/server.log', 'r') as f:
|
| 205 |
print(f.read())
|
| 206 |
|
| 207 |
-
return save_path
|
| 208 |
|
| 209 |
input_textbox = gr.Textbox(
|
| 210 |
label="Input Text",
|
|
@@ -259,7 +264,10 @@ gradio_app = gr.Interface(
|
|
| 259 |
sad_slider,
|
| 260 |
surprise_slider
|
| 261 |
],
|
| 262 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
| 263 |
title="xVASynth (WIP)",
|
| 264 |
clear_btn=gr.Button(visible=False)
|
| 265 |
# examples=[
|
|
|
|
| 200 |
response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
|
| 201 |
except requests.exceptions.RequestException as err:
|
| 202 |
print('Failed to synthesize!')
|
| 203 |
+
print('server.log contents:')
|
| 204 |
+
with open('resources/app/server.log', 'r') as f:
|
| 205 |
+
print(f.read())
|
| 206 |
+
return ['', err]
|
| 207 |
+
|
| 208 |
print('server.log contents:')
|
| 209 |
with open('resources/app/server.log', 'r') as f:
|
| 210 |
print(f.read())
|
| 211 |
|
| 212 |
+
return [save_path, response]
|
| 213 |
|
| 214 |
input_textbox = gr.Textbox(
|
| 215 |
label="Input Text",
|
|
|
|
| 264 |
sad_slider,
|
| 265 |
surprise_slider
|
| 266 |
],
|
| 267 |
+
outputs=[
|
| 268 |
+
gr.Audio(label="22kHz audio output", type="filepath"),
|
| 269 |
+
"text"
|
| 270 |
+
],
|
| 271 |
title="xVASynth (WIP)",
|
| 272 |
clear_btn=gr.Button(visible=False)
|
| 273 |
# examples=[
|
resources/app/python/xvapitch/model.py
CHANGED
|
@@ -753,17 +753,19 @@ class xVAPitch(object):
|
|
| 753 |
em_sad_pred.squeeze().cpu().detach().numpy() if em_sad_pred is not None else [],
|
| 754 |
em_surprise_pred.squeeze().cpu().detach().numpy() if em_surprise_pred is not None else [],
|
| 755 |
]
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
|
|
|
|
|
|
| 767 |
|
| 768 |
def set_device (self, device):
|
| 769 |
self.device = device
|
|
|
|
| 753 |
em_sad_pred.squeeze().cpu().detach().numpy() if em_sad_pred is not None else [],
|
| 754 |
em_surprise_pred.squeeze().cpu().detach().numpy() if em_surprise_pred is not None else [],
|
| 755 |
]
|
| 756 |
+
|
| 757 |
+
del pitch_pred, dur_pred, energy_pred, text, sequence
|
| 758 |
+
return {
|
| 759 |
+
"pitch": pitch,
|
| 760 |
+
"durations": durations,
|
| 761 |
+
"energy": energy,
|
| 762 |
+
"em_angry": em_angry,
|
| 763 |
+
"em_happy": em_happy,
|
| 764 |
+
"em_sad": em_sad,
|
| 765 |
+
"em_surprise": em_surprise,
|
| 766 |
+
"editorStyles": json.dumps(editorStyles),
|
| 767 |
+
"arpabet": all_cleaned_text
|
| 768 |
+
}
|
| 769 |
|
| 770 |
def set_device (self, device):
|
| 771 |
self.device = device
|
resources/app/server.py
CHANGED
|
@@ -131,7 +131,7 @@ if __name__ == '__main__':
|
|
| 131 |
class Handler(BaseHTTPRequestHandler):
|
| 132 |
def _set_response(self):
|
| 133 |
self.send_response(200)
|
| 134 |
-
self.send_header("Content-Type", "
|
| 135 |
self.end_headers()
|
| 136 |
|
| 137 |
def do_GET(self):
|
|
|
|
| 131 |
class Handler(BaseHTTPRequestHandler):
|
| 132 |
def _set_response(self):
|
| 133 |
self.send_response(200)
|
| 134 |
+
self.send_header("Content-Type", "application/json")
|
| 135 |
self.end_headers()
|
| 136 |
|
| 137 |
def do_GET(self):
|