Skip to content

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

Closed as not planned
Closed as not planned

Description

@ShowUNow

前置确认

  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

Activity

  1. dhlsam commented on Mar 9, 2023

    @dhlsam

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

  2. zhayujie commented on Mar 9, 2023

    @zhayujie
    Owner

    一、接收语音,回复文字

    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

  3. changed the title [-]对应语音合成平台的key要添加到哪里呢?[/-] [+]关于语音识别功能的使用[/+] on Mar 9, 2023
  4. pinned this issue on Mar 9, 2023
  5. 4331599 commented on Mar 10, 2023

    @4331599

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

  6. zhayujie commented on Mar 10, 2023

    @zhayujie
    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'

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

  7. yuyang0702 commented on Mar 10, 2023

    @yuyang0702

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

  8. Ayuyyae commented on Mar 10, 2023

    @Ayuyyae

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

  9. wanggang1987 commented on Mar 10, 2023

    @wanggang1987
    Contributor

    安装下pip3 install baidu-aip chardet

  10. huanyan commented on Mar 10, 2023

    @huanyan

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

  11. yuyang0702 commented on Mar 10, 2023

    @yuyang0702

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

  12. wangjiangmin1115 commented on Mar 10, 2023

    @wangjiangmin1115

    [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

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

  13. wangjiangmin1115 commented on Mar 10, 2023

    @wangjiangmin1115

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

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

  14. lingwecho commented on Mar 11, 2023

    @lingwecho

    wechaty比itchat更容易被封吗?

  15. 67 remaining items

  16. KunBoy5240 commented on Jul 31, 2023

    @KunBoy5240

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

  17. AnCool-OvO commented on Jan 22, 2024

    @AnCool-OvO
    Contributor

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

  18. jones-so commented on Jan 22, 2024

    @jones-so
  19. AnCool-OvO commented on Jan 23, 2024

    @AnCool-OvO
    Contributor

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

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

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

  20. 1600858489 commented on Apr 21, 2024

    @1600858489

    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

  21. jones-so commented on Apr 21, 2024

    @jones-so
  22. spacex-3 commented on Sep 18, 2024

    @spacex-3

    依赖都安装了,收到语音还是提示错误,请问如何解决呀?应该是默认用的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

  23. jones-so commented on Sep 18, 2024

    @jones-so
  24. zhayujie commented on Jun 1, 2026

    @zhayujie
    Owner

    Thanks for reporting this! This issue has had no activity for over a year and predates our major rewrite, so we're closing it during a backlog cleanup.

    🚀 CowAgent has been upgraded to 2.0 — an open-source super AI assistant & agent harness. It plans tasks, runs tools and skills, and autonomously grows with memory and a local knowledge base. Multi-model, multi-channel, lightweight, extensible, one-line install.

    If your need still applies to the new version, we'd love to hear it — feel free to open a fresh issue. ❤️


    感谢反馈!此 issue 一年多没有活动,且属于项目大版本重构之前的时期,我们在清理历史 backlog 时将其关闭。

    🚀 CowAgent 已升级到 2.0,升级为开源的超级 AI 助手 & Agent Harness 框架。能规划任务、调用工具与技能,并通过记忆和本地知识库自主成长。多模型、多渠道,轻量、可扩展,一行命令安装。

    如果你的需求在新版本上依然适用,欢迎新建一个 issue 告诉我们 ❤️

  25. added
    staleNo activity for a long time; closed during backlog cleanup
    on Jun 1, 2026
  26. jones-so commented on Jun 1, 2026

    @jones-so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleNo activity for a long time; closed during backlog cleanuptutorialTutorial provided by maintainer, may be outdated

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions