jianchang512 / clone-voice

A sound cloning tool with a web interface, using your voice or any sound to record audio / 一个带web界面的声音克隆工具,使用你的音色或任意声音来录制音频
https://pyvideotrans.com
Other
7.46k stars 759 forks source link

执行python code_dev.py下载模型时提示aiohttp [SSL: CERTIFICATE_VERIFY_FAILED] 如何修改 #59

Closed Mumastema closed 9 months ago

Mumastema commented 10 months ago

python code_dev.py

异常栈:

aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False))
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1567fabd0>
 > tts_models/multilingual/multi-dataset/xtts_v2 is already downloaded.
 > Using model: xtts
 > voice_conversion_models/multilingual/vctk/freevc24 is already downloaded.
 > Using model: freevc
 > Loading pretrained speaker encoder model ...
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
    transport, protocol = await self._create_connection_transport(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
    await waiter
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 575, in _on_handshake_complete
    raise handshake_exc
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 557, in _do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 979, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/xcj/Desktop/clone-voice-main/code_dev.py", line 20, in <module>
    tts = TTS(model_name='voice_conversion_models/multilingual/vctk/freevc24').to(device)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/api.py", line 76, in __init__
    self.load_vc_model_by_name(model_name, gpu)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/api.py", line 157, in load_vc_model_by_name
    self.voice_converter = Synthesizer(vc_checkpoint=model_path, vc_config=config_path, use_cuda=gpu)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/utils/synthesizer.py", line 101, in __init__
    self._load_vc(vc_checkpoint, vc_config, use_cuda)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/utils/synthesizer.py", line 139, in _load_vc
    self.vc_model = setup_vc_model(config=self.vc_config)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/vc/models/__init__.py", line 16, in setup_model
    model = MyModel.init_from_config(config, samples)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/vc/models/freevc.py", line 552, in init_from_config
    model = FreeVC(config)
            ^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/vc/models/freevc.py", line 370, in __init__
    self.load_pretrained_speaker_encoder()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/vc/models/freevc.py", line 381, in load_pretrained_speaker_encoder
    self.enc_spk_ex = SpeakerEncoderEx(
                      ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/vc/modules/freevc/speaker_encoder/speaker_encoder.py", line 42, in __init__
    checkpoint = load_fsspec(weights_fpath, map_location="cpu")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/TTS/utils/io.py", line 46, in load_fsspec
    with fsspec.open(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/core.py", line 103, in __enter__
    f = self.fs.open(self.path, mode=mode)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/implementations/cached.py", line 436, in <lambda>
    return lambda *args, **kw: getattr(type(self), item).__get__(self)(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/spec.py", line 1295, in open
    f = self._open(
        ^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/implementations/cached.py", line 436, in <lambda>
    return lambda *args, **kw: getattr(type(self), item).__get__(self)(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/implementations/cached.py", line 697, in _open
    self.fs.get_file(path, fn)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/asyn.py", line 118, in wrapper
    return sync(self.loop, func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/asyn.py", line 103, in sync
    raise return_result
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/asyn.py", line 56, in _runner
    result[0] = await coro
                ^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fsspec/implementations/http.py", line 244, in _get_file
    async with session.get(self.encode_url(rpath), **kw) as r:
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/client.py", line 1187, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/client.py", line 574, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 994, in _wrap_create_connection
    raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host github.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')]
Mumastema commented 10 months ago

【补充】部分模型已下载成功,异常在以下地方触发:

> Model's license - MIT█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊| 895M/896M [01:36<00:00, 11.2MiB/s]
 > Check https://choosealicense.com/licenses/mit/ for more info.
 > Using model: freevc
 > Loading pretrained speaker encoder model ...
Traceback (most recent call last):
Mumastema commented 10 months ago

尝试在/aiohtto/client.py中添加自己的proxy=xxx也不生效

jianchang512 commented 10 months ago

网络问题,这个speaker模型需要从github下载 首先找个稳定的代理,然后电脑全局代理

也可以直接在终端设置代理

或者去模型下载那个地方,下载tss.cache.zip文件。源码版也适用

使用预编译时,如果模型均已下载,并正确解压,解压后目录结构如上图所示,但仍提示连接 github 网站失败,请 下载 tts_cache.zip 解压后得到2个文件,将这2个文件复制到 tts_cache 目录下