将gTT导入Python问题

时间:2018-12-17 20:49:34

标签: python google-text-to-speech

当我在Python Shell中输入代码时 我收到此错误。

  prfun lemma_nat_mul_1_is_nat
    {x: nat}
    {y: int}
    .<x>.
    ( pf_x1: MUL(x,1,y) )
    : [y == x] void
  = sif x <= 0 
      then let
          prval pf_01_0 = MULbas{1}()
          prval _       = mul_isfun(pf_01_0, pf_x1)
        in () end
      else let
          prval pf_xm1  = mul_istot{x-1,1}()
          prval _       = lemma_nat_mul_1_is_nat{x-1}(pf_xm1)
          prval pf2_x1  = mul_add_const{1}{x-1,1}(pf_xm1)
          prval _       = mul_isfun(pf_x1, pf2_x1)
        in () end


  prfn lemma_x_mul_1_is_x
    {x: int}
    {y: int}
    ( pf_x1: MUL(x,1,y) )
    : [y == x] void
  = sif x < 0 
      then let
          prval pf_neg = mul_istot{~x,1}()
          prval _      = lemma_nat_mul_1_is_nat{~x}(pf_neg)
          prval pf2_x1 = mul_negate{~x,1}(pf_neg)
          prval _      = mul_isfun(pf_x1, pf2_x1)
        in () end
      else lemma_nat_mul_1_is_nat{x}{y}(pf_x1)


  prfn lemma_mul_gez
    {a:  pos}
    {b:  int}
    {ab: nat}
    ( pf: MUL(a,b,ab) )
    : [b >= 0; (ab == 0 && b == 0) || (ab > 0 && b > 0)] void
  = let
    prfun loop
      {a:  pos}
      {b:  int}
      {ab: int}
      {i:  pos | i <= a}
      {ib: int | (ib < 0 && b < 0) || (ib == 0 && b == 0) || (ib > 0 && b > 0) }
      .<a-i>.
      ( pfi: MUL(i,b,ib)
      , pf : MUL(a,b,ab) )
      : [(ab < 0 && b < 0) || (ab == 0 && b == 0) || (ab > 0 && b > 0)] void
    = sif i >= a (* i == a *)
      then mul_isfun(pf,pfi)
      else let
          prval pfi_inc = mul_add_const{1}(pfi)
        in loop(pfi_inc, pf) end

    prval pf1 = mul_istot{1,b}()
    prval _   = lemma_x_mul_1_is_x(mul_commute(pf1))
  in loop(pf1, pf) end

因为我已经正确安装了gTTS,所以我可以肯定。 我使用了https://pypi.org/project/gTTS/

给出的示例

我使用的代码是

    Traceback (most recent call last):
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 344, in connect
    ssl_context=context)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 344, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 853, in _create
    self.do_handshake()
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, 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: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\gtts\tts.py", line 189, in write_to_fp
    part_tk = self.token.calculate_token(part)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\gtts_token\gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\gtts_token\gtts_token.py", line 55, in _get_token_key
    response = requests.get("https://translate.google.com/")
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    tts.write_to_fp(mp3_fp)
  File "C:\Users\Raav\AppData\Local\Programs\Python\Python37\lib\site-packages\gtts\tts.py", line 194, in write_to_fp
    str(e))
gtts.tts.gTTSError: Connection error during token calculation: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)')))

我没有创建单独的程序,我只是在IDLE中分别输入了每一行。

0 个答案:

没有答案