当前位置: 首页 > article >正文

安装MeloTTS报错解决方法

0. 研究背景

在国内环境中安装MeloTTS往往会报错,因为有些资料需要从国外网站中下载。

1. huggingface无法访问问题

首先需要解决国内无法访问huggingface的问题,可以配置使用国内镜像来解决。

export HF_ENDPOINT=https://hf-mirror.com

2. nltk无法下载问题

参考文档

3. unidic无法下载问题

在执行python -m unidic download 时会报错,由于网络原因。

download url: https://cotonoha-dic.s3-ap-northeast-1.amazonaws.com/unidic-3.1.0.zip
Dictionary version: 3.1.0+2021-08-31
Downloading UniDic v3.1.0+2021-08-31...
unidic-3.1.0.zip: 0.00B [00:00, ?B/s]
Traceback (most recent call last):
  File "/root/miniconda3/envs/tts/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/miniconda3/envs/tts/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/unidic/__main__.py", line 17, in <module>
    plac.call(commands[command], sys.argv[1:])
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/plac_core.py", line 436, in call
    cmd, result = parser.consume(arglist)
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/plac_core.py", line 287, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/unidic/download.py", line 104, in download_version
    download_and_clean(dictinfo['version'], dictinfo['url'])
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/unidic/download.py", line 62, in download_and_clean
    download_progress(url, fname)
  File "/root/miniconda3/envs/tts/lib/python3.9/site-packages/unidic/download.py", line 38, in download_progress
    urlretrieve(url, filename=fname, reporthook=t.update_to, data=None)
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 239, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/root/miniconda3/envs/tts/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

解决方式:

1. 从 https://cotonoha-dic.s3-ap-northeast-1.amazonaws.com/unidic-3.1.0.zip 中下载
2. 把下载后的文件上传到服务器中的 /root/miniconda3/envs/tts/lib/python3.9/site-packages/unidic,并把 unidic-3.1.0.zip 重命名为 unidic.zip
3. 修改 download.py,找到 93 行,也就是在 download_version() 函数中,注释掉除了 download_and_clean() 之外的内容
4. 修改 download_and_clean() 中的参数,你可以随意设置
5. 修改 download.py 中的 62 行,注释 download_process()
6. 执行 python -m unidic download

参考文件

给这个压缩包赋值执行权限

chmod +x unidic.zip

4. 下载模型

melo/download_utils.py中可以找到对应的下载地址

DOWNLOAD_CKPT_URLS = {
    'EN': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/EN/checkpoint.pth',
    'EN_V2': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/EN_V2/checkpoint.pth',
    'FR': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/FR/checkpoint.pth',
    'JP': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/JP/checkpoint.pth',
    'ES': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/ES/checkpoint.pth',
    'ZH': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/ZH/checkpoint.pth',
    'KR': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/KR/checkpoint.pth',
}

DOWNLOAD_CONFIG_URLS = {
    'EN': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/EN/config.json',
    'EN_V2': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/EN_V2/config.json',
    'FR': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/FR/config.json',
    'JP': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/JP/config.json',
    'ES': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/ES/config.json',
    'ZH': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/ZH/config.json',
    'KR': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/KR/config.json',
}

PRETRAINED_MODELS = {
    'G.pth': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/pretrained/G.pth',
    'D.pth': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/pretrained/D.pth',
    'DUR.pth': 'https://myshell-public-repo-host.s3.amazonaws.com/openvoice/basespeakers/pretrained/DUR.pth',
}

LANG_TO_HF_REPO_ID = {
    'EN': 'myshell-ai/MeloTTS-English',
    'EN_V2': 'myshell-ai/MeloTTS-English-v2',
    'EN_NEWEST': 'myshell-ai/MeloTTS-English-v3',
    'FR': 'myshell-ai/MeloTTS-French',
    'JP': 'myshell-ai/MeloTTS-Japanese',
    'ES': 'myshell-ai/MeloTTS-Spanish',
    'ZH': 'myshell-ai/MeloTTS-Chinese',
    'KR': 'myshell-ai/MeloTTS-Korean',
}

