紧急修复

--修复因流式音频结束标记提前而导致的麦克风风不释放问题;
--使用更短的文本切割。
This commit is contained in:
xszyou
2025-06-10 23:15:41 +08:00
parent f9ab99db4b
commit b4ecc6996b
2 changed files with 14 additions and 11 deletions

View File

@@ -322,7 +322,9 @@ class FeiFei:
if is_end and wsa_server.get_web_instance().is_connected(interact.data.get('user')):
wsa_server.get_web_instance().add_cmd({"panelMsg": "", 'Username' : interact.data.get('user'), 'robot': f'{cfg.fay_url}/robot/Normal.jpg'})
if result is not None or is_first or is_end:
if result is not None or is_first or is_end:
if is_end:#如果结束标记则延迟1秒处理,免得is end比前面的音频tts要快
time.sleep(1)
MyThread(target=self.__process_output_audio, args=[result, interact, text]).start()
return result
@@ -375,8 +377,9 @@ class FeiFei:
is_first = True
if interact.data.get('isend'):
is_end = True
util.printInfo(1, interact.data.get('user'), '播放音频...')
self.speaking = True
if file_url is not None:
util.printInfo(1, interact.data.get('user'), '播放音频...')
self.speaking = True
#自动播报关闭
global auto_play_lock
@@ -394,11 +397,11 @@ class FeiFei:
pygame.mixer.music.load(file_url)
pygame.mixer.music.play()
# 播放过程中计时,直到音频播放完毕
length = 0
while length < audio_length:
length += 0.01
time.sleep(0.01)
# 播放过程中计时,直到音频播放完毕
length = 0
while length < audio_length:
length += 0.01
time.sleep(0.01)
if is_end:
self.play_end(interact)

View File

@@ -108,7 +108,7 @@ def init_memory_scheduler():
schedule.every().day.at("00:00").do(save_agent_memory)
# 设置每天晚上11点执行反思
schedule.every().day.at("09:41").do(perform_daily_reflection)
schedule.every().day.at("23:00").do(perform_daily_reflection)
# 启动定时任务线程
scheduler_thread = MyThread(target=memory_scheduler_thread)
@@ -309,7 +309,7 @@ def question(content, username, observation=None):
current_username = username # 记录当前会话用户名
full_response_text = ""
accumulated_text = ""
punctuation_marks = ["", "", "", ".", "!", "?", "\n"]
punctuation_marks = [",", "","", "", "", ".", "!", "?", "\n"]
is_first_sentence = True
# 创建代理
@@ -385,7 +385,7 @@ def question(content, username, observation=None):
{observation}
"""
# 构建消息列表
messages = [SystemMessage(content=system_prompt), HumanMessage(content=content + "/no_think")]
messages = [SystemMessage(content=system_prompt), HumanMessage(content=content)]
# 1. 获取mcp工具
mcp_tools = get_mcp_tools()
# 2. 存在mcp工具走react agent