update: 增加杂音屏蔽词,暂时停止记忆、情感识别功能
This commit is contained in:
1 parent
09ffeb6ab6
commit
2378fee258
2 files changed
+16
-10
No files matched your search
@@ -263,14 +263,15 @@ async def sct_asr_handler(ws,session_id,user_input_q,llm_input_q,user_input_fini
|
||||
current_message += ''.join(asr_result['text'])
|
||||
asr_result = asr.streaming_recognize(session_id,b'',is_end=True)
|
||||
current_message += ''.join(asr_result['text'])
|
||||
if current_message == "":
|
||||
slice_arr = ["嗯",""]
|
||||
if current_message in slice_arr:
|
||||
await ws.send_text(json.dumps({"type": "close", "code": 201, "msg": ""}, ensure_ascii=False))
|
||||
return
|
||||
current_message = asr.punctuation_correction(current_message)
|
||||
emotion_dict = asr.emtion_recognition(audio) #情感辨识
|
||||
if not isinstance(emotion_dict, str):
|
||||
max_index = emotion_dict['scores'].index(max(emotion_dict['scores']))
|
||||
current_message = f"{current_message},当前说话人的情绪:{emotion_dict['labels'][max_index]}"
|
||||
# emotion_dict = asr.emtion_recognition(audio) #情感辨识
|
||||
# if not isinstance(emotion_dict, str):
|
||||
# max_index = emotion_dict['scores'].index(max(emotion_dict['scores']))
|
||||
# current_message = f"{current_message},当前说话人的情绪:{emotion_dict['labels'][max_index]}"
|
||||
await llm_input_q.put(current_message)
|
||||
asr.session_signout(session_id)
|
||||
except Exception as e:
|
||||
@@ -288,8 +289,11 @@ async def sct_asr_handler(ws,session_id,user_input_q,llm_input_q,user_input_fini
|
||||
elif status == CONTINUE_FRAME:
|
||||
await xf_websocket.send(make_continue_frame(audio_data))
|
||||
await xf_websocket.send(make_last_frame(""))
|
||||
|
||||
|
||||
current_message = parse_xfasr_recv(json.loads(await xf_websocket.recv()))
|
||||
if current_message in ["","嗯"]:
|
||||
await ws.send_text(json.dumps({"type": "close", "code": 201, "msg": ""}, ensure_ascii=False))
|
||||
return
|
||||
await llm_input_q.put(current_message)
|
||||
logger.debug(f"接收到用户消息: {current_message}")
|
||||
|
||||
@@ -305,9 +309,11 @@ async def sct_llm_handler(ws,session_id,response_type,llm_info,tts_info,db,redis
|
||||
user_info = json.loads(session_content["user_info"])
|
||||
messages = json.loads(session_content["messages"])
|
||||
current_message = await llm_input_q.get()
|
||||
if current_message == "":
|
||||
return
|
||||
messages.append({'role': 'user', "content": current_message})
|
||||
messages_send = messages #创造一个message副本,在其中最后一条数据前面添加用户信息
|
||||
messages_send[-1]['content'] = f"用户性格:{user_info['character']}\n事件摘要:{user_info['events']}" + messages_send[-1]['content']
|
||||
# messages_send[-1]['content'] = f"用户性格:{user_info['character']}\n事件摘要:{user_info['events']}" + messages_send[-1]['content']
|
||||
payload = json.dumps({
|
||||
"model": llm_info["model"],
|
||||
"stream": True,
|
||||
|
||||
Reference in new issue
Block a user