Skip to content

Commit

Permalink
微信公众号语音输入支持 (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
JS00000 authored Apr 12, 2023
1 parent 28bd917 commit 88f4a45
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def func(_signo, _stack_frame):
conf().save_user_datas()
if callable(old_handler): # check old_handler
return old_handler(_signo, _stack_frame)
sys.exit(0)
signal.signal(_signo, func)

def run():
Expand Down
5 changes: 4 additions & 1 deletion channel/wechatmp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ sudo iptables-save > /etc/iptables/rules.v4
## 私有api_key
公共api有访问频率限制(免费账号每分钟最多20次ChatGPT的API调用),这在服务多人的时候会遇到问题。因此这里多加了一个设置私有api_key的功能。目前通过godcmd插件的命令来设置私有api_key。

## 语音输入
利用微信自带的语音识别功能,提供语音输入能力。需要在公众号管理页面的“设置与开发”->“接口权限”页面开启“接收语音识别结果”。

## 测试范围
目前在`RoboStyle`这个公众号上进行了测试(基于[wechatmp-stable分支](https://github.com/JS00000/chatgpt-on-wechat/tree/wechatmp-stable),而[master分支](https://github.com/zhayujie/chatgpt-on-wechat)含有最新功能,但是稳定性有待测试),感兴趣的可以关注并体验。开启了godcmd, Banwords, role, dungeon, finish这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。
目前在`RoboStyle`这个公众号上进行了测试基于[wechatmp分支](https://github.com/JS00000/chatgpt-on-wechat/tree/wechatmp),感兴趣的可以关注并体验。开启了godcmd, Banwords, role, dungeon, finish这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。

## TODO
* 服务号交互完善
Expand Down
2 changes: 1 addition & 1 deletion channel/wechatmp/ServiceAccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def POST(self):
webData = web.data()
# logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8"))
wechatmp_msg = receive.parse_xml(webData)
if wechatmp_msg.msg_type == 'text':
if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice':
from_user = wechatmp_msg.from_user_id
message = wechatmp_msg.content.decode("utf-8")
message_id = wechatmp_msg.msg_id
Expand Down
2 changes: 1 addition & 1 deletion channel/wechatmp/SubscribeAccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def POST(self):
webData = web.data()
logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8"))
wechatmp_msg = receive.parse_xml(webData)
if wechatmp_msg.msg_type == 'text':
if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice':
from_user = wechatmp_msg.from_user_id
to_user = wechatmp_msg.to_user_id
message = wechatmp_msg.content.decode("utf-8")
Expand Down

0 comments on commit 88f4a45

Please sign in to comment.