Skip to content

请问,目前的api.py文件已经兼容v4版本了吗? #2354

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

Open
Downupanddownup opened this issue May 5, 2025 · 11 comments
Open

请问,目前的api.py文件已经兼容v4版本了吗? #2354

Downupanddownup opened this issue May 5, 2025 · 11 comments

Comments

@Downupanddownup
Copy link
Contributor

Image

@xiaohuoxing
Copy link

不知为何,v4模型识别成v2的

.\runtime\python.exe -I api.py -d cuda -s "SoVITS_weights_v4/xxxx_e5_s745_l32.pth" -g "GPT_weights_v4/xxxx-e15.ckpt" -dr "G:\AI\GPT-SoVITS-v4-20250422fix\output\1.wav" -dt "xxxx请输入文字xxxxxx" -dl zh

INFO: 默认参考音频路径: G:\AI\GPT-SoVITS-v4-20250422fix\output\1.wav
INFO: 默认参考音频文本: xxxxxxx
INFO: 默认参考音频语种: zh
INFO: 半精: True
INFO: 编码格式: wav
INFO: 数据类型: int16
INFO: 模型版本: v2
INFO: Started server process [440]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9880 (Press CTRL+C to quit)
INFO: 192.168.115.232:46648 - "GET /?text=%E6%9C%89%E4%B8%80%E5%9C%BA%E5%A4%A7%E6%88%98%EF%BC%8C%E6%9C%80%E4%B8%BB%E8%A6%81%E7%9A%84%E5%8E%9F%E5%9B%A0%E5%B0%B1%E6%98%AF%E8%A6%81%E4%BA%89%E5%A4%BA%E8%BF%99%E5%8F%A3%E5%8F%A4%E9%BC%8E%E3%80%82&text_language=zh HTTP/1.1" 200 OK
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 407, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\fastapi\applications.py", line 1054, in call
await super().call(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\applications.py", line 123, in call
await self.middleware_stack(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\errors.py", line 186, in call
raise exc
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\errors.py", line 164, in call
await self.app(scope, receive, _send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\exceptions.py", line 65, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app
raise exc
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 754, in call
await self.middleware_stack(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 774, in app
await route.handle(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 295, in handle
await self.app(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 77, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app
raise exc
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 75, in app
await response(scope, receive, send)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 265, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 662, in aexit
raise exceptions[0]
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 261, in wrap
await func()
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 250, in stream_response
async for chunk in self.body_iterator:
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\concurrency.py", line 65, in iterate_in_threadpool
yield await anyio.to_thread.run_sync(_next, as_iterator)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 867, in run
result = context.run(func, *args)
File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\concurrency.py", line 54, in _next
return next(iterator)
File "G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav
infer_sovits = speaker_list[spk].sovits
KeyError: 'default'

@passby6someone
Copy link

遇到了同样的问题,跟 @xiaohuoxing 的报错一样

@yangyuke001
Copy link

看起来api.py和api_v2.py都没集成好v4模型,调用有问题,等一波作者大佬出手

@Karasukaigan
Copy link

不知为何,v4模型识别成v2的

.\runtime\python.exe -I api.py -d cuda -s "SoVITS_weights_v4/xxxx_e5_s745_l32.pth" -g "GPT_weights_v4/xxxx-e15.ckpt" -dr "G:\AI\GPT-SoVITS-v4-20250422fix\output\1.wav" -dt "xxxx请输入文字xxxxxx" -dl zh

INFO: 默认参考音频路径: G:\AI\GPT-SoVITS-v4-20250422fix\output\1.wav INFO: 默认参考音频文本: xxxxxxx INFO: 默认参考音频语种: zh INFO: 半精: True INFO: 编码格式: wav INFO: 数据类型: int16 INFO: 模型版本: v2 INFO: Started server process [440] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:9880 (Press CTRL+C to quit) INFO: 192.168.115.232:46648 - "GET /?text=%E6%9C%89%E4%B8%80%E5%9C%BA%E5%A4%A7%E6%88%98%EF%BC%8C%E6%9C%80%E4%B8%BB%E8%A6%81%E7%9A%84%E5%8E%9F%E5%9B%A0%E5%B0%B1%E6%98%AF%E8%A6%81%E4%BA%89%E5%A4%BA%E8%BF%99%E5%8F%A3%E5%8F%A4%E9%BC%8E%E3%80%82&text_language=zh HTTP/1.1" 200 OK ERROR: Exception in ASGI application Traceback (most recent call last): File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 407, in run_asgi result = await app( # type: ignore[func-returns-value] File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in call return await self.app(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\fastapi\applications.py", line 1054, in call await super().call(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\errors.py", line 186, in call raise exc File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\errors.py", line 164, in call await self.app(scope, receive, _send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\middleware\exceptions.py", line 65, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 754, in call await self.middleware_stack(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 774, in app await route.handle(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 295, in handle await self.app(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\routing.py", line 75, in app await response(scope, receive, send) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 265, in call await wrap(partial(self.listen_for_disconnect, receive)) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 662, in aexit raise exceptions[0] File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 261, in wrap await func() File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\responses.py", line 250, in stream_response async for chunk in self.body_iterator: File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\concurrency.py", line 65, in iterate_in_threadpool yield await anyio.to_thread.run_sync(_next, as_iterator) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio\to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\anyio_backends_asyncio.py", line 867, in run result = context.run(func, *args) File "G:\AI\GPT-SoVITS-v4-20250422fix\runtime\lib\site-packages\starlette\concurrency.py", line 54, in _next return next(iterator) File "G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

@yangyuke001
Copy link

@"G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

好像不行哦大佬

@Karasukaigan
Copy link

Karasukaigan commented May 8, 2025

@"G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

好像不行哦大佬

还是会识别错吗?请贴出报错或者相关信息。
请使用我提交的PR里的改法,而不是直接改为v4。

@Karasukaigan
Copy link

Karasukaigan commented May 8, 2025

@"G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

好像不行哦大佬

好消息,已经测试通过。请查看 #2352 最新的提交。
不会再报KeyError: 'default',且能正常生成音频。
但还是建议改用api_v2.pyapi.py对v4的支持仍不稳定。
Image

@yangyuke001
Copy link

@"G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

好像不行哦大佬

好消息,已经测试通过。请查看PR最新的提交。 不会再报KeyError: 'default',且能正常生成音频。 但还是建议改用api_v2.pyapi.py对v4的支持仍不稳定。 Image

给大佬倒茶!请问下,我看你提的pr里没涉及到api_v2.py的改动,api.py里倒是有一些加载v4模型的改动;就只改TTS.py里的那几行就行吗?
“”“
version = "v2"
if "custom" in configs and configs["custom"]["version"].lower() in ["v1", "v2", "v3", "v4"]:
version = configs["custom"]["version"].lower()
”“”

@Karasukaigan
Copy link

Karasukaigan commented May 9, 2025

@"G:\AI\GPT-SoVITS-v4-20250422fix\api.py", line 730, in get_tts_wav infer_sovits = speaker_list[spk].sovits KeyError: 'default'

尝试修改GPT_SoVITS/TTS_infer_pack/TTS.py里的以下代码,将默认模型改为“v4”似乎就能解决问题:

assert isinstance(configs, dict)
version = configs.get("version", "v4").lower() # 这里改为v4
assert version in ["v1", "v2", "v3", "v4"]
self.default_configs[version] = configs.get(version, self.default_configs[version])
self.configs: dict = configs.get("custom", deepcopy(self.default_configs[version]))
print(self.configs)

好像不行哦大佬

好消息,已经测试通过。请查看PR最新的提交。 不会再报KeyError: 'default',且能正常生成音频。 但还是建议改用api_v2.pyapi.py对v4的支持仍不稳定。 Image

给大佬倒茶!请问下,我看你提的pr里没涉及到api_v2.py的改动,api.py里倒是有一些加载v4模型的改动;就只改TTS.py里的那几行就行吗? “”“ version = "v2" if "custom" in configs and configs["custom"]["version"].lower() in ["v1", "v2", "v3", "v4"]: version = configs["custom"]["version"].lower() ”“”

测试过调用没问题。但如果出现新的报错,麻烦贴出错误或者告诉我该如何复现。

@yangyuke001
Copy link

@yangyuke001
Copy link

我又做了如下修改 :

Image
api_v2.py能跑起来v4模型了,但生成的音频很怪。。。

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

5 participants