#update: 添加mixed模型方案

This commit is contained in:
killua committed 2024-06-20 16:06:03 +08:00
1 parent 6354fe49f0
commit 55e2d7209c
2 files changed
+64 -3

No files matched your search

+8 -3
View File
@@ -226,14 +226,19 @@ async def streaming_chat(ws: WebSocket):
agent.recorder.input_text = prompt
logger.debug("开始调用大模型")
llm_frames = await agent.chat(assistant, prompt)
start_time = time.time()
is_first_response = True
async for llm_frame in llm_frames:
if is_first_response:
end_time = time.time()
logger.debug(f"第一帧返回耗时:{round(end_time-start_time,3)}s")
is_first_response = False
resp_msgs = agent.llm_msg_process(llm_frame)
for resp_msg in resp_msgs:
llm_text += resp_msg
tts_start_time = time.time()
tts_audio = agent.synthetize(assistant, resp_msg)
tts_end_time = time.time()
logger.debug(f"TTS生成音频耗时:{tts_end_time-tts_start_time}s")
agent.tts_audio_process(tts_audio)
await ws.send_bytes(agent.encode(resp_msg, tts_audio))
logger.debug(f'websocket返回:{resp_msg}')