Skip to content

Commit

Permalink
修复语音输入调用函数出错bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed May 17, 2024
1 parent 43867f0 commit 8ad3a8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ def get_priority_level(data_json):
# 查找插入位置
new_data_priority = get_priority_level(data_json)

logging.info(f"{type} 优先级: {new_data_priority}")

if type == "等待合成消息":
logging.info(f"{type} 优先级: {new_data_priority} 内容:【{data_json['content']}】")

# 如果新数据没有 'type' 键或其类型不在 priority_mapping 中,直接插入到末尾
if new_data_priority is None:
insert_position = len(Audio.message_queue)
Expand Down Expand Up @@ -459,6 +459,8 @@ def get_priority_level(data_json):

return {"code": 200, "msg": f"数据已插入到位置 {insert_position}"}
else:
logging.info(f"{type} 优先级: {new_data_priority} 音频={data_json['voice_path']}")

# 如果新数据没有 'type' 键或其类型不在 priority_mapping 中,直接插入到末尾
if new_data_priority is None:
insert_position = len(Audio.voice_tmp_path_queue)
Expand All @@ -479,7 +481,7 @@ def get_priority_level(data_json):

# 数据队列数据量超长判断,插入位置索引大于最大数,则说明优先级低与队列中已存在数据,丢弃数据
if insert_position >= int(self.config.get("filter", "voice_tmp_path_queue_max_len")):
logging.info(f"voice_tmp_path_queue 已满,数据丢弃:【{data_json['voice_path']}】")
logging.info(f"voice_tmp_path_queue 已满,音频丢弃:【{data_json['voice_path']}】")
return {"code": 1, "msg": f"voice_tmp_path_queue 已满,音频丢弃:【{data_json['voice_path']}】"}

# 获取线程锁,避免同时操作
Expand Down
2 changes: 1 addition & 1 deletion utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3157,7 +3157,7 @@ def process_last_data(self, timer_flag):
elif timer_flag == "talk":
# 聊天暂时共用弹幕处理逻辑
for data in timer.last_data:
self.comment_handle(data)
self.talk_handle(data)
#self.comment_handle(timer.last_data)
elif timer_flag == "schedule":
# 定时任务处理
Expand Down

0 comments on commit 8ad3a8b

Please sign in to comment.