Skip to content

Commit 88f4a45

Browse files
authored
微信公众号语音输入支持 (zhayujie#808)
1 parent 28bd917 commit 88f4a45

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def func(_signo, _stack_frame):
1515
conf().save_user_datas()
1616
if callable(old_handler): # check old_handler
1717
return old_handler(_signo, _stack_frame)
18+
sys.exit(0)
1819
signal.signal(_signo, func)
1920

2021
def run():

channel/wechatmp/README.md

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

48+
## 语音输入
49+
利用微信自带的语音识别功能,提供语音输入能力。需要在公众号管理页面的“设置与开发”->“接口权限”页面开启“接收语音识别结果”。
50+
4851
## 测试范围
49-
目前在`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这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。
52+
目前在`RoboStyle`这个公众号上进行了测试基于[wechatmp分支](https://github.com/JS00000/chatgpt-on-wechat/tree/wechatmp),感兴趣的可以关注并体验。开启了godcmd, Banwords, role, dungeon, finish这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。
5053

5154
## TODO
5255
* 服务号交互完善

channel/wechatmp/ServiceAccount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def POST(self):
2121
webData = web.data()
2222
# logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8"))
2323
wechatmp_msg = receive.parse_xml(webData)
24-
if wechatmp_msg.msg_type == 'text':
24+
if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice':
2525
from_user = wechatmp_msg.from_user_id
2626
message = wechatmp_msg.content.decode("utf-8")
2727
message_id = wechatmp_msg.msg_id

channel/wechatmp/SubscribeAccount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def POST(self):
2222
webData = web.data()
2323
logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8"))
2424
wechatmp_msg = receive.parse_xml(webData)
25-
if wechatmp_msg.msg_type == 'text':
25+
if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice':
2626
from_user = wechatmp_msg.from_user_id
2727
to_user = wechatmp_msg.to_user_id
2828
message = wechatmp_msg.content.decode("utf-8")

0 commit comments

Comments
 (0)