mirror of
https://github.com/rany2/edge-tts
synced 2024-11-21 17:29:07 +00:00
Fix "unable to get local issuer certificate" when trust store is not available from OS
Closes #129 Signed-off-by: rany2 <rany2@riseup.net>
This commit is contained in:
parent
453a096c54
commit
8f8a334203
1
setup.py
1
setup.py
@ -5,5 +5,6 @@ setup(
|
|||||||
name="edge-tts",
|
name="edge-tts",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"aiohttp>=3.8.0",
|
"aiohttp>=3.8.0",
|
||||||
|
"certifi==2023.07.22",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -5,6 +5,7 @@ Communicate package.
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import ssl
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from contextlib import nullcontext
|
from contextlib import nullcontext
|
||||||
@ -23,6 +24,7 @@ from typing import (
|
|||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import certifi
|
||||||
|
|
||||||
from edge_tts.exceptions import (
|
from edge_tts.exceptions import (
|
||||||
NoAudioReceived,
|
NoAudioReceived,
|
||||||
@ -302,9 +304,10 @@ class Communicate:
|
|||||||
prev_idx = -1
|
prev_idx = -1
|
||||||
shift_time = -1
|
shift_time = -1
|
||||||
|
|
||||||
|
ssl_ctx = ssl.create_default_context(cafile=certifi.where())
|
||||||
for idx, text in enumerate(texts):
|
for idx, text in enumerate(texts):
|
||||||
async with aiohttp.ClientSession(
|
async with aiohttp.ClientSession(
|
||||||
trust_env=True
|
trust_env=True,
|
||||||
) as session, session.ws_connect(
|
) as session, session.ws_connect(
|
||||||
f"{WSS_URL}&ConnectionId={connect_id()}",
|
f"{WSS_URL}&ConnectionId={connect_id()}",
|
||||||
compress=15,
|
compress=15,
|
||||||
@ -320,6 +323,7 @@ class Communicate:
|
|||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
" (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.41",
|
" (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.41",
|
||||||
},
|
},
|
||||||
|
ssl=ssl_ctx,
|
||||||
) as websocket:
|
) as websocket:
|
||||||
# download indicates whether we should be expecting audio data,
|
# download indicates whether we should be expecting audio data,
|
||||||
# this is so what we avoid getting binary data from the websocket
|
# this is so what we avoid getting binary data from the websocket
|
||||||
|
@ -3,9 +3,11 @@ list_voices package for edge_tts.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import ssl
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import certifi
|
||||||
|
|
||||||
from .constants import VOICE_LIST
|
from .constants import VOICE_LIST
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ async def list_voices(*, proxy: Optional[str] = None) -> Any:
|
|||||||
Returns:
|
Returns:
|
||||||
dict: A dictionary of voice attributes.
|
dict: A dictionary of voice attributes.
|
||||||
"""
|
"""
|
||||||
|
ssl_ctx = ssl.create_default_context(cafile=certifi.where())
|
||||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||||
async with session.get(
|
async with session.get(
|
||||||
VOICE_LIST,
|
VOICE_LIST,
|
||||||
@ -37,6 +40,7 @@ async def list_voices(*, proxy: Optional[str] = None) -> Any:
|
|||||||
"Accept-Language": "en-US,en;q=0.9",
|
"Accept-Language": "en-US,en;q=0.9",
|
||||||
},
|
},
|
||||||
proxy=proxy,
|
proxy=proxy,
|
||||||
|
ssl=ssl_ctx,
|
||||||
) as url:
|
) as url:
|
||||||
data = json.loads(await url.text())
|
data = json.loads(await url.text())
|
||||||
return data
|
return data
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Edge TTS version information."""
|
"""Edge TTS version information."""
|
||||||
|
|
||||||
__version__ = "6.1.7"
|
__version__ = "6.1.8"
|
||||||
__version_info__ = tuple(int(num) for num in __version__.split("."))
|
__version_info__ = tuple(int(num) for num in __version__.split("."))
|
||||||
|
Loading…
Reference in New Issue
Block a user