gTT 连接失败

问题描述

所以,我制作了一个简单的程序来从文件中读取行以从中创建音频文件。 但是我收到以下错误

Traceback (most recent call last):
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\urllib3\connectionpool.py",line 688,in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\urllib3\connectionpool.py",line 280,in _get_conn
    return conn or self._new_conn()
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\urllib3\connectionpool.py",line 979,in _new_conn
    raise SSLError(
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\requests\adapters.py",line 439,in send
    resp = conn.urlopen(
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\urllib3\connectionpool.py",line 755,in urlopen
    retries = retries.increment(
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\urllib3\util\retry.py",line 573,in increment
    raise MaxRetryError(_pool,url,error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='translate.google.com',port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\gtts\tts.py",line 263,in write_to_fp
    r = s.send(request=pr,File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\requests\sessions.py",line 655,in send
    r = adapter.send(request,**kwargs)
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\requests\adapters.py",line 514,in send
    raise SSLError(e,request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='translate.google.com',another exception occurred:

Traceback (most recent call last):
  File "C:/Arbeit/Python/PyCharm/Projects/createAudio/Audio_from_txt.py",line 15,in <module>
    save_file(filename=line)
  File "C:/Arbeit/Python/PyCharm/Projects/createAudio/Audio_from_txt.py",line 9,in save_file
    tts.save(filename+".wav")
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\gtts\tts.py",line 312,in save
    self.write_to_fp(f)
  File "C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\gtts\tts.py",line 279,in write_to_fp
    raise gTTSError(tts=self)
gtts.tts.gTTSError: Failed to connect. Probable cause: UnkNown

运行 pip install gtts 得到以下结果:

PS C:\Arbeit\Python\PyCharm\Projects\createAudio> pip install gtts
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: c:\users\alpha-omega\appdata\local\programs\python\python38\Include\UNKNowN
sysconfig: c:\users\alpha-omega\appdata\local\programs\python\python38\Include
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Requirement already satisfied: gtts in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (2.2.2)
Requirement already satisfied: click in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from gtts) (7.1.2)
Requirement already satisfied: requests in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from gtts) (2.25.1)
Requirement already satisfied: six in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from gtts) (1.15.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from requests->gtts) (1.26.3)
Requirement already satisfied: idna<3,>=2.5 in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from requests->gtts) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from requests->gtts) (4.0.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\alpha-omega\appdata\local\programs\python\python38\lib\site-packages (from requests->gtts) (2020.12.5)
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: c:\users\alpha-omega\appdata\local\programs\python\python38\Include\UNKNowN
sysconfig: c:\users\alpha-omega\appdata\local\programs\python\python38\Include
WARNING: Additional context:
user = False
home = None
root = None
prefix = None

我的程序是这样的:

import gtts
from tkinter.filedialog import askopenfilename



def save_file(filename):
    tts=gtts.gTTS(text=filename,lang="en")
   # filename="voice.mp3"
    tts.save(filename+".wav")

if __name__ == "__main__":
    input_file = askopenfilename()

    for line in input_file:
        save_file(filename=line)

我的问题:我该如何解决这个问题? 我正在使用 Pycharm 社区版和 Visual Studio 代码。 这些是我的环境变量:(我很新,不知道它们在这里是否重要)

C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python38\Scripts\
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python38\
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python39\Scripts\
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python39\
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python38-32\Scripts\
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python38-32\
C:\Arbeit\Python\Microsoft VS Code\bin
C:\Arbeit\Python\Microsoft VS Code
C:\Arbeit\Python\Anaconda
C:\Arbeit\Python\Anaconda\bin
C:\Arbeit\Python\Anaconda\Scripts
C:\Arbeit\Python\Anaconda\Library\bin
C:\Arbeit\Python\Anaconda\envs\tensorflow\lib\site-packages\binance;
C:\Users\Alpha-Omega\AppData\Local\Programs\Python\python38\python.exe

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...