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

大佬请教一下,我用wechat机器人请求vits-simple-api,反馈语音合成失败,该如何解决。 #36

Closed
cgnannan opened this issue May 14, 2023 · 19 comments

Comments

@cgnannan
Copy link

cgnannan commented May 14, 2023

大佬您好,最近在测试微信机器人的语音合成方案,在调用咱们家的vist-simple-api时遇到了点问题,想请教您。

前置确认
1.我确认我运行的是最新版本的代码,并且安装了所需的依赖
搜索issues中是否已存在类似问题

2.我已经搜索过issues,没有跟我遇到的问题相关的issue

操作系统类型?
Windows 10 专业版(21H2)

运行的python版本是?
python 3.10.8

复现步骤 🕹
启动终端——>激活环境变量(fort)——>python app.py——>给微信机器人发语音——>请求失败

问题描述 😯
在微信机器人项目(https://github.com/zhayujie/chatgpt-on-wechat) 中调用仓库的语音合成api,现实语音合成失败。
IMG_99673FB09C89-1

终端日志 📒
127.0.0.1 - - [14/May/2023 13:12:40] "POST /voice HTTP/1.1" 400 -

Screen Shot 2023-05-14 at 1 14 15 PM
@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

看看是不是post请求的代码写错了,可以把微信机器人项目里的post方法单独拿出来测试一下,content-typemultipart/form-data

@cgnannan
Copy link
Author

cgnannan commented May 14, 2023

看看是不是post请求的代码写错了,可以把微信机器人项目里的post方法单独拿出来测试一下,content-typemultipart/form-data

谢谢大佬,您判断的很准,我看微信机器人请求vits-simple-api代码,post方法中api的url地址引用错了,修正后vits能接到请求了。
Screen Shot 2023-05-14 at 2 16 18 PM

但是新问题产生了,我接到了vits-simple-api发来的wav格式语音文件,容量15B(时长0秒),点击播放听不到声音。大佬,是不是因为我说中文,而vits的Model中我没有配套中文模型库的原因?亦或是语音自动识别等参数设置错误的原因?

用汉语、日语和英语连续发了三个语音,回复的都是15B大小、0秒时长,听不到声音的语音文件。

IMG_FB87804E406F-1
IMG_20D2D7ED2514-1

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

我的建议是先单独测试vits-simple-api能否正常工作,发送请求返回的语音是否正常。不这样我无法确定是哪个环节出现了问题。
请求的语音也要确保模型支持该语言,这个可以在http://127.0.0.1:23456/voice/speakers里面看到

@cgnannan
Copy link
Author

cgnannan commented May 14, 2023

我的建议是先单独测试vits-simple-api能否正常工作,发送请求返回的语音是否正常。不这样我无法确定是哪个环节出现了问题。 请求的语音也要确保模型支持该语言,这个可以在http://127.0.0.1:23456/voice/speakers里面看到

大佬,我单独运行vits-simpe-api数据库的python app.py后,终端显示如下日志:
127.0.0.1 - - [14/May/2023 16:11:03] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [14/May/2023 16:11:03] "GET /favicon.ico HTTP/1.1" 404 -
Screen Shot 2023-05-14 at 4 20 58 PM

在网页打开http://127.0.0.1:23456/,显示如下:
Screen Shot 2023-05-14 at 4 16 19 PM

在页面打开[http://127.0.0.1:23456/voice/speakers,显示如下:
Screen Shot 2023-05-14 at 4 17 55 PM

是不是我在配置vits-simple-api的时候,还是有错误的操作

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

应该是忘记配置模型了,没有模型用不了。vits-simple-api里不带模型,模型要另外下载

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

看看是不是post请求的代码写错了,可以把微信机器人项目里的post方法单独拿出来测试一下,content-typemultipart/form-data

谢谢大佬,您判断的很准,我看微信机器人请求vits-simple-api代码,post方法中api的url地址引用错了,修正后vits能接到请求了。 Screen Shot 2023-05-14 at 2 16 18 PM

但是新问题产生了,我接到了vits-simple-api发来的wav格式语音文件,容量15B(时长0秒),点击播放听不到声音。大佬,是不是因为我说中文,而vits的Model中我没有配套中文模型库的原因?亦或是语音自动识别等参数设置错误的原因?

用汉语、日语和英语连续发了三个语音,回复的都是15B大小、0秒时长,听不到声音的语音文件。

IMG_FB87804E406F-1 IMG_20D2D7ED2514-1

刚刚没注意看,这个url应该没有写错,确实是要请求http://127.0.0.1:23456/voice
另外正常来说vits的请求应该会有logging产生的日志,但在你的截图中没有看到。然后我本地尝试在config.py中不填写模型路径的时,发现logging无法正常工作,这应该是个bug,我正在研究如何解决。

@cgnannan
Copy link
Author

应该是忘记配置模型了,没有模型用不了。vits-simple-api里不带模型,模型要另外下载

大佬,按照readme的流程和目录规范,已经准备好Model且在config.py中配置了对应的路径。
Screen Shot 2023-05-14 at 5 35 04 PM

python app.py,在网页打开以下地址
http://127.0.0.1:23456/
http://127.0.0.1:23456/voice/speakers

仍然如下图所示
Screen Shot 2023-05-14 at 5 40 09 PM

Screen Shot 2023-05-14 at 5 39 46 PM

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

要在MODEL_LIST里面填写模型路径,你圈的地方是我写的注释

@cgnannan
Copy link
Author

要在MODEL_LIST里面填写模型路径,你圈的地方是我写的注释

在MODEL_LIST中填写模型路径后,运行时,终端窗口提示类型错误。大佬,是否我需要直接写绝对路径?
Screen Shot 2023-05-14 at 6 00 10 PM

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

这个是hubert模型被识别成了w2v2模型,config.json是否是模型对应的文件。另外如果只需要语音合成的话其实hubert模型没有用

@cgnannan
Copy link
Author

cgnannan commented May 14, 2023

这个是hubert模型被识别成了w2v2模型,config.json是否是模型对应的文件。另外如果只需要语音合成的话其实hubert模型没有用
模型和对应的配置文件是从您推荐的仓库下载的
Screen Shot 2023-05-14 at 6 28 43 PM

git pull了您最新的代码,运行后识别到模型了,但仍然报错。
(fort) E:\Fort\WechatBot\vits-simple-api>python app.py
INFO:root:Loaded checkpoint 'E:\Fort\WechatBot\vits-simple-api/Model/Nene_Nanami_Rong_Tang/1026_epochs.pth' (iteration None)
Traceback (most recent call last):
File "E:\Fort\WechatBot\vits-simple-api\app.py", line 28, in
tts = merge_model(app.config["MODEL_LIST"])
File "E:\Fort\WechatBot\vits-simple-api\utils\merge.py", line 53, in merge_model
obj = vits(model=i[0], config=i[1])
File "E:\Fort\WechatBot\vits-simple-api\voice.py", line 54, in init
self.load_model(model, model_)
File "E:\Fort\WechatBot\vits-simple-api\voice.py", line 65, in load_model
self.emotion_reference = np.load(model_)
File "E:\Fort\WechatBot\vits-simple-api\fort\lib\site-packages\numpy\lib\npyio.py", line 390, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
TypeError: expected str, bytes or os.PathLike object, not NoneType

Screen Shot 2023-05-14 at 6 31 07 PM

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

噢,你下的Nene_Nanami_Rong_Tang是w2v2模型,但第三个位置应该填写npy文件,例如[ABS_PATH+"/Model/w2v2-vits/1026_epochs.pth", ABS_PATH+"/Model/w2v2-vits/config.json", ABS_PATH+"/all_emotions.npy"],不同的模型一定要遵循注释里的说明来填写

@cgnannan
Copy link
Author

噢,你下的Nene_Nanami_Rong_Tang是w2v2模型,但第三个位置应该填写npy文件,例如[ABS_PATH+"/Model/w2v2-vits/1026_epochs.pth", ABS_PATH+"/Model/w2v2-vits/config.json", ABS_PATH+"/all_emotions.npy"],不同的模型一定要遵循注释里的说明来填写

大佬,重新检查并匹配了模型,运行后,终端显示如下
Screen Shot 2023-05-14 at 6 55 43 PM

访问
http://127.0.0.1:23456
http://127.0.0.1:23456/voice/speakers
网页显示如下
Screen Shot 2023-05-14 at 6 57 38 PM
Screen Shot 2023-05-14 at 6 57 03 PM

者是否意味着已经成功运行vist-simple-api了?

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

是的

@cgnannan
Copy link
Author

是的

谢谢大佬指点,我现在去试试微信机器人请求vits-simple-api.

@cgnannan
Copy link
Author

是的

微信机器人能请求vits-simple-api,但是提示缺少pyopenjtalk依赖库。我pip install pyopenjtalk,怎么都装不上
(fort) E:\Fort\WechatBot\vits-simple-api>pip3 install pyopenjtalk
Collecting pyopenjtalk
Using cached pyopenjtalk-0.3.0.tar.gz (1.5 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
setup.py:26: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
_CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
Traceback (most recent call last):
File "E:\Fort\WechatBot\vits-simple-api\fort\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "E:\Fort\WechatBot\vits-simple-api\fort\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "E:\Fort\WechatBot\vits-simple-api\fort\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\win10\AppData\Local\Temp\pip-build-env-it0pfaq3\overlay\Lib\site-packages\setuptools\build_meta.py", line 162, in get_requires_for_build_wheel
return self._get_build_requires(
File "C:\Users\win10\AppData\Local\Temp\pip-build-env-it0pfaq3\overlay\Lib\site-packages\setuptools\build_meta.py", line 143, in _get_build_requires
self.run_setup()
File "C:\Users\win10\AppData\Local\Temp\pip-build-env-it0pfaq3\overlay\Lib\site-packages\setuptools\build_meta.py", line 267, in run_setup
super(_BuildMetaLegacyBackend,
File "C:\Users\win10\AppData\Local\Temp\pip-build-env-it0pfaq3\overlay\Lib\site-packages\setuptools\build_meta.py", line 158, in run_setup
exec(compile(code, file, 'exec'), locals())
File "setup.py", line 153, in
File "C:\Users\win10\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 503, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\win10\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\win10\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1440, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

试试pip3 install openjtalk==0.3.0.dev2
或者下载对应你的系统和python版本的whl再用pip install安装

@cgnannan
Copy link
Author

下载

大佬可以啦,现在机器人能正确返回语音啦。真是太感谢啦,占用您一下午时间。您细致、耐心、专业的解决方案,真是让人佩服啊。

IMG_849A512594DC-1

@Artrajz
Copy link
Owner

Artrajz commented May 14, 2023

不客气

@Artrajz Artrajz closed this as completed May 17, 2023
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