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

配置企业微信识别用户发送的语音时报错,使用的百度语音 #90

Open
2 tasks done
dreamaichina opened this issue Sep 3, 2024 · 3 comments
Open
2 tasks done

Comments

@dreamaichina
Copy link

前置确认

  • 我确认我运行的是最新版本的代码,并且安装了所需的依赖,在FAQS中也未找到类似问题。

⚠️ 搜索issues中是否已存在类似问题

  • 我已经搜索过issues和disscussions,没有跟我遇到的问题相关的issue

操作系统类型?

Windows

运行的python版本是?

python 3.10

使用的dify-on-wechat版本是?

Latest Release

运行的channel类型是?

other

复现步骤 🕹

企业微信配置百度语音,给配置好的企业微信发送文字能正常回复文字,发送文字也可以正常回复语音,唯独发送语音时报错。
{
"coze_api_base": "https://api.coze.cn/open_api/v2",
"coze_api_key": "没问题",
"coze_bot_id": "没问题",
"channel_type": "wework",
"model": "coze",
"single_chat_prefix": [""],
"single_chat_reply_prefix": "",
"group_chat_prefix": ["@bot"],
"group_name_white_list": ["ALL_GROUP"],
"accept_friend_commands": ["加好友"],
"group_exit_msg": "退群聊通知文案",
"speech_recognition": "True",
"group_speech_recognition": "True",
"voice_to_text": "baidu",
"text_to_voice": "baidu",
"baidu_dev_pid": 1536,
"baidu_app_id": "没问题",
"baidu_api_key": "没问题",
"baidu_secret_key": "没问题",
"accept_friend_msg": "通过好友发送的提示语"
}

问题描述 😯

配了百度语音识别,就一直报这个错误,
[ERROR][2024-09-03 19:23:13][wework_message.py:101] - D:\coze-workchat\dify-on-wechat\tmp\20240903192311.silk
[ERROR][2024-09-03 19:23:13][chat_channel.py:326] - Worker return exception: Error: could not open input file
Traceback (most recent call last):
File "C:\Users\lizhi\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "D:\coze-workchat\dify-on-wechat\channel\chat_channel.py", line 175, in _handle
reply = self._generate_reply(context)
File "D:\coze-workchat\dify-on-wechat\channel\chat_channel.py", line 201, in _generate_reply
cmsg.prepare()
File "D:\coze-workchat\dify-on-wechat\channel\chat_message.py", line 68, in prepare
self._prepare_fn()
File "D:\coze-workchat\dify-on-wechat\channel\wework\wework_message.py", line 133, in
self.prepare_fn = lambda: c2c_download_and_convert(wework, wework_msg, file_name)
File "D:\coze-workchat\dify-on-wechat\channel\wework\wework_message.py", line 102, in c2c_download_and_convert
pilk.silk_to_wav(save_path, wav_file, rate=24000)
File "C:\Users\lizhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pilk_init
.py", line 45, in silk_to_wav
decode(silk, pcm_path, pcm_rate=rate)
OSError: Error: could not open input file
语音输入对方接收到后找不到语音文件。查看本地临时文件20240903153618.silk.cdncomtdl都是这种,多了个后缀.cdncomtdl导致找不到,不知道啥原因。有人说是下载语音文件时没完成,但是不知道具体原因。求解?

终端日志 📒

[ERROR][2024-09-03 19:23:13][wework_message.py:101] - D:\coze-workchat\dify-on-wechat\tmp\20240903192311.silk
[ERROR][2024-09-03 19:23:13][chat_channel.py:326] - Worker return exception: Error: could not open input file
Traceback (most recent call last):
  File "C:\Users\lizhi\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\coze-workchat\dify-on-wechat\channel\chat_channel.py", line 175, in _handle
    reply = self._generate_reply(context)
  File "D:\coze-workchat\dify-on-wechat\channel\chat_channel.py", line 201, in _generate_reply
    cmsg.prepare()
  File "D:\coze-workchat\dify-on-wechat\channel\chat_message.py", line 68, in prepare
    self._prepare_fn()
  File "D:\coze-workchat\dify-on-wechat\channel\wework\wework_message.py", line 133, in <lambda>
    self._prepare_fn = lambda: c2c_download_and_convert(wework, wework_msg, file_name)
  File "D:\coze-workchat\dify-on-wechat\channel\wework\wework_message.py", line 102, in c2c_download_and_convert
    pilk.silk_to_wav(save_path, wav_file, rate=24000)
  File "C:\Users\lizhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pilk\__init__.py", line 45, in silk_to_wav
    decode(silk, pcm_path, pcm_rate=rate)
OSError: Error: could not open input file       
@yangxushan
Copy link

yangxushan commented Sep 5, 2024

我使用讯飞语音,也遇到了类似错误:
{
"dify_api_base": "http://172.16.1.232/v1",
"dify_api_key": "app-9yOHDg5519LHOD******",
"dify_app_type": "agent",
"channel_type": "wx",
"model": "dify",
"single_chat_prefix": [""],
"single_chat_reply_prefix": "",
"group_chat_prefix": ["@bot"],
"group_name_white_list": ["ALL_GROUP"],
"accept_friend_commands": ["加好友"],
"group_exit_msg": "退群聊通知文案",
"error_reply": "我卡住了,请您稍后重试~",
"image_recognition": true,
"voice_to_text": "xunfei",
"text_to_voice": "xunfei",
"speech_recognition": true,
"group_speech_recognition": false,
"voice_reply_voice": false,
"accept_friend_msg": "通过好友发送的提示语"
}

[WARNING][2024-09-05 18:35:30][chat_channel.py:207] - [chat_channel]any to wav error, use raw path. [WinError 2] 系统找不到指定的文件。
[WARNING][2024-09-05 18:35:30][xunfei_voice.py:72] - XunfeiVoice init failed: module 'websocket' has no attribute 'enableTrace', ignore
[INFO][2024-09-05 18:35:30][wechat_channel.py:246] - [WX] sendMsg=Reply(type=ERROR, content=[ERROR]
讯飞语音识别出错了;{0}), receiver=@f91fe7d980813809f2a5c37ffbacf0cafd5e0bac3afac8a030caec55d372a5b9

@yangxushan
Copy link

我的问题解决了,可以识别语音了,解决方法:
1、下载安装ffmpeg文件
2、 pip install websocket-client

@dreamaichina
Copy link
Author

dreamaichina commented Sep 6, 2024

我的问题解决了,可以识别语音了,解决方法: 1、下载安装ffmpeg文件 2、 pip install websocket-client

我安装了ffmpeg,我的是找不到硬盘上的语音文件,如果我硬编码一个语音文件在硬盘上,然后让百度识别是没问题的。我试试讯飞。。
你用讯飞 apiid,key什么的在config.json里的名称是什么啊?“xunfei_app_id”这种?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants