mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-20 21:57:14 +08:00
fix: merge plugins to dev
This commit is contained in:
@@ -56,14 +56,15 @@ class WechatChannel(Channel):
|
||||
# start message listener
|
||||
itchat.run()
|
||||
|
||||
# handle_* 系列函数处理收到的消息后构造context,然后调用handle函数处理context
|
||||
# context是一个字典,包含了消息的所有信息,包括以下key
|
||||
# handle_* 系列函数处理收到的消息后构造Context,然后传入handle函数中处理Context和发送回复
|
||||
# Context包含了消息的所有信息,包括以下属性
|
||||
# type 消息类型, 包括TEXT、VOICE、IMAGE_CREATE
|
||||
# content 消息内容,如果是TEXT类型,content就是文本内容,如果是VOICE类型,content就是语音文件名,如果是IMAGE_CREATE类型,content就是图片生成命令
|
||||
# session_id: 会话id
|
||||
# isgroup: 是否是群聊
|
||||
# msg: 原始消息对象
|
||||
# receiver: 需要回复的对象
|
||||
# kwargs 附加参数字典,包含以下的key:
|
||||
# session_id: 会话id
|
||||
# isgroup: 是否是群聊
|
||||
# receiver: 需要回复的对象
|
||||
# msg: itchat的原始消息对象
|
||||
|
||||
def handle_voice(self, msg):
|
||||
if conf().get('speech_recognition') != True:
|
||||
|
||||
@@ -194,12 +194,12 @@ class WechatyChannel(Channel):
|
||||
try:
|
||||
if not query:
|
||||
return
|
||||
context = dict()
|
||||
context = Context(ContextType.TEXT, query)
|
||||
context['session_id'] = reply_user_id
|
||||
reply_text = super().build_reply_content(query, context)
|
||||
reply_text = super().build_reply_content(query, context).content
|
||||
if reply_text:
|
||||
# 转换 mp3 文件为 silk 格式
|
||||
mp3_file = super().build_text_to_voice(reply_text)
|
||||
mp3_file = super().build_text_to_voice(reply_text).content
|
||||
silk_file = mp3_file.replace(".mp3", ".silk")
|
||||
# Load the MP3 file
|
||||
audio = AudioSegment.from_file(mp3_file, format="mp3")
|
||||
|
||||
Reference in New Issue
Block a user