add stream chat with TTS (#2228)

### What problem does this PR solve?



### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Kevin Hu
2024-09-03 19:49:14 +08:00
committed by GitHub
parent 07de36ec86
commit abc32803cc
2 changed files with 29 additions and 5 deletions

View File

@ -196,8 +196,8 @@ def tts():
tts_mdl = LLMBundle(tenants[0]["tenant_id"], LLMType.TTS, tts_id)
def stream_audio():
try:
for chunk in tts_mdl.tts(text):
yield chunk
for chunk in tts_mdl.tts(text):
yield chunk
except Exception as e:
yield ("data:" + json.dumps({"retcode": 500, "retmsg": str(e),
"data": {"answer": "**ERROR**: "+str(e)}},