Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -112,38 +112,35 @@ def predict(prompt, style, audio_file_pth, agree):
|
|
112 |
response = requests.post(API_URL, json=data, headers=headers, timeout=60)
|
113 |
print(f'Get response successfully within {time.time() - start}')
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
120 |
gr.Warning(
|
121 |
-
f"[ERROR] {json_data['error']} \n"
|
122 |
)
|
123 |
return (
|
124 |
text_hint,
|
125 |
None,
|
126 |
None,
|
127 |
)
|
128 |
-
|
|
|
129 |
with open(save_path, 'wb') as f:
|
130 |
-
f.write(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
None,
|
139 |
-
None,
|
140 |
-
)
|
141 |
-
text_hint += f'''Get response successfully \n'''
|
142 |
-
return (
|
143 |
-
text_hint,
|
144 |
-
save_path,
|
145 |
-
speaker_wav,
|
146 |
-
)
|
147 |
|
148 |
|
149 |
title = "MyShell OpenVoice"
|
|
|
112 |
response = requests.post(API_URL, json=data, headers=headers, timeout=60)
|
113 |
print(f'Get response successfully within {time.time() - start}')
|
114 |
|
115 |
+
task_id = response.json()['task_id']
|
116 |
+
while True:
|
117 |
+
response = requests.post(API_URL.replace('run', 'get_result'), json={'task_id': task_id}, headers=headers)
|
118 |
+
json_data = response.json()
|
119 |
+
status = json_data['status']
|
120 |
+
if status in ["CREATED", "RUNNING"]:
|
121 |
+
time.sleep(1)
|
122 |
+
continue
|
123 |
+
if status == 'FAILED':
|
124 |
+
text_hint += f"[HTTP ERROR] {json_data['error']} \n"
|
125 |
gr.Warning(
|
126 |
+
f"[HTTP ERROR] {json_data['error']} \n"
|
127 |
)
|
128 |
return (
|
129 |
text_hint,
|
130 |
None,
|
131 |
None,
|
132 |
)
|
133 |
+
else:
|
134 |
+
decoded_bytes = base64.b64decode(json_data['result']['base64'])
|
135 |
with open(save_path, 'wb') as f:
|
136 |
+
f.write(decoded_bytes)
|
137 |
+
|
138 |
+
text_hint += f'''Get response successfully \n'''
|
139 |
+
return (
|
140 |
+
text_hint,
|
141 |
+
save_path,
|
142 |
+
speaker_wav,
|
143 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
|
146 |
title = "MyShell OpenVoice"
|