File tree Expand file tree Collapse file tree 4 files changed +28
-65
lines changed
Expand file tree Collapse file tree 4 files changed +28
-65
lines changed Original file line number Diff line number Diff line change @@ -433,9 +433,9 @@ async def send_ssml_request() -> None:
433433 trust_env = True ,
434434 timeout = self .session_timeout ,
435435 ) as session , session .ws_connect (
436- f"{ WSS_URL } &Sec-MS-GEC= { DRM . generate_sec_ms_gec ()} "
437- f"&Sec-MS-GEC-Version= { SEC_MS_GEC_VERSION } "
438- f"&ConnectionId= { connect_id () } " ,
436+ f"{ WSS_URL } &ConnectionId= { connect_id ()} "
437+ f"&Sec-MS-GEC= { DRM . generate_sec_ms_gec () } "
438+ f"&Sec-MS-GEC-Version= { SEC_MS_GEC_VERSION } " ,
439439 compress = 15 ,
440440 proxy = self .proxy ,
441441 headers = WSS_HEADERS ,
Original file line number Diff line number Diff line change 11"""Constants for the edge_tts package."""
22
3- BASE_URL = "speech.platform.bing. com/consumer/speech/synthesize/readaloud "
3+ BASE_URL = "api.msedgeservices. com/tts/cognitiveservices "
44TRUSTED_CLIENT_TOKEN = "6A5AA1D4EAFF4E9FB37E23D68491D6F4"
55
6- WSS_URL = f"wss://{ BASE_URL } /edge/v1?TrustedClientToken={ TRUSTED_CLIENT_TOKEN } "
7- VOICE_LIST = f"https://{ BASE_URL } /voices/list?trustedclienttoken={ TRUSTED_CLIENT_TOKEN } "
6+ WSS_URL = (
7+ f"wss://{ BASE_URL } /websocket/v1?Ocp-Apim-Subscription-Key={ TRUSTED_CLIENT_TOKEN } "
8+ )
9+ VOICE_LIST = (
10+ f"https://{ BASE_URL } /voices/list?Ocp-Apim-Subscription-Key={ TRUSTED_CLIENT_TOKEN } "
11+ )
812
913DEFAULT_VOICE = "en-US-EmmaMultilingualNeural"
1014
2226 "Pragma" : "no-cache" ,
2327 "Cache-Control" : "no-cache" ,
2428 "Origin" : "chrome-extension://jdiccldimpdaibmpdkjnbmckianbfold" ,
29+ "Sec-WebSocket-Protocol" : "synthesize" ,
30+ "Sec-WebSocket-Version" : "13" ,
2531}
2632WSS_HEADERS .update (BASE_HEADERS )
2733VOICE_HEADERS = {
Original file line number Diff line number Diff line change @@ -20,64 +20,24 @@ class TTSChunk(TypedDict):
2020class VoiceTag (TypedDict ):
2121 """VoiceTag data."""
2222
23- ContentCategories : List [
24- Literal [
25- "Cartoon" ,
26- "Conversation" ,
27- "Copilot" ,
28- "Dialect" ,
29- "General" ,
30- "News" ,
31- "Novel" ,
32- "Sports" ,
33- ]
34- ]
35- VoicePersonalities : List [
36- Literal [
37- "Approachable" ,
38- "Authentic" ,
39- "Authority" ,
40- "Bright" ,
41- "Caring" ,
42- "Casual" ,
43- "Cheerful" ,
44- "Clear" ,
45- "Comfort" ,
46- "Confident" ,
47- "Considerate" ,
48- "Conversational" ,
49- "Cute" ,
50- "Expressive" ,
51- "Friendly" ,
52- "Honest" ,
53- "Humorous" ,
54- "Lively" ,
55- "Passion" ,
56- "Pleasant" ,
57- "Positive" ,
58- "Professional" ,
59- "Rational" ,
60- "Reliable" ,
61- "Sincere" ,
62- "Sunshine" ,
63- "Warm" ,
64- ]
65- ]
23+ ContentCategories : List [str ]
24+ VoicePersonalities : List [str ]
6625
6726
6827class Voice (TypedDict ):
6928 """Voice data."""
7029
7130 Name : str
7231 ShortName : str
73- Gender : Literal ["Female" , "Male" ]
32+ DisplayName : str
33+ LocalName : str
34+ LocaleName : str
7435 Locale : str
75- SuggestedCodec : Literal ["audio-24khz-48kbitrate-mono-mp3 " ]
76- FriendlyName : str
77- Status : Literal ["GA " ]
36+ Gender : Literal ["Female" , "Male " ]
37+ WordsPerMinute : str
38+ Status : Literal ["Deprecated" , "GA" , "Preview " ]
7839 VoiceTag : VoiceTag
7940
80-
8141class VoicesManagerVoice (Voice ):
8242 """Voice data for VoicesManager."""
8343
Original file line number Diff line number Diff line change @@ -41,17 +41,14 @@ async def __list_voices(
4141 data : List [Voice ] = json .loads (await url .text ())
4242
4343 for voice in data :
44- # Remove leading and trailing whitespace from categories and personalities.
45- # This has only happened in one case with the zh-CN-YunjianNeural voice
46- # where there was a leading space in one of the categories.
47- voice ["VoiceTag" ]["ContentCategories" ] = [
48- category .strip () # type: ignore
49- for category in voice ["VoiceTag" ]["ContentCategories" ]
50- ]
51- voice ["VoiceTag" ]["VoicePersonalities" ] = [
52- personality .strip () # type: ignore
53- for personality in voice ["VoiceTag" ]["VoicePersonalities" ]
54- ]
44+ if "VoiceTag" not in voice :
45+ voice ["VoiceTag" ] = {}
46+
47+ if "ContentCategories" not in voice ["VoiceTag" ]:
48+ voice ["VoiceTag" ]["ContentCategories" ] = []
49+
50+ if "VoicePersonalities" not in voice ["VoiceTag" ]:
51+ voice ["VoiceTag" ]["VoicePersonalities" ] = []
5552
5653 return data
5754
You can’t perform that action at this time.
0 commit comments