zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT4.0/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。

Home Page:https://docs.link-ai.tech/cow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于语音识别功能的使用

ShowUNow opened this issue · comments

commented

前置确认

  1. 网络能够访问openai接口 #351
  2. python 已安装:版本在 3.7 ~ 3.10 之间,依赖已安装
  3. 在已有 issue 中未搜索到类似问题
  4. FAQS 中无类似问题

问题描述

"voice_reply_voice": true这个语句没在config-template.json里找到,不过应该是添加到chatgpt-on-wechat/config.json里面吧?...

对应语音合成平台的key是阿里云的

终端日志 (如有报错)

环境

  • 操作系统类型 (Mac/Windows/Linux):Windows 10
  • Python版本 ( 执行 python3 -V ):python 3.9
  • pip版本 ( 依赖问题此项必填,执行 pip3 -V):pip 23.0.1
commented

同问,如何添加语音合成平台的api key

一、接收语音,回复文字

config.json 中设置 "speech_recognition": true 即可, 这个配置在 template中有。 启动程序后 私聊 就会支持语音识别,会对所有收到的语音消息转成文字,并回复文字。

二、接收语音,回复语音

有多种可选平台,以下提供两种方案,默认是OpenAI识别,Google语音合成:

1.百度

(1) 安装依赖: pip3 install baidu-aip chardet

(2) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true,
    "baidu_app_id": "YOUR BAIDU APP ID",
    "baidu_api_key": "YOUR BAIDU API KEY",
    "baidu_secret_key": "YOUR BAIDU SERVICE KEY"
}

2.Google

(1) 安装 SpeechRecognition: pip3 install SpeechRecognition

(2) 安装 ffmpeg 和 espeak

  • MacOS: brew install ffmpeg espeak
  • Windows: 下载ffmpeg.exe
  • Linux: apt-get install ffmpeg espeak

(3) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true
}

注:在itchat中只能回复mp3文件;在wechaty中可以回复语音消息,wechaty中使用需要安装额外依赖:

pip3 install pysilk-mod
pip3 install pydub

三、群组语音

"group_speech_recognition": true加入配置项

PR:
#385 by @wanggang1987
#476 by @Chiaki-Chan
#623 by @Chiaki-Chan

commented

你好。为什么我填好了之后还是提示这个错误呢?
[ERROR][2023-03-10 09:04:23][wechat_channel.py:151] - 'session_id' Traceback (most recent call last): File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\channel\wechat\wechat_channel.py", line 145, in _do_send_voice reply_text = super().build_reply_content(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\channel\channel.py", line 31, in build_reply_content return Bridge().fetch_reply_content(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\bridge\bridge.py", line 10, in fetch_reply_content return bot_factory.create_bot("chatGPT").reply(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\bot\chatgpt\chat_gpt_bot.py", line 27, in reply session_id = context['session_id'] KeyError: 'session_id'

你好。为什么我填好了之后还是提示这个错误呢? [ERROR][2023-03-10 09:04:23][wechat_channel.py:151] - 'session_id' Traceback (most recent call last): File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\channel\wechat\wechat_channel.py", line 145, in _do_send_voice reply_text = super().build_reply_content(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\channel\channel.py", line 31, in build_reply_content return Bridge().fetch_reply_content(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\bridge\bridge.py", line 10, in fetch_reply_content return bot_factory.create_bot("chatGPT").reply(query, context) File "E:\Enviroment\PythonWorks\src\chatgpt-on-wechat-20230310\chatgpt-on-wechat-1.0.5\bot\chatgpt\chat_gpt_bot.py", line 27, in reply session_id = context['session_id'] KeyError: 'session_id'

修改了下,可以获取最新代码再试试

我同样的问题,获取最新的代码后在执行,提示:
[ERROR][2023-03-10 10:00:50][wechat_channel.py:151] - No module named 'aip'
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice
replyFile = super().build_text_to_voice(reply_text)
File "/root/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice
return Bridge().fetch_text_to_voice(text)
File "/root/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice
return voice_factory.create_voice("baidu").textToVoice(text)
File "/root/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice
from voice.baidu.baidu_voice import BaiduVoice
File "/root/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 6, in
from aip import AipSpeech
ModuleNotFoundError: No module named 'aip'

我同样的问题,获取最新的代码后在执行,提示: [ERROR][2023-03-10 10:00:50][wechat_channel.py:151] - No module named 'aip' Traceback (most recent call last): File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/root/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/root/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/root/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/root/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 6, in from aip import AipSpeech ModuleNotFoundError: No module named 'aip'

你需要安装:pip install baidu-aip

安装下pip3 install baidu-aip chardet

因为调用了baidu-aip库,终端输入pip3 install baidu-aip chardet 。

谢谢,已经解决了,程序默认的语音类型的百度,我没安装百度的这个库,刚刚改成谷歌了。谢谢~~

[INFO][2023-03-10 16:30:44][openai_voice.py:22] - [Openai] voiceToText text=回复一个语言 voice file name=tmp/230310-163043.mp3
[INFO][2023-03-10 16:30:44][chat_gpt_bot.py:26] - [OPEN_AI] query=回复一个语言
[INFO][2023-03-10 16:30:46][google_voice.py:49] - [Google] textToVoice text=您好!请问题用哪种语言提问,我将用相同的语言进行回答。 voice file name=tmp/语音回复_1678437046.mp3
[INFO][2023-03-10 16:30:46][wechat_channel.py:149] - [WX] sendFile=tmp/语音回复_1678437046.mp3, receiver=@68bd8f5f7464a0ffee8f9ef10bf401e8b83abc33ad375cc6c2c6167d6842e19b

使用的是谷歌的语音类型,但是微信没有回复任何消息

在itchat中只能回复mp3文件,在wechaty中可以回复语音消息
wechaty 所需要的版本是多少,需要指定某个版本吗?

itchat和wechaty,是在哪个配置项,还是哪个文件上指定了

wechaty比itchat更容易被封吗?

wechaty 语音功能还不支持

Start auto replying.
[INFO][2023-03-12 22:46:58][openai_voice.py:22] - [Openai] voiceToText text=趕快睡覺吧,別 搞了 voice file name=tmp/230312-224657.mp3
[INFO][2023-03-12 22:46:58][chat_gpt_bot.py:27] - [OPEN_AI] query=趕快睡覺吧,別 搞了
[ERROR][2023-03-12 22:47:03][baidu_voice.py:35] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3749716633}
[INFO][2023-03-12 22:47:03][wechat_channel.py:149] - [WX] sendFile=None, receiver=@590c249050a578793750164dda76be47

这个语音错误是杂回事啊

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3
[INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C.
[ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip'
Traceback (most recent call last):
File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice
replyFile = super().build_text_to_voice(reply_text)
File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice
return Bridge().fetch_text_to_voice(text)
File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice
return voice_factory.create_voice("baidu").textToVoice(text)
File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice
from voice.baidu.baidu_voice import BaiduVoice
File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in
class BaiduVoice(Voice):
File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init
self._appId = appId.strip()
AttributeError: 'NoneType' object has no attribute 'strip'
我也是,语音使用报错

Start auto replying. [INFO][2023-03-12 22:46:58][openai_voice.py:22] - [Openai] voiceToText text=趕快睡覺吧,別 搞了 voice file name=tmp/230312-224657.mp3 [INFO][2023-03-12 22:46:58][chat_gpt_bot.py:27] - [OPEN_AI] query=趕快睡覺吧,別 搞了 [ERROR][2023-03-12 22:47:03][baidu_voice.py:35] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3749716633} [INFO][2023-03-12 22:47:03][wechat_channel.py:149] - [WX] sendFile=None, receiver=@590c249050a578793750164dda76be47

这个语音错误是杂回事啊

在百度云账号领一下免费额度应该就行

commented

一、接收语音,回复文字

config.json 中设置 "speech_recognition": true 即可, 这个配置在 template中有。 启动程序后 私聊 就会支持语音识别,会对所有收到的语音消息转成文字,并回复文字。

二、接收语音,回复语音

在itchat中只能回复mp3文件,在wechaty中可以回复语音消息。 有两种可选平台:

1.百度

(1) 安装依赖: pip3 install baidu-aip chardet

(2) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true,
    "baidu_app_id": "YOUR BAIDU APP ID",
    "baidu_api_key": "YOUR BAIDU API KEY",
    "baidu_secret_key": "YOUR BAIDU SERVICE KEY"
}

2.Google

(1) 安装 SpeechRecognition: pip3 install SpeechRecognition

(2) 安装 ffmpeg 和 espeak

* MacOS: brew install ffmpeg espeak

* Windows: 下载ffmpeg.exe

* Linux: apt-get install ffmpeg espeak

(3) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true
}

PR: #385 by @wanggang1987

wechaty方案的语音识别是不是没对接?代码中找不到这部分

一、接收语音,回复文字

config.json 中设置 "speech_recognition": true 即可, 这个配置在 template中有。 启动程序后 私聊 就会支持语音识别,会对所有收到的语音消息转成文字,并回复文字。

二、接收语音,回复语音

在itchat中只能回复mp3文件,在wechaty中可以回复语音消息。 有两种可选平台:

1.百度

(1) 安装依赖: pip3 install baidu-aip chardet
(2) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true,
    "baidu_app_id": "YOUR BAIDU APP ID",
    "baidu_api_key": "YOUR BAIDU API KEY",
    "baidu_secret_key": "YOUR BAIDU SERVICE KEY"
}

2.Google

(1) 安装 SpeechRecognition: pip3 install SpeechRecognition
(2) 安装 ffmpeg 和 espeak

* MacOS: brew install ffmpeg espeak

* Windows: 下载ffmpeg.exe

* Linux: apt-get install ffmpeg espeak

(3) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true
}

PR: #385 by @wanggang1987

wechaty方案的语音识别是不是没对接?代码中找不到这部分

一样找不到,求更新!!!

一、接收语音,回复文字

config.json 中设置 "speech_recognition": true 即可, 这个配置在 template中有。 启动程序后 私聊 就会支持语音识别,会对所有收到的语音消息转成文字,并回复文字。

二、接收语音,回复语音

在itchat中只能回复mp3文件,在wechaty中可以回复语音消息。 有两种可选平台:

1.百度

(1) 安装依赖: pip3 install baidu-aip chardet

(2) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true,
    "baidu_app_id": "YOUR BAIDU APP ID",
    "baidu_api_key": "YOUR BAIDU API KEY",
    "baidu_secret_key": "YOUR BAIDU SERVICE KEY"
}

2.Google

(1) 安装 SpeechRecognition: pip3 install SpeechRecognition

(2) 安装 ffmpeg 和 espeak

  • MacOS: brew install ffmpeg espeak
  • Windows: 下载ffmpeg.exe
  • Linux: apt-get install ffmpeg espeak

(3) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true
}

PR: #385 by @wanggang1987

