From 4fd7e4be6777fc0ae638077a8eb6fb32e69afefe Mon Sep 17 00:00:00 2001 From: lanvent Date: Wed, 29 Mar 2023 16:46:55 +0800 Subject: [PATCH] fix: ignore remove file failed --- channel/wechat/wechat_channel.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index abbe298..f3cbd16 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -277,8 +277,12 @@ class WechatChannel(Channel): # 语音识别 reply = super().build_voice_to_text(wav_path) # 删除临时文件 - os.remove(wav_path) - os.remove(mp3_path) + try: + os.remove(wav_path) + os.remove(mp3_path) + except Exception as e: + logger.warning("[WX]delete temp file error: " + str(e)) + if reply.type != ReplyType.ERROR and reply.type != ReplyType.INFO: content = reply.content # 语音转文字后,将文字内容作为新的context context.type = ContextType.TEXT