Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于语音识别功能的使用 #415

Open
ShowUNow opened this issue Mar 9, 2023 · 87 comments
Open

关于语音识别功能的使用 #415

ShowUNow opened this issue Mar 9, 2023 · 87 comments
Labels
tutorial Tutorial provided by maintainer, may be outdated

Comments

@ShowUNow
Copy link

ShowUNow commented Mar 9, 2023

前置确认

  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
@dhlsam
Copy link

dhlsam commented Mar 9, 2023

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

@zhayujie
Copy link
Owner

zhayujie commented Mar 9, 2023

一、接收语音,回复文字

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

@zhayujie zhayujie changed the title 对应语音合成平台的key要添加到哪里呢? 关于语音识别功能的使用 Mar 9, 2023
@zhayujie zhayujie pinned this issue Mar 9, 2023
@4331599
Copy link

4331599 commented Mar 10, 2023

你好。为什么我填好了之后还是提示这个错误呢?
[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'

@zhayujie
Copy link
Owner

你好。为什么我填好了之后还是提示这个错误呢? [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'

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

@yuyang0702
Copy link

我同样的问题,获取最新的代码后在执行,提示:
[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'

@Ayuyyae
Copy link

Ayuyyae commented Mar 10, 2023

我同样的问题,获取最新的代码后在执行,提示: [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

@wanggang1987
Copy link
Contributor

安装下pip3 install baidu-aip chardet

@huanyan
Copy link

huanyan commented Mar 10, 2023

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

@yuyang0702
Copy link

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

@wangjiangmin1115
Copy link

[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

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

@wangjiangmin1115
Copy link

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

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

@lingwecho
Copy link

wechaty比itchat更容易被封吗?

@1018987534
Copy link

wechaty 语音功能还不支持

@exp224
Copy link

exp224 commented Mar 12, 2023

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

这个语音错误是杂回事啊

@yixmlh90
Copy link

[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'
我也是,语音使用报错

@lingwecho
Copy link

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

这个语音错误是杂回事啊

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

@Chiaki-Chan
Copy link
Contributor

一、接收语音,回复文字

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方案的语音识别是不是没对接?代码中找不到这部分

@1018987534
Copy link

一、接收语音,回复文字

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方案的语音识别是不是没对接?代码中找不到这部分

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

@qcoltma
Copy link

qcoltma commented Mar 14, 2023

一、接收语音,回复文字

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,但是实测不生效,后台日志没有显示任何反应。

@shuodehaoa
Copy link

[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中修改为谷歌

@zhayujie
Copy link
Owner

[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" 这三个配置了嘛

@zhayujie
Copy link
Owner

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

@Chiaki-Chan
Copy link
Contributor

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

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

@zhayujie
Copy link
Owner

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

@meezln
Copy link

meezln commented Mar 14, 2023

[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 ?

@shuodehaoa
Copy link

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

@zhayujie
Copy link
Owner

wechaty 回复语音已实现:#476

@qcoltma
Copy link

qcoltma commented Apr 12, 2023

估计你没装ffmpeg

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

@Winston-H
Copy link

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

@lanvent lanvent added the tutorial Tutorial provided by maintainer, may be outdated label Apr 24, 2023
@Super-Wong
Copy link

[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

请教这个是什么问题啊?

@lanvent
Copy link
Collaborator

lanvent commented Apr 26, 2023

#948 这种情况吗

@Super-Wong
Copy link

#948 这种情况吗

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

@caizhenjia
Copy link

怎么重新生成二维码

@andyzlys
Copy link

andyzlys commented May 6, 2023

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

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

@lanvent
Copy link
Collaborator

lanvent commented May 6, 2023

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

@lsCoding666
Copy link

语音合成失败 我打印下被合成的文本 发现没有问题。就是让百度去合成的时候报错,错误代码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

@lsCoding666
Copy link

#1037

@andyzlys
Copy link

andyzlys commented May 6, 2023

按您说的装上后就可用了

@kuaile1993
Copy link

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'
这个报错是什么原因呢? 好像我第一个遇到?

@X-233
Copy link

X-233 commented May 10, 2023

[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,这个怎么做呀

@1728012088
Copy link

[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'
这个怎么解决,哪位大佬教一下

@jones-so
Copy link

jones-so commented Jun 4, 2023

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

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

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

@andyzlys
Copy link

andyzlys commented Jun 6, 2023

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

@jones-so
Copy link

jones-so commented Jun 6, 2023 via email

@AssassinJY
Copy link

google 不走代理吗,超时了

@jones-so
Copy link

jones-so commented Jun 21, 2023 via email

@KunBoy5240
Copy link

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

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

@KunBoy5240
Copy link

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

@AnCool-OvO
Copy link
Contributor

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

@jones-so
Copy link

jones-so commented Jan 22, 2024 via email

@AnCool-OvO
Copy link
Contributor

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

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

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

@1600858489
Copy link

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

@jones-so
Copy link

jones-so commented Apr 21, 2024 via email

@spacex-3
Copy link

依赖都安装了,收到语音还是提示错误,请问如何解决呀?应该是默认用的tts-1和whisper-1模型吧?我也没其他设置

[DEBUG][2024-09-18 22:03:15][chat_channel.py:190] - [chat_channel] ready to handle context: type=VOICE, content=tmp/240918-220315.mp3 [INFO][2024-09-18 22:03:16][bridge.py:68] - create bot for voice_to_text [ERROR][2024-09-18 22:03:16][chat_channel.py:303] - Worker return exception: Traceback (most recent call last): File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/root/chatgpt-on-wechat/channel/chat_channel.py", line 170, in _handle reply = self._generate_reply(context) File "/root/chatgpt-on-wechat/channel/chat_channel.py", line 205, in _generate_reply reply = super().build_voice_to_text(wav_path) File "/root/chatgpt-on-wechat/channel/channel.py", line 41, in build_voice_to_text return Bridge().fetch_voice_to_text(voice_file) File "/root/chatgpt-on-wechat/bridge/bridge.py", line 86, in fetch_voice_to_text return self.get_bot("voice_to_text").voiceToText(voiceFile) File "/root/chatgpt-on-wechat/bridge/bridge.py", line 72, in get_bot self.bots[typename] = create_voice(self.btype[typename]) File "/root/chatgpt-on-wechat/voice/factory.py", line 53, in create_voice raise RuntimeError RuntimeError

@jones-so
Copy link

jones-so commented Sep 18, 2024 via email

Leslie0310 pushed a commit to Leslie0310/chatgpt-on-wechat that referenced this issue Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tutorial Tutorial provided by maintainer, may be outdated
Projects
None yet
Development

No branches or pull requests