Update backend/open_webui/apps/audio/main.py
Browse files
backend/open_webui/apps/audio/main.py
CHANGED
@@ -253,8 +253,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|
253 |
body = body.decode("utf-8")
|
254 |
body = json.loads(body)
|
255 |
body["model"] = app.state.config.TTS_MODEL
|
256 |
-
query=body["input"]
|
257 |
-
print(query)
|
258 |
body = json.dumps(body).encode("utf-8")
|
259 |
except Exception:
|
260 |
pass
|
@@ -264,12 +264,13 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|
264 |
client = Client("https://s5k.cn/api/v1/studio/iic/CosyVoice-300M-WAIC/gradio/")
|
265 |
r= client.predict(
|
266 |
_sound_radio="中文女",
|
267 |
-
|
|
|
268 |
_seed=0,
|
269 |
api_name="/generate_audio"
|
270 |
|
271 |
)
|
272 |
-
print(r)
|
273 |
#r = requests.post(
|
274 |
# url=f"{app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
|
275 |
#data=body,
|
@@ -277,12 +278,13 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|
277 |
# stream=True,
|
278 |
#)
|
279 |
|
280 |
-
|
281 |
|
282 |
# Save the streaming content to a file
|
283 |
with open(file_path, "wb") as f:
|
284 |
-
|
285 |
-
f.write(
|
|
|
286 |
|
287 |
with open(file_body_path, "w") as f:
|
288 |
json.dump(json.loads(body.decode("utf-8")), f)
|
|
|
253 |
body = body.decode("utf-8")
|
254 |
body = json.loads(body)
|
255 |
body["model"] = app.state.config.TTS_MODEL
|
256 |
+
#query=body["input"]
|
257 |
+
#print(query)
|
258 |
body = json.dumps(body).encode("utf-8")
|
259 |
except Exception:
|
260 |
pass
|
|
|
264 |
client = Client("https://s5k.cn/api/v1/studio/iic/CosyVoice-300M-WAIC/gradio/")
|
265 |
r= client.predict(
|
266 |
_sound_radio="中文女",
|
267 |
+
# _synthetic_input_textbox={"query":query},
|
268 |
+
_synthetic_input_textbox=body,
|
269 |
_seed=0,
|
270 |
api_name="/generate_audio"
|
271 |
|
272 |
)
|
273 |
+
#print(r)
|
274 |
#r = requests.post(
|
275 |
# url=f"{app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
|
276 |
#data=body,
|
|
|
278 |
# stream=True,
|
279 |
#)
|
280 |
|
281 |
+
r.raise_for_status()
|
282 |
|
283 |
# Save the streaming content to a file
|
284 |
with open(file_path, "wb") as f:
|
285 |
+
for chunk in r.iter_content(chunk_size=8192):
|
286 |
+
f.write(chunk)
|
287 |
+
#f.write(r.content)
|
288 |
|
289 |
with open(file_body_path, "w") as f:
|
290 |
json.dump(json.loads(body.decode("utf-8")), f)
|