diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 44cddd2..f3cad61 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -144,9 +144,11 @@ class ChatChannel(Channel): # 删除临时文件 try: os.remove(file_path) - os.remove(wav_path) + if wav_path != file_path: + os.remove(wav_path) except Exception as e: - logger.warning("[WX]delete temp file error: " + str(e)) + pass + # logger.warning("[WX]delete temp file error: " + str(e)) if reply.type == ReplyType.TEXT: new_context = self._compose_context( diff --git a/channel/wechat/wechaty_channel.py b/channel/wechat/wechaty_channel.py index 259ce82..85742bd 100644 --- a/channel/wechat/wechaty_channel.py +++ b/channel/wechat/wechaty_channel.py @@ -84,7 +84,8 @@ class WechatyChannel(ChatChannel): asyncio.run_coroutine_threadsafe(receiver.say(msg),loop).result() try: os.remove(file_path) - os.remove(sil_file) + if sil_file != file_path: + os.remove(sil_file) except Exception as e: pass logger.info('[WX] sendVoice={}, receiver={}'.format(reply.content, receiver))