'commit'
This commit is contained in:
@@ -84,15 +84,6 @@ async def streaming_chat(websocket: WebSocket):
|
||||
logger.error(f"发送ASR结果失败: {str(e)}")
|
||||
return
|
||||
|
||||
|
||||
# 获取学伴响应内容(包含题目信息)
|
||||
logger.info("获取学伴响应内容...")
|
||||
llm_chunks = []
|
||||
async for chunk in get_xueban_response_async(asr_result['text'], stream=True):
|
||||
llm_chunks.append(chunk)
|
||||
full_llm_response = ''.join(llm_chunks)
|
||||
logger.info(f"学伴响应内容: {full_llm_response}")
|
||||
|
||||
# 定义音频回调函数,将音频块发送给前端
|
||||
async def audio_callback(audio_chunk):
|
||||
logger.info(f"发送音频块,大小: {len(audio_chunk)}")
|
||||
@@ -103,12 +94,14 @@ async def streaming_chat(websocket: WebSocket):
|
||||
logger.error(f"发送音频块失败: {str(e)}")
|
||||
raise
|
||||
|
||||
# 修改streaming_chat函数中的相关部分
|
||||
# 实时获取LLM流式输出并处理
|
||||
logger.info("开始LLM流式处理和TTS合成...")
|
||||
try:
|
||||
# 直接使用stream_and_split_text获取LLM流式响应并断句
|
||||
text_stream = stream_and_split_text(query_text=asr_result['text'])
|
||||
# 获取LLM流式响应
|
||||
llm_stream = get_xueban_response_async(asr_result['text'], stream=True)
|
||||
|
||||
# 使用stream_and_split_text处理流式响应并断句
|
||||
text_stream = stream_and_split_text(llm_stream=llm_stream)
|
||||
|
||||
# 初始化TTS处理器
|
||||
tts = StreamingVolcanoTTS(max_concurrency=1)
|
||||
|
Reference in New Issue
Block a user