按要求配置了"speech_recognition": true,但是实测不生效,后台日志没有显示任何反应。

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3 [INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C. [ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in class BaiduVoice(Voice): File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init self._appId = appId.strip() AttributeError: 'NoneType' object has no attribute 'strip' 我也是,语音使用报错

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3 [INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C. [ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in class BaiduVoice(Voice): File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init self._appId = appId.strip() AttributeError: 'NoneType' object has no attribute 'strip' 我也是,语音使用报错

这个是因为没有修改配置,代码默认使用百度,如果要使用谷歌需要在bridge/bridge.py中修改为谷歌

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3 [INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C. [ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in class BaiduVoice(Voice): File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init self._appId = appId.strip() AttributeError: 'NoneType' object has no attribute 'strip' 我也是,语音使用报错

"baidu_app_id", "baidu_api_key", "baidu_secret_key" 这三个配置了嘛

@chiakileftcang @1018987534 对的,wechaty暂时还没对接发送语音

commented

@chiakileftcang @1018987534 对的,wechaty暂时还没对接发送语音

我已经给你接好了,给个代码提交权限呗

@chiakileftcang 那太好了, 你直接发起 pull request 就好

commented

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3 [INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C. [ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in class BaiduVoice(Voice): File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init self._appId = appId.strip() AttributeError: 'NoneType' object has no attribute 'strip' 我也是,语音使用报错

[INFO][2023-03-13 00:36:38][openai_voice.py:22] - [Openai] voiceToText text=A, B, C. voice file name=tmp/230313-003636.mp3 [INFO][2023-03-13 00:36:38][chat_gpt_bot.py:26] - [OPEN_AI] query=A, B, C. [ERROR][2023-03-13 00:36:40][wechat_channel.py:151] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/home/pi/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 147, in _do_send_voice replyFile = super().build_text_to_voice(reply_text) File "/home/pi/chatgpt-on-wechat/channel/channel.py", line 37, in build_text_to_voice return Bridge().fetch_text_to_voice(text) File "/home/pi/chatgpt-on-wechat/bridge/bridge.py", line 16, in fetch_text_to_voice return voice_factory.create_voice("baidu").textToVoice(text) File "/home/pi/chatgpt-on-wechat/voice/voice_factory.py", line 12, in create_voice from voice.baidu.baidu_voice import BaiduVoice File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 12, in class BaiduVoice(Voice): File "/home/pi/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 16, in BaiduVoice client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) File "/home/pi/.local/lib/python3.9/site-packages/aip/base.py", line 43, in init self._appId = appId.strip() AttributeError: 'NoneType' object has no attribute 'strip' 我也是,语音使用报错

这个是因为没有修改配置,代码默认使用百度,如果要使用谷歌需要在bridge/bridge.py中修改为谷歌

在bridge的位置如何修改为google ?

fetch_text_to_voice函数中的“baidu“换成"google"

wechaty 回复语音已实现:#476

@chiakileftcang @1018987534 对的,wechaty暂时还没对接发送语音

我已经给你接好了,给个代码提交权限呗

[ERROR][2023-03-15 22:12:16][wechaty_channel.py:215] - [Errno 2] No such file or directory: 'ffprobe'
Traceback (most recent call last):
File "/work/chatGPT/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 197, in _do_send_voice
audio = AudioSegment.from_file(mp3_file, format="mp3")
File "/usr/local/lib/python3.8/site-packages/pydub/audio_segment.py", line 728, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "/usr/local/lib/python3.8/site-packages/pydub/utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "/usr/local/lib/python3.8/subprocess.py", line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.8/subprocess.py", line 1706, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'
/usr/local/lib/python3.8/site-packages/pydub/utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)

语音回复,这是啥情况??

commented

@chiakileftcang @1018987534 对的,wechaty暂时还没对接发送语音

我已经给你接好了,给个代码提交权限呗

[ERROR][2023-03-15 22:12:16][wechaty_channel.py:215] - [Errno 2] No such file or directory: 'ffprobe' Traceback (most recent call last): File "/work/chatGPT/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 197, in _do_send_voice audio = AudioSegment.from_file(mp3_file, format="mp3") File "/usr/local/lib/python3.8/site-packages/pydub/audio_segment.py", line 728, in from_file info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit) File "/usr/local/lib/python3.8/site-packages/pydub/utils.py", line 274, in mediainfo_json res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE) File "/usr/local/lib/python3.8/subprocess.py", line 858, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.8/subprocess.py", line 1706, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe' /usr/local/lib/python3.8/site-packages/pydub/utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)

语音回复,这是啥情况??

你的环境里没有安装 ffmpeg ,“ Couldn't find ffprobe” 这个ffprobe是ffmpeg中的工具。

commented

[INFO][2023-03-18 02:24:18][openai_voice.py:22] - [Openai] voiceToText text=你是誰? voice file name=tmp/230318-022417.mp3
[INFO][2023-03-18 02:24:18][chat_gpt_bot.py:28] - [OPEN_AI] query=你是誰?
[INFO][2023-03-18 02:24:27][baidu_voice.py:32] - [Baidu] textToVoice text=我是ChatGPT,一個由OpenAI訓練的大型語言模型。我旨在回答和解決人們的各種問題,並且可以使用多種語言與人交流。 voice file name=tmp/语音回复_1679077467.mp3
[ERROR][2023-03-18 02:24:33][wechat_channel.py:151] - HTTPSConnectionPool(host='file.wx2.qq.com', port=443): Max retries exceeded with url: /cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)))
Traceback (most recent call last):
File "Python\Python39\site-packages\urllib3\connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "Python\Python39\site-packages\urllib3\connectionpool.py", line 996, in prepare_proxy
conn.connect()
File "Python\Python39\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "Python\Python39\site-packages\urllib3\util\ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "Python\Python39\site-packages\urllib3\util\ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Program Files\Python39\lib\ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "C:\Program Files\Python39\lib\ssl.py", line 1041, in _create
self.do_handshake()
File "C:\Program Files\Python39\lib\ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
啥子情况哦,能识别到了,但是发不出来

commented

按要求配置了"speech_recognition": true,但是实测不生效,后台日志没有显示任何反应。

commented

一、接收语音,回复文字

config.json 中设置 "speech_recognition": true 即可, 这个配置在 template中有。 启动程序后 私聊 就会支持语音识别,会对所有收到的语音消息转成文字,并回复文字。

二、接收语音,回复语音

有两种可选平台:

1.百度

(1) 安装依赖: pip3 install baidu-aip chardet

(2) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true,
    "baidu_app_id": "YOUR BAIDU APP ID",
    "baidu_api_key": "YOUR BAIDU API KEY",
    "baidu_secret_key": "YOUR BAIDU SERVICE KEY"
}

2.Google

(1) 安装 SpeechRecognition: pip3 install SpeechRecognition

(2) 安装 ffmpeg 和 espeak

* MacOS: brew install ffmpeg espeak

* Windows: 下载ffmpeg.exe

* Linux: apt-get install ffmpeg espeak

(3) 在 config.json 中添加配置:

{
    "speech_recognition": true,
    "voice_reply_voice": true
}

注:在itchat中只能回复mp3文件;在wechaty中可以回复语音消息,wechaty中使用需要安装额外依赖:

pip3 install pysilk
pip3 install pysilk-mod
pip3 install pydub

PR: #385 by @wanggang1987 #476 by @Chiaki-Chan

penai的whisper模型识别为文字

问题是我按照要求做了, 但是whisper的识别语音 ,在程序成功运行后一点反应都没有,文字是正常回复但是语音就一点动静哦都没有,至少给我一个提示说哪里错了。这也没有

使用了google的语音,在日志中可以看到回复,但是实际上在微信上没有收到语音回复。好奇怪

pip3 install SpeechRecognitio

看了下好像没有实现send_file方法?

~/chatgpt-on-wechat$ nohup python3 app.py & tail -f nohup.out
[1] 1174
nohup: ignoring input and appending output to 'nohup.out'
File "/home/ubuntu/.local/lib/python3.8/site-packages/itchat/components/register.py", line 60, in configured_reply
r = replyFn(msg)
File "/home/ubuntu/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 23, in handler_single_msg
WechatChannel().handle_text(msg)
File "/home/ubuntu/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 71, in handle_text
self._handle_single_msg(msg, content)
File "/home/ubuntu/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 76, in _handle_single_msg
other_user_id = msg['User']['UserName'] # 对手方id
KeyError: 'UserName'

[ERROR][2023-03-21 03:17:53][app.py:19] - App startup failed!
[ERROR][2023-03-21 03:17:53][app.py:20] - Extra data: line 17 column 2 (char 547)
Traceback (most recent call last):
File "app.py", line 11, in
config.load_config()
File "/home/ubuntu/chatgpt-on-wechat/config.py", line 18, in load_config
config = json.loads(config_str)
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 17 column 2 (char 547)

不加语音可以正常运行,加了语音就报错。求解

目前我遇到的是使用google的语音进行语音回复测试,查看日志是有回复信息的,但实际上没有回复
Login successfully as ChatGPT
Start auto replying.
[INFO][2023-03-21 16:33:11][openai_voice.py:22] - [Openai] voiceToText text=你好 voice file name=tmp/230321-163307.mp3
[INFO][2023-03-21 16:33:11][chat_gpt_bot.py:28] - [OPEN_AI] query=你好
[INFO][2023-03-21 16:33:24][google_voice.py:49] - [Google] textToVoice text=你好,有什么问题我可以帮你解答吗? voice file name=tmp/语音回复_1679387604.mp3
[INFO][2023-03-21 16:33:24][wechat_channel.py:149] - [WX] sendFile=tmp/语音回复_1679387604.mp3

config.load_config()

File "/root/chatgpt-on-wechat/config.py", line 102, in load_config
config = Config(json.loads(config_str))
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 16 column 4 (char 598)
nohup: ignoring input and appending output to 'nohup.out'
[ERROR][2023-03-26 03:44:19][app.py:23] - App startup failed!
[ERROR][2023-03-26 03:44:19][app.py:24] - Expecting ',' delimiter: line 16 column 4 (char 598)
Traceback (most recent call last):
File "app.py", line 12, in run
config.load_config()
File "/root/chatgpt-on-wechat/config.py", line 102, in load_config
config = Config(json.loads(config_str))
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 16 column 4 (char 598)
用的是百度。。请问这是啥错误。。

@luojin520520 json配置格式问题

怎么显示发送语音文件了,但是接收不到?
image

用的googl的语音,能发生mp3文件,但无论我要求什么,她都只会一个大小为46b的文件,打开后是空的,这个有什么解决方法吗?我换过百度的不知道是api接口的问题还是什么,回复的内容一直是,有领取百度开发者的新手额度

[ERROR][2023-03-27 11:53:12][baidu_voice.py:36] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3084016285}
image
image

使用baidu-aip成功了,不过跟想象中的不一样,对话返回的是个MP3音频文件
1679901161271
image

跟着楼主步骤来没问题,补充一下百度baidu_app_id和baidu_api_key获取方式:
1、注册登录百度智能云,百度云账号就可以 https://login.bce.baidu.com/
2、在控制台搜索语音技术
image
3、创建应用,按照操作指引来
image
领取免费额度需要选择 语音合成
image
4、拷贝参数到配置文件,可以直接试试语音交互了
image

是不是需要购买一下百度语音的资源包呢,开通语音识别到是免费

------------------ 原始邮件 ------------------ 发件人: "zhayujie/chatgpt-on-wechat" @.>; 发送时间: 2023年3月27日(星期一) 下午3:31 @.>; @.@.>; 主题: Re: [zhayujie/chatgpt-on-wechat] 关于语音识别功能的使用 (Issue #415) 使用baidu-aip成功了,不过跟想象中的不一样,对话返回的是个MP3音频文件 跟着楼主步骤来没问题,补充一下百度baidu_app_id和baidu_api_key获取方式: 1、注册登录百度智能云,百度云账号就可以 https://login.bce.baidu.com/ 2、在控制台搜索语音技术 3、创建应用,按照操作指引来 领取免费额度需要选择 语音合成 4、拷贝参数到配置文件,可以直接试试语音交互了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

不需要,登录注册都是免费的,接口也可以领取免费次数,全部可以白嫖

用的googl的语音,能发生mp3文件,但无论我要求什么,她都只会一个大小为46b的文件,打开后是空的,这个有什么解决方法吗?我换过百度的不知道是api接口的问题还是什么,回复的内容一直是,有领取百度开发者的新手额度

[ERROR][2023-03-27 11:53:12][baidu_voice.py:36] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3084016285} image image

解决了,在百度那领取免费额度的时候,领错了,领成语音识别了

解决了,感谢

用的googl的语音,能生成mp3文件,但无论我要什么,她都会一个很大的小为46b的文件,打开后是空的,这个有什么解决方法的不清楚吗?我换过接口的问题还是什么,回复的内容一直是​​,有领取百度开发者的新手头度
[ERROR][2023-03-27 11:53:12][baidu_voice.py:36] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3084016285} 图像 图像

解决了,在百度那领取免费额度的时候,领错了,领成语语音识别了
哥们,最新的代码使用的默认就是Google的语音识别吧,怎么修改成百度的呢

怎么使用 wechaty 进行语音回复呢,有没有大佬指教一下,辛苦辛苦💦

commented

用了Railway部署后,语音mp3发不到微信上去了,卡在了这里:
[INFO][2023-03-28 19:48:17][openai_voice.py:25] - [Openai] voiceToText text=你好 voice file name=tmp/230328-194814.wav
[INFO][2023-03-28 19:48:17][wechat_channel.py:301] - [WX]receive voice, checkprefix didn't match

试过了google和baidu的语音合成都不成功

登录成功,@名称 提问无响应怎么回事呢

我安装要求配置了baidu的,为什么还是去调用google呢?

[INFO][2023-04-05 08:55:12][bridge.py:28] - create bot google for text_to_voice
[ERROR][2023-04-05 08:55:12][chat_channel.py:233] - Worker return exception: No module named 'speech_recognition'
Traceback (most recent call last):

commented

你去bridge文件夹中找到bridge.py,把代码中"text_to_voice": conf().get("text_to_voice", "Google")改成"text_to_voice": conf().get("text_to_voice", "baidu")

鉴于openai调用效率太低,能否把语音转文本设置成用baidu来完成,然后回复还是用文本回复(我不想同时开启语音回复语音)。请问这个怎么设置?

参考可选配置项

"voice_to_text": "openai", # 语音识别引擎,支持openai,google,azure
好像不支持:(

忘记修改了,是支持百度的

忘记修改了,是支持百度的
配置了baidu后,出现如下错误:
[ERROR][2023-04-11 20:26:34][chat_channel.py:237] - Worker return exception: file does not start with RIFF id
Traceback (most recent call last):
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/qcolt/chatgpt-on-wechat/channel/chat_channel.py", line 128, in _handle
reply = self._generate_reply(context)
File "/home/qcolt/chatgpt-on-wechat/channel/chat_channel.py", line 138, in _generate_reply
e_context = PluginManager().emit_event(EventContext(Event.ON_HANDLE_CONTEXT, {
File "/home/qcolt/chatgpt-on-wechat/plugins/plugin_manager.py", line 159, in emit_event
instance.handlers[e_context.event](e_context, *args, **kwargs)
File "/home/qcolt/chatgpt-on-wechat/plugins/skills/skills.py", line 56, in on_handle_context
reply = e_context['channel'].build_voice_to_text(file_name)
File "/home/qcolt/chatgpt-on-wechat/channel/channel.py", line 38, in build_voice_to_text
return Bridge().fetch_voice_to_text(voice_file)
File "/home/qcolt/chatgpt-on-wechat/bridge/bridge.py", line 46, in fetch_voice_to_text
return self.get_bot("voice_to_text").voiceToText(voiceFile)
File "/home/qcolt/chatgpt-on-wechat/voice/baidu/baidu_voice.py", line 65, in voiceToText
pcm = get_pcm_from_wav(voice_file)
File "/home/qcolt/chatgpt-on-wechat/voice/audio_convert.py", line 29, in get_pcm_from_wav
wav = wave.open(wav_path, "rb")
File "/usr/lib/python3.8/wave.py", line 510, in open
return Wave_read(f)
File "/usr/lib/python3.8/wave.py", line 164, in init
self.initfp(f)
File "/usr/lib/python3.8/wave.py", line 131, in initfp
raise Error('file does not start with RIFF id')
wave.Error: file does not start with RIFF id

估计你没装ffmpeg

估计你没装ffmpeg

确实是,现在搞定了,谢谢。

估计你没装ffmpeg

奇怪,我在另一台机器上,安装了ffmpeg后还是出现这个错误,还有没有别的原因了?

我都设置为调用百度的API 为什么还需要 安装ffmpeg这个呢

[Google] textToVoice text=“你好嗎?”的英文翻译是 "How are you?"。 voice file name=tmp/reply-1682526485-1578620872.mp3 [ERROR][2023-04-26 19:28:06][wechatmp_channel.py:98] - [wechatmp] upload voice failed: Error code: 48001, message: api unauthorized rid: 64495116-496f1ca5-6817ed93

请教这个是什么问题啊?

#948 这种情况吗

#948 这种情况吗

应该是这个情况。我吧公众号认证一下试试

怎么重新生成二维码

我在google 的cloud run上部署了这个项目来对接企业微信的自建应用,文本已经可以正常接发了。但是我设置"speech_recognition": true, 然后发送语音,按说明,应该是会调用默认的openai来识别语音并回复文字,但收到的回复是:
[ERROR]
Invalid file format. Supported formats: ['m4a', 'mp3', 'webm', 'mp4', 'mpga', 'wav', 'mpeg']

请问要如何解决呢?十分感谢

企业应用号需要ffmpeg,并安装amr编码器

语音合成失败 我打印下被合成的文本 发现没有问题。就是让百度去合成的时候报错,错误代码513。百度技术文档没有这个错误代码

[INFO][2023-05-06 21:48:43][wechaty_channel.py:129] - [WX] receiveMsg=ChatMessage: id=3431040645055321713, create_time=1683380918, ctype=VOICE, content=tmp/message-3431040645055321713-audio.slk, from_user_id=wxid_k10fvreqzcbf22, from_user_nickname=梁爽, to_user_id=18725660724@chatroom, to_user_nickname=账号群, other_user_id=18725660724@chatroom, other_user_nickname=账号群, is_group=True, is_at=False, actual_user_id=wxid_k10fvreqzcbf22, actual_user_nickname=梁爽, context=Context(type=VOICE, content=tmp/message-3431040645055321713-audio.slk, kwargs={'isgroup': True, 'msg': <channel.wechat.wechaty_message.WechatyMessage object at 0x00000218C8C58CD0>, 'origin_ctype': <ContextType.VOICE: 2>, 'openai_api_key': None, 'session_id': 'wxid_k10fvreqzcbf22', 'receiver': '18725660724@chatroom', 'desire_rtype': <ReplyType.VOICE: 2>})
[INFO][2023-05-06 21:48:46][openai_voice.py:25] - [Openai] voiceToText text=機器人介紹下三體的劇情 voice file name=tmp/message-3431040645055321713-audio.wav
[INFO][2023-05-06 21:48:46][chat_gpt_bot.py:49] - [CHATGPT] query=介紹下三體的劇情
[INFO][2023-05-06 21:49:33][baidu_voice.py:84] - 被合成的文本=《三体》是刘慈欣的科幻小说,是**近年来受欢迎的科幻小说之一,曾荣获雨果奖。

《三体》的故事主要围绕一个名为“三体”的外星文明展开,它们居住于一个蕴含三个恒星的行星系统中,常年受到从另一恒星系中发射的恒星光束以及混沌环境的影响,为了生存而不断进化。三体文明历经了多次灾难性的文明崩溃,一次发现地球之后,他们发动了一场推翻人类文明的战争。

小说第一部主要描述了以世界末日之夜(又称“红岸基事件”)为开始的故事。红岸基事件是一场怪异的学术研讨会,它的主题是“三体问 题”的解法。会议的参与者们各有不同的想法,有的认为解法在纯理论上就不可能存在,有的则认为应该从实践中寻找。

在这个过程中,人类与三体间的交流不断加深,并且三体文明对地球的**也日益临近。小说第二部主要描述了三体文明的来袭以及人类如何应对。在全世界政府和科技界的努力下,人类共同应对了三体文明的入侵,利用一种特殊的技术,人类成功进入了三体文明的行星系,并在那里发现了一个名为“黑暗森林”的宇宙规律。

小说第三部主要是对人类文明和三体文明之间的较量的终结。在第三部,三体文明与地球文明之间的较量进一步升级,两个文明之间的历史和复杂的关系得以揭示,最终达成了一个复杂的结局。
[ERROR][2023-05-06 21:49:33][baidu_voice.py:93] - [Baidu] textToVoice error={'cookie': '549501194_2000', 'err_detail': 'Invalid text length', 'err_msg': 'tex param err', 'err_no': 513, 'err_subcode': 234, 'tts_logid': 1888171743}
[INFO][2023-05-06 21:49:34][wechaty_channel.py:75] - [WX] sendMsg=Reply(type=ERROR, content=[ERROR]

image

按您说的装上后就可用了

112.53.2.93:35534 - - [09/May/2023 06:21:57] "HTTP/1.1 POST /wxcomapp" - 200 OK
[ERROR][2023-05-09 06:21:57][chat_channel.py:267] - Worker return exception: 'BaiduVoice' object has no attribute 'client'
Traceback (most recent call last):
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/app/channel/chat_channel.py", line 145, in _handle
reply = self._generate_reply(context)
File "/app/channel/chat_channel.py", line 177, in _generate_reply
reply = super().build_voice_to_text(wav_path)
File "/app/channel/channel.py", line 40, in build_voice_to_text
return Bridge().fetch_voice_to_text(voice_file)
File "/app/bridge/bridge.py", line 48, in fetch_voice_to_text
return self.get_bot("voice_to_text").voiceToText(voiceFile)
File "/app/voice/baidu/baidu_voice.py", line 65, in voiceToText
res = self.client.asr(pcm, "pcm", 16000, {"dev_pid": self.dev_id})
AttributeError: 'BaiduVoice' object has no attribute 'client'
这个报错是什么原因呢? 好像我第一个遇到?

commented

[WARNING][2023-05-10 17:05:34][chat_channel.py:174] - [WX]any to wav error, use raw path. name 'any_to_wav' is not defined
[INFO][2023-05-10 17:05:34][bridge.py:30] - create bot openai for voice_to_text,这个怎么做呀

[WARNING][2023-05-17 19:40:55][chat_channel.py:175] - [WX]any to wav error, use raw path. name 'any_to_wav' is not defined
[INFO][2023-05-17 19:40:55][bridge.py:30] - create bot baidu for voice_to_text
[ERROR][2023-05-17 19:40:55][chat_channel.py:268] - Worker return exception: No module named 'pysilk.backends.cython._silk'
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\Administrator\chatgpt-on-wechat\channel\chat_channel.py", line 146, in _handle
reply = self.generate_reply(context)
File "C:\Users\Administrator\chatgpt-on-wechat\channel\chat_channel.py", line 178, in generate_reply
reply = super().build_voice_to_text(wav_path)
File "C:\Users\Administrator\chatgpt-on-wechat\channel\channel.py", line 40, in build_voice_to_text
return Bridge().fetch_voice_to_text(voice_file)
File "C:\Users\Administrator\chatgpt-on-wechat\bridge\bridge.py", line 48, in fetch_voice_to_text
return self.get_bot("voice_to_text").voiceToText(voiceFile)
File "C:\Users\Administrator\chatgpt-on-wechat\bridge\bridge.py", line 34, in get_bot
self.bots[typename] = create_voice(self.btype[typename])
File "C:\Users\Administrator\chatgpt-on-wechat\voice\factory.py", line 13, in create_voice
from voice.baidu.baidu_voice import BaiduVoice
File "C:\Users\Administrator\chatgpt-on-wechat\voice\baidu\baidu_voice.py", line 14, in
from voice.audio_convert import get_pcm_from_wav
File "C:\Users\Administrator\chatgpt-on-wechat\voice\audio_convert.py", line 4, in
import pysilk
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pysilk_init
.py", line 18, in
from pysilk.backends.cython import *
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pysilk\backends\cython_init
.py", line 4, in
from pysilk.backends.cython._silk import *
ModuleNotFoundError: No module named 'pysilk.backends.cython._silk'
这个怎么解决,哪位大佬教一下

我在google 的cloud run上部署了这个项目来对接企业微信的自建应用,文本已经可以正常接发了。但是我设置"speech_recognition": true, 然后发送语音,按说明,应该是会调用默认的openai来识别语音并回复文字,但收到的回复是: [ERROR] Invalid file format. Supported formats: ['m4a', 'mp3', 'webm', 'mp4', 'mpga', 'wav', 'mpeg']

请问要如何解决呢?十分感谢

老兄,这个问题怎么解决的呀,我也遇到了

@jones-so 企业应用号需要ffmpeg,并安装amr编码器,前面有个大神已经回复了。实测可行

google 不走代理吗,超时了

fetch_text_to_voice函数中的“baidu“换成"google"

我的代码没看到什么’百度‘,而是这样的def fetch_text_to_voice(self, text) -> Reply: return self.get_bot("text_to_voice").textToVoice(text)发了语音过去,查看后台信息是把我的语音识别成了文字,可是一直回复不了语音,一直提示回复任意字获取

请问你用的是啥通道能看到Google的语音回复?好像我的wechatmp这个通道不能使用语音识别?多次显示http状态吗200之后就直接错误了[ERROR]
Failed to connect. Probable cause: Unknown不知道啥请款。 @zhayujie 能帮解惑一下嘛

为什么我在微信中使用回复的还是mp3文件呀

使用baidu-aip成功了,不过跟想象中的不一样,对话返回的是个MP3音频文件 1679901161271 图像

按照楼主步骤来没问题,补充一下百度baidu_app_id和baidu_api_key获取方式: 1、注册登录百度智能云,百度云账号就可以https://login.bce.baidu.com/ 2、在控制台搜索语音技术 3 、创建应用,按照选择操作指引来 领取免费赠品需要语音合成 4、复制参数到配置文件,可以直接尝试语音交易了 图像 图像 图像 图像

请问你这个解决了吗,我也是遇到这样的问题返回的不是微信语音而是mp3文件

Start auto replying. [INFO][2023-03-12 22:46:58][openai_voice.py:22] - [Openai] voiceToText text=趕快睡覺吧,別 搞了 voice file name=tmp/230312-224657.mp3 [INFO][2023-03-12 22:46:58][chat_gpt_bot.py:27] - [OPEN_AI] query=趕快睡覺吧,別 搞了 [ERROR][2023-03-12 22:47:03][baidu_voice.py:35] - [Baidu] textToVoice error={'err_detail': '16: Open api characters limit reached', 'err_msg': '16: Open api characters limit reached', 'err_no': 502, 'err_subcode': 16, 'tts_logid': 3749716633} [INFO][2023-03-12 22:47:03][wechat_channel.py:149] - [WX] sendFile=None, receiver=@590c249050a578793750164dda76be47

这个语音错误是杂回事啊

image
我也是这个问题,请问您解决了吗,我用的是百度的短语音识别api