update: 更新了进入沉默模式的功能

This commit is contained in:
killua committed 2024-06-12 22:56:39 +08:00
1 parent 76c7adc1b5
commit 34f3fd62f5
4 files changed
+34

No files matched your search

+6
View File
@@ -221,6 +221,12 @@ async def streaming_chat(ws: WebSocket,db=Depends(get_db)):
agent.recorder.output_text = llm_text
agent.save()
logger.debug("音频保存成功")
except EnterSlienceMode:
tts_audio = agent.synthetize(assistant, "已进入沉默模式", db)
await ws.send_bytes(agent.encode("已进入沉默模式", tts_audio))
await ws.send_text(json.dumps({"type":"info","code":201,"msg":"进入沉默模式"}, ensure_ascii=False))
except SlienceMode:
await ws.send_text(json.dumps({"type":"info","code":201,"msg":"处于沉默模式"}, ensure_ascii=False))
except AsrResultNoneError:
await ws.send_text(json.dumps({"type":"error","code":501,"msg":"asr结果为空"}, ensure_ascii=False))
except AbnormalLLMFrame as e: