mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
fix(westernization): translate edge-tts monkey-patch comments from upstream sync
This commit is contained in:
parent
a80ff5084b
commit
df6fc3ae76
1 changed files with 10 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import edge_tts
|
import edge_tts
|
||||||
import edge_tts.communicate # 显式 import,下方要给本模块的 WSS_URL 重新赋值
|
import edge_tts.communicate # explicit import; WSS_URL is reassigned on this module below
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from core.providers.tts.base import TTSProviderBase
|
from core.providers.tts.base import TTSProviderBase
|
||||||
from config.logger import setup_logging
|
from config.logger import setup_logging
|
||||||
|
|
@ -9,17 +9,19 @@ from config.logger import setup_logging
|
||||||
TAG = __name__
|
TAG = __name__
|
||||||
logger = setup_logging()
|
logger = setup_logging()
|
||||||
|
|
||||||
# 微软 2026-10 起对 legacy 消费者接口返回 403,edge-tts 7.2.8 仍走
|
# Since 2026-10 Microsoft returns 403 for the legacy consumer endpoint, and
|
||||||
# speech.platform.bing.com 走不通。上游 PR rany2/edge-tts#491 切到
|
# edge-tts 7.2.8 still talks to speech.platform.bing.com, which no longer works.
|
||||||
# api.msedgeservices.com 修好,但 7.2.8 仍是 PyPI 最新版本,临时把 WSS_URL 顶住。
|
# Upstream PR rany2/edge-tts#491 fixes it by switching to api.msedgeservices.com,
|
||||||
# TODO(7.2.9): 升 edge-tts ≥ 7.2.9 后删掉这段 monkey patch。
|
# but 7.2.8 is still the newest release on PyPI, so temporarily override WSS_URL.
|
||||||
|
# TODO(7.2.9): remove this monkey patch once edge-tts >= 7.2.9 is available.
|
||||||
_NEW_WSS_URL = (
|
_NEW_WSS_URL = (
|
||||||
"wss://api.msedgeservices.com/tts/cognitiveservices/websocket/v1"
|
"wss://api.msedgeservices.com/tts/cognitiveservices/websocket/v1"
|
||||||
f"?Ocp-Apim-Subscription-Key={edge_tts.constants.TRUSTED_CLIENT_TOKEN}"
|
f"?Ocp-Apim-Subscription-Key={edge_tts.constants.TRUSTED_CLIENT_TOKEN}"
|
||||||
)
|
)
|
||||||
# communicate.py 第 35 行 `from .constants import WSS_URL` 会在 import 时把
|
# Line 35 of communicate.py, `from .constants import WSS_URL`, copies WSS_URL
|
||||||
# WSS_URL 复制成本模块局部名,只改 edge_tts.constants.WSS_URL 不会生效。
|
# into a module-local name at import time, so patching only
|
||||||
# __stream() 走 LEGB 找的是 edge_tts.communicate.WSS_URL,所以这里两个都要改。
|
# edge_tts.constants.WSS_URL has no effect. __stream() resolves WSS_URL via LEGB
|
||||||
|
# to edge_tts.communicate.WSS_URL, so both names must be patched here.
|
||||||
edge_tts.constants.WSS_URL = _NEW_WSS_URL
|
edge_tts.constants.WSS_URL = _NEW_WSS_URL
|
||||||
edge_tts.communicate.WSS_URL = _NEW_WSS_URL
|
edge_tts.communicate.WSS_URL = _NEW_WSS_URL
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue