modelscope-funasr想实现文本转语音,有什么比较好的建议?

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想实现文本转语音,有什么比较好的建议?依赖有点难装,有没有简单一点的?

展开
收起
嘟嘟嘟嘟嘟嘟 2023-12-27 08:01:52 238 分享 版权
阿里云 AI 助理回答

问题分析与解答

根据您提供的信息,您在尝试使用 modelscope 和相关依赖(如 kanttsttsfrd)实现文本转语音(TTS)功能时遇到了以下主要问题:

  1. 缺少 ttsfrd 模块:无法找到正确的安装方式。
  2. Python 版本兼容性问题:不同版本的 Python 在安装 kantts 和其依赖时失败。
  3. 运行 demo 失败:可能与环境配置或依赖未正确安装有关。

以下是针对这些问题的详细解答和建议。


1. 关于 ttsfrd 模块缺失的问题

问题描述

您提到在运行代码时出现以下错误:

No module named 'ttsfrd'

这表明 ttsfrd 模块未正确安装或未包含在 modelscope 的依赖中。

解决方案

  • 确认模块来源ttsfrd 是一个非标准的 Python 包,通常由特定项目提供。根据您的描述,它可能是 kanttsmodelscope 的依赖之一。
  • 手动安装 ttsfrd

    • 如果 ttsfrd 是一个独立的模块,您可以尝试从源码安装。例如,如果该模块托管在 GitHub 上,可以使用以下命令安装:
    pip install git+https://github.com/<repository-url>.git
    
    • 如果 ttsfrdkantts 的子模块,请确保您安装的是完整版的 kantts,并检查其文档是否提供了额外的安装步骤。
  • 联系模型开发者:如果无法找到 ttsfrd 的安装方式,建议直接联系 modelscopekantts 的开发者团队,获取支持。


2. Python 版本兼容性问题

问题描述

您尝试在 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),以满足依赖要求。

    • 升级 Python 后,重新创建虚拟环境并安装依赖:
    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
    

3. 运行 demo 失败的问题

问题描述

您提到运行 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)
    

4. 简化 TTS 实现的建议

如果您觉得当前依赖安装复杂,可以考虑以下替代方案:

方案 1:使用预构建的 Docker 镜像

  • 推荐理由:Docker 镜像包含了所有必要的依赖,避免了手动安装的麻烦。
  • 操作步骤
    1. 拉取官方镜像:
      docker pull registry.cn-beijing.aliyuncs.com/modelscope/modelscope-inference:latest
      
    2. 启动容器并运行 TTS 示例代码:
      docker run -it --gpus all registry.cn-beijing.aliyuncs.com/modelscope/modelscope-inference:latest
      

方案 2:使用在线推理服务

  • 推荐理由:无需本地安装任何依赖,直接调用云端 API。
  • 操作步骤
    1. 登录阿里云 PAI 平台,部署 modelscope 的 TTS 模型服务。
    2. 使用 HTTP 请求调用服务:
      curl -XPOST http://<service-address>/generate \
        -H "Content-Type: application/json" \
        -d '{"text_input": "你好,欢迎使用通义千问。"}'
      

方案 3:选择其他轻量级 TTS 工具

  • 如果您对 modelscope 的依赖安装感到困难,可以尝试其他开源 TTS 工具,例如:
    • Coqui TTS:轻量级且易于安装。
    • ESPnet:支持多种语言的 TTS 模型。

总结与建议

  1. 优先解决 ttsfrd 模块问题:通过手动安装或联系开发者获取支持。
  2. 升级 Python 版本:确保满足 kantts 的最低版本要求。
  3. 尝试简化方案:使用 Docker 镜像或在线推理服务,避免复杂的本地环境配置。
  4. 参考官方文档:严格按照 modelscope 官方文档中的步骤操作,确保环境与代码一致。

如果仍有问题,请提供更多错误日志或上下文信息,以便进一步排查。您可以复制页面截图提供更多信息,我可以进一步帮您分析问题原因。

有帮助
无帮助
AI 助理回答生成答案可能存在不准确,仅供参考
0 条回答
写回答
取消 提交回答

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352

热门讨论

热门文章

还有其他疑问?
咨询AI助理