Browse Source

修复接语音回复失效的问题

develop
chenzhenkun 1 year ago
parent
commit
ca25d0433f
2 changed files with 9 additions and 0 deletions
  1. +3
    -0
      channel/wework/wework_channel.py
  2. +6
    -0
      channel/wework/wework_message.py

+ 3
- 0
channel/wework/wework_channel.py View File

@@ -302,5 +302,8 @@ class WeworkChannel(ChatChannel):
wework.send_video(receiver, video_path) wework.send_video(receiver, video_path)
logger.info("[WX] sendVideo, receiver={}".format(receiver)) logger.info("[WX] sendVideo, receiver={}".format(receiver))
elif reply.type == ReplyType.VOICE: elif reply.type == ReplyType.VOICE:
current_dir = os.getcwd()
voice_file = reply.content.split("/")[-1]
reply.content = os.path.join(current_dir, "tmp", voice_file)
wework.send_file(receiver, reply.content) wework.send_file(receiver, reply.content)
logger.info("[WX] sendFile={}, receiver={}".format(reply.content, receiver)) logger.info("[WX] sendFile={}, receiver={}".format(reply.content, receiver))

+ 6
- 0
channel/wework/wework_message.py View File

@@ -69,6 +69,12 @@ def c2c_download_and_convert(wework, message, file_name):
wav_file = base_name + ".wav" wav_file = base_name + ".wav"
pilk.silk_to_wav(save_path, wav_file, rate=24000) pilk.silk_to_wav(save_path, wav_file, rate=24000)


# 删除SILK文件
try:
os.remove(save_path)
except Exception as e:
pass



class WeworkMessage(ChatMessage): class WeworkMessage(ChatMessage):
def __init__(self, wework_msg, wework, is_group=False): def __init__(self, wework_msg, wework, is_group=False):


Loading…
Cancel
Save