edge-tts
edge-tts copied to clipboard
IPv6 not falling back to IPv4 (aiohttp upstream issue - No Happy Eyeballs support)
When I tried to run 'edge tts -- text' Hello, world '-- write media hello. mp3', this error occurred. I believe this is my own reason, but I cannot solve it.
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1070, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1054, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 963, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('2620:1ec:c11::237', 443, 0, 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/edge-tts", line 8, in
Are you connecting to a VPN with an "IPv6 killswitch"?
I once failed to configure VPN, but then I turned off all agents in the environment variable. I am not sure if I have completely cancelled my configuration
This seems like an IPv6 configuration issue on your end.
Indeed, it seems aiohttp does not support Happy Eyeballs: https://github.com/aio-libs/aiohttp/issues/4451
So should I try to turn off ipv6?
Could you try that and let me know?
yes,thank you for your help
Perfect, I will see if I could work around it. In the worst case I'll consider switching to another library.
This seems to be valid, but I have encountered a certificate issue again:
aiohttp.client_ exceptions.ClientConnectorCertificateError: Cannot connect to host speech.platform.bing.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
@wanqifa Someone is hijacking your SSL connection, are you using this at a workplace? Edit, can you run this:
curl -4vvvv https://speech.platform.bing.com
curl -6vvvv https://speech.platform.bing.com
The first one can run
@wanqifa I mean can you share the output?
[root@localhost ~]# curl -4vvvv https://speech.platform.bing.com
- About to connect() to speech.platform.bing.com port 443 (#0)
- Trying 13.107.21.237...
- Connected to speech.platform.bing.com (13.107.21.237) port 443 (#0)
- Initializing NSS with certpath: sql:/etc/pki/nssdb
- CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
- SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- Server certificate:
-
subject: CN=www.bing.com
-
start date: Feb 16 03:47:45 2023 GMT
-
expire date: Aug 16 03:47:45 2023 GMT
-
common name: www.bing.com
-
issuer: CN=Microsoft RSA TLS CA 02,O=Microsoft Corporation,C=US
GET / HTTP/1.1 User-Agent: curl/7.29.0 Host: speech.platform.bing.com Accept: /
< HTTP/1.1 400 Bad Request < Transfer-Encoding: chunked < X-MSEdge-Ref: 0O2JaZAAAAADeWVAa6FhpQ4kUKczxXQDrU0cxRURHRTAzMjEARWRnZQ== < Date: Tue, 09 May 2023 15:09:47 GMT <
- Connection #0 to host speech.platform.bing.com left intact
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.
0O2JaZAAAAADeWVAa6FhpQ4kUKczxXQDrU0cxRURHRTAzMjEARWRnZQ==[root@localhost ~]# curl -6vvvv https://speech.platform.bing.com
- About to connect() to speech.platform.bing.com port 443 (#0)
- Trying 2620:1ec:c11::237...
- Failed to connect to 2620:1ec:c11::237: Network is unreachable
- couldn't connect to host at speech.platform.bing.com:443
- Closing connection 0 curl: (7) Failed to connect to 2620:1ec:c11::237: Network is unreachable
@wanqifa Thank you, my understanding is that the SSL error only happens sometimes; right?
Since I started using edge-tts, this function has not been successful. But I can use it on another device
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
I have tried this before, but it failed. I will try your method again
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
This is useful, thank you very much !!!!!!!!!!!!
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector
305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
I'm going to implement this but why did you disable SSL verification?
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector 305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
I'm going to implement this but why did you disable SSL verification?
Perhaps the SSL certificate validation error was caused by invalid certificates in certain systems or Python versions. I have found similar issues in the issues section of aiohttp before.
I use vim /opt/python3/lib/python3.9/site-packages/edge_tts/communicate.py
26 from aiohttp import TCPConnector 305 async with aiohttp.ClientSession( 306 trust_env=True,connector=TCPConnector(ssl=False) 307 )
I'm going to implement this but why did you disable SSL verification?
Perhaps the SSL certificate validation error was caused by invalid certificates in certain systems or Python versions. I have found similar issues in the issues section of aiohttp before.
Should be resolved by https://github.com/rany2/edge-tts/commit/8f8a3342038a283917c39af11435adb729f4ce42