5. 阻止联网下载文件

默认会从网上下载模型和配置文件,需要修改melo/download_utils.py源码,阻止联网下载文件。

def load_or_download_config(locale, use_hf=True, config_path=None):
    if config_path is None:
        language = locale.split('-')[0].upper()
        if use_hf:
            assert language in LANG_TO_HF_REPO_ID
            config_path = hf_hub_download(repo_id=LANG_TO_HF_REPO_ID[language], filename="config.json")
        #else:
        #    assert language in DOWNLOAD_CONFIG_URLS
        #    config_path = cached_path(DOWNLOAD_CONFIG_URLS[language])
    return utils.get_hparams_from_file(config_path)

def load_or_download_model(locale, device, use_hf=True, ckpt_path=None):
    if ckpt_path is None:
        language = locale.split('-')[0].upper()
        if use_hf:
            assert language in LANG_TO_HF_REPO_ID
            ckpt_path = hf_hub_download(repo_id=LANG_TO_HF_REPO_ID[language], filename="checkpoint.pth")
        #else:
        #    assert language in DOWNLOAD_CKPT_URLS
        #    ckpt_path = cached_path(DOWNLOAD_CKPT_URLS[language])
    return torch.load(ckpt_path, map_location=device)

修改app.py

'EN': TTS(language='EN', device=device, use_hf=False, config_path='/root/autodl-tmp/tts/model/English/config.json', ckpt_path='/root/autodl-tmp/tts/model/English/checkpoint.pth')

6. 解决AttributeError: module ‘botocore.exceptions’ has no attribute 'HTTPClientError’报错问题

botocore>=1.34.98
cached_path>=1.6.2
boto3>=1.35.81

参考文档

7. 解决nltk_data报错问题

报错信息:

  Resource averaged_perceptron_tagger_eng not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('averaged_perceptron_tagger_eng')
  
  For more information see: https://www.nltk.org/data.html

  Attempted to load taggers/averaged_perceptron_tagger_eng/

  Searched in:
    - '/root/nltk_data'
    - '/root/miniconda3/envs/tts/nltk_data'
    - '/root/miniconda3/envs/tts/share/nltk_data'
    - '/root/miniconda3/envs/tts/lib/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'

解决方法:

git clone https://github.com/nltk/nltk_data.git

找到nltk_data/packages/taggers/averaged_perceptron_tagger_eng.zip复制到/root/nltk_data/taggers解压。

8. 报错cmudict解决方法

将上面下载的nltk_data解压出来的cmudict目录放置到/root/nltk_data路径下。


http://www.kler.cn/a/518054.html

相关文章:

  • 08-ArcGIS For JavaScript-通过Mesh绘制几何体(Cylinder,Circle,Box,Pyramid)
  • 【C语言算法刷题】第10题
  • 用科技守护团圆时光,约克VRF中央空调新天氟地水/天氟热水让春节更美好!
  • 【贪心算法】洛谷P1090 合并果子 / [USACO06NOV] Fence Repair G
  • C++实现设计模式---桥接模式 (Bridge)
  • 「 机器人 」利用电压偏移实现扑翼飞行器的俯仰力矩控制
  • leetcode刷题记录(八十七)——215. 数组中的第K个最大元素
  • 前端(数据可视化低代码平台)AI
  • 常用集合-数据结构-MySql
  • openlava/LSF 用户组管理脚本
  • 22_解析XML配置文件_List列表
  • eniops库中pack函数使用方法
  • Python数据分析-pandas入门(五)
  • LosslessCut:一款强大的音视频无损剪辑工具
  • 【深度学习】常见模型-生成对抗网络(Generative Adversarial Network, GAN)
  • 【优选算法】10----无重复字符的最长子串
  • Vue.js组件开发-如何实现带有搜索功能的下拉框
  • CASAIM与友达光电达成深度合作,CASAIM IS自动化蓝光测量技术为创新显示技术发展注入新的活力
  • Poetry shell --> poetry-plugin-shell
  • Hnu电子电路实验4