1、window
2、
kantts 0.0.1
modelscope 1.10.0
torch 2.1.2
model_id = 'damo/speech_sambert-hifigan_tts_zhiyan_emo_zh-cn_16k'
3、https://www.modelscope.cn/models/damo/speech_sambert-hifigan_tts_zhiyan_emo_zh-cn_16k/summary
4、运行demo 无法执行
5、没有 ttsfrd 模块,找不到正确的安装方式
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 843, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\28100.conda\envs\py38\lib\site-packages\modelscope\pipelines\audio\text_to_speech_pipeline.py", line 9, in
from modelscope.models.audio.tts import SambertHifigan
File "", line 1039, in _handle_fromlist
File "C:\Users\28100.conda\envs\py38\lib\site-packages\modelscope\utils\import_utils.py", line 434, in getattr
module = self._get_module(self._class_to_module[name])
File "C:\Users\28100.conda\envs\py38\lib\site-packages\modelscope\utils\import_utils.py", line 453, in _get_module
raise RuntimeError(
RuntimeError: Failed to import modelscope.models.audio.tts.sambert_hifi because of the following error (look up to see its traceback):
No module named 'ttsfrd'
6、问题及排查方向
6.1、没有 ttsfrd 模块,找不到正确的安装方式
6.2、python3.8版本尝试安装kantts 1.0.1版本,失败
ERROR: Ignored the following versions that require a different python version: 1.5.0 Requires-Python >=3.9
ERROR: Could not find a version that satisfies the requirement ttsfrd (from kantts) (from versions: none)
ERROR: No matching distribution found for ttsfrd
6.3、python3.9版本尝试安装kantts 1.0.1版本,失败
ERROR: Could not find a version that satisfies the requirement ttsfrd (from kantts) (from versions: none)
ERROR: No matching distribution found for ttsfrd
modelscope-funasr想实现文本转语音,有什么比较好的建议?依赖有点难装,有没有简单一点的?
根据您提供的信息,您在尝试使用 modelscope
和相关依赖(如 kantts
和 ttsfrd
)实现文本转语音(TTS)功能时遇到了以下主要问题:
ttsfrd
模块:无法找到正确的安装方式。kantts
和其依赖时失败。以下是针对这些问题的详细解答和建议。
ttsfrd
模块缺失的问题您提到在运行代码时出现以下错误:
No module named 'ttsfrd'
这表明 ttsfrd
模块未正确安装或未包含在 modelscope
的依赖中。
ttsfrd
是一个非标准的 Python 包,通常由特定项目提供。根据您的描述,它可能是 kantts
或 modelscope
的依赖之一。手动安装 ttsfrd
:
ttsfrd
是一个独立的模块,您可以尝试从源码安装。例如,如果该模块托管在 GitHub 上,可以使用以下命令安装:pip install git+https://github.com/<repository-url>.git
ttsfrd
是 kantts
的子模块,请确保您安装的是完整版的 kantts
,并检查其文档是否提供了额外的安装步骤。联系模型开发者:如果无法找到 ttsfrd
的安装方式,建议直接联系 modelscope
或 kantts
的开发者团队,获取支持。
您尝试在 Python 3.8 和 Python 3.9 环境下安装 kantts
1.0.1 版本时均失败,提示如下错误:
ERROR: Could not find a version that satisfies the requirement ttsfrd (from kantts)
升级 Python 版本:根据错误信息,kantts
1.5.0 及以上版本要求 Python >= 3.9。建议您升级到 Python 3.9 或更高版本(如 Python 3.10),以满足依赖要求。
conda create -n py39 python=3.9
conda activate py39
pip install modelscope kantts
降级 kantts
版本:如果您无法升级 Python,可以尝试安装较低版本的 kantts
,例如 1.0.1:
pip install kantts==1.0.1
检查依赖冲突:如果仍然无法安装,建议使用 pip
的调试模式查看具体问题:
pip install kantts --verbose
您提到运行 demo 时无法执行,可能与以下原因有关: - 缺少必要的依赖模块(如 ttsfrd
)。 - 环境配置不完整或版本不匹配。
检查依赖完整性:确保所有依赖均已正确安装。可以通过以下命令验证:
pip list | grep -E "modelscope|kantts|torch"
如果发现缺少某些依赖,请手动安装。
清理并重新安装依赖:有时依赖冲突会导致运行失败。建议清理现有环境并重新安装:
pip uninstall modelscope kantts torch -y
pip install modelscope kantts torch
运行官方示例代码:参考 modelscope
官方文档中的 TTS 示例代码,确保代码逻辑与环境配置一致。例如:
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
model_id = 'damo/speech_sambert-hifigan_tts_zhiyan_emo_zh-cn_16k'
tts_pipeline = pipeline(task=Tasks.text_to_speech, model=model_id)
output = tts_pipeline("你好,欢迎使用通义千问。")
print(output)
如果您觉得当前依赖安装复杂,可以考虑以下替代方案:
docker pull registry.cn-beijing.aliyuncs.com/modelscope/modelscope-inference:latest
docker run -it --gpus all registry.cn-beijing.aliyuncs.com/modelscope/modelscope-inference:latest
modelscope
的 TTS 模型服务。curl -XPOST http://<service-address>/generate \
-H "Content-Type: application/json" \
-d '{"text_input": "你好,欢迎使用通义千问。"}'
modelscope
的依赖安装感到困难,可以尝试其他开源 TTS 工具,例如:
ttsfrd
模块问题:通过手动安装或联系开发者获取支持。kantts
的最低版本要求。modelscope
官方文档中的步骤操作,确保环境与代码一致。如果仍有问题,请提供更多错误日志或上下文信息,以便进一步排查。您可以复制页面截图提供更多信息,我可以进一步帮您分析问题原因。
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352