Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -78,14 +78,19 @@ def voice_vits_api():
|
|
78 |
noisew = float(request.args.get("noisew", app.config.get("NOISEW", 0.8)))
|
79 |
max = int(request.args.get("max", app.config.get("MAX", 50)))
|
80 |
elif request.method == "POST":
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
except Exception as e:
|
90 |
logger.error(f"[VITS] {e}")
|
91 |
return make_response("parameter error", 400)
|
@@ -192,15 +197,20 @@ def voice_w2v2_api():
|
|
192 |
max = int(request.args.get("max", app.config.get("MAX", 50)))
|
193 |
emotion = int(request.args.get("emotion", app.config.get("EMOTION", 0)))
|
194 |
elif request.method == "POST":
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
204 |
except Exception as e:
|
205 |
logger.error(f"[w2v2] {e}")
|
206 |
return make_response(f"parameter error", 400)
|
@@ -290,7 +300,12 @@ def vits_voice_conversion_api():
|
|
290 |
@require_api_key
|
291 |
def ssml():
|
292 |
try:
|
293 |
-
|
|
|
|
|
|
|
|
|
|
|
294 |
except Exception as e:
|
295 |
logger.info(f"[ssml] {e}")
|
296 |
return make_response(jsonify({"status": "error", "message": f"parameter error"}), 400)
|
@@ -338,8 +353,13 @@ def check():
|
|
338 |
model = request.args.get("model")
|
339 |
id = int(request.args.get("id"))
|
340 |
elif request.method == "POST":
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
343 |
except Exception as e:
|
344 |
logger.info(f"[check] {e}")
|
345 |
return make_response(jsonify({"status": "error", "message": "parameter error"}), 400)
|
@@ -389,3 +409,4 @@ def clean_task():
|
|
389 |
if __name__ == '__main__':
|
390 |
app.run(host='0.0.0.0', port=app.config.get("PORT", 23456), debug=app.config.get("DEBUG", False)) # 对外开放
|
391 |
# app.run(host='127.0.0.1', port=app.config.get("PORT",23456), debug=True) # 本地运行、调试
|
|
|
|
78 |
noisew = float(request.args.get("noisew", app.config.get("NOISEW", 0.8)))
|
79 |
max = int(request.args.get("max", app.config.get("MAX", 50)))
|
80 |
elif request.method == "POST":
|
81 |
+
content_type = request.headers.get('Content-Type')
|
82 |
+
if content_type == 'application/json':
|
83 |
+
data = request.get_json()
|
84 |
+
else:
|
85 |
+
data = request.form
|
86 |
+
text = data.get("text", "")
|
87 |
+
id = int(data.get("id", app.config.get("ID", 0)))
|
88 |
+
format = data.get("format", app.config.get("FORMAT", "wav"))
|
89 |
+
lang = data.get("lang", app.config.get("LANG", "auto"))
|
90 |
+
length = float(data.get("length", app.config.get("LENGTH", 1)))
|
91 |
+
noise = float(data.get("noise", app.config.get("NOISE", 0.667)))
|
92 |
+
noisew = float(data.get("noisew", app.config.get("NOISEW", 0.8)))
|
93 |
+
max = int(data.get("max", app.config.get("MAX", 50)))
|
94 |
except Exception as e:
|
95 |
logger.error(f"[VITS] {e}")
|
96 |
return make_response("parameter error", 400)
|
|
|
197 |
max = int(request.args.get("max", app.config.get("MAX", 50)))
|
198 |
emotion = int(request.args.get("emotion", app.config.get("EMOTION", 0)))
|
199 |
elif request.method == "POST":
|
200 |
+
content_type = request.headers.get('Content-Type')
|
201 |
+
if content_type == 'application/json':
|
202 |
+
data = request.get_json()
|
203 |
+
else:
|
204 |
+
data = request.form
|
205 |
+
text = data.get("text", "")
|
206 |
+
id = int(data.get("id", app.config.get("ID", 0)))
|
207 |
+
format = data.get("format", app.config.get("FORMAT", "wav"))
|
208 |
+
lang = data.get("lang", app.config.get("LANG", "auto"))
|
209 |
+
length = float(data.get("length"))
|
210 |
+
noise = float(data.get("noise", app.config.get("NOISE", 0.667)))
|
211 |
+
noisew = float(data.get("noisew", app.config.get("NOISEW", 0.8)))
|
212 |
+
max = int(data.get("max", app.config.get("MAX", 50)))
|
213 |
+
emotion = int(data.get("emotion", app.config.get("EMOTION", 0)))
|
214 |
except Exception as e:
|
215 |
logger.error(f"[w2v2] {e}")
|
216 |
return make_response(f"parameter error", 400)
|
|
|
300 |
@require_api_key
|
301 |
def ssml():
|
302 |
try:
|
303 |
+
content_type = request.headers.get('Content-Type')
|
304 |
+
if content_type == 'application/json':
|
305 |
+
data = request.get_json()
|
306 |
+
else:
|
307 |
+
data = request.form
|
308 |
+
ssml = data.get("ssml")
|
309 |
except Exception as e:
|
310 |
logger.info(f"[ssml] {e}")
|
311 |
return make_response(jsonify({"status": "error", "message": f"parameter error"}), 400)
|
|
|
353 |
model = request.args.get("model")
|
354 |
id = int(request.args.get("id"))
|
355 |
elif request.method == "POST":
|
356 |
+
content_type = request.headers.get('Content-Type')
|
357 |
+
if content_type == 'application/json':
|
358 |
+
data = request.get_json()
|
359 |
+
else:
|
360 |
+
data = request.form
|
361 |
+
model = data.get("model")
|
362 |
+
id = int(data.get("id"))
|
363 |
except Exception as e:
|
364 |
logger.info(f"[check] {e}")
|
365 |
return make_response(jsonify({"status": "error", "message": "parameter error"}), 400)
|
|
|
409 |
if __name__ == '__main__':
|
410 |
app.run(host='0.0.0.0', port=app.config.get("PORT", 23456), debug=app.config.get("DEBUG", False)) # 对外开放
|
411 |
# app.run(host='127.0.0.1', port=app.config.get("PORT",23456), debug=True) # 本地运行、调试
|
412 |
+
|