mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
fix(tts): patch 还要写 communicate.WSS_URL
edge-tts 7.2.8 仍指 legacy bing 接口,10 月起微软 403。 上游 PR #491 已切到 msedgeservices.com,7.2.9 才进 PyPI,先顶住。 上次只改 constants.WSS_URL 不够,communicate 用 from import 是模块局部名, LEGB 找不到新值。这次同时改 communicate.WSS_URL 才生效。
This commit is contained in:
parent
11d7ada979
commit
6e25c50dc6
1 changed files with 11 additions and 5 deletions
|
|
@ -1,17 +1,23 @@
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import edge_tts
|
import edge_tts
|
||||||
|
import edge_tts.communicate # 显式 import,下方要给本模块的 WSS_URL 重新赋值
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from core.providers.tts.base import TTSProviderBase
|
from core.providers.tts.base import TTSProviderBase
|
||||||
|
|
||||||
# 微软 2026-10 起对 legacy 消费者接口返回 403,
|
# 微软 2026-10 起对 legacy 消费者接口返回 403,edge-tts 7.2.8 仍走
|
||||||
# edge-tts 7.2.8 仍走 speech.platform.bing.com 走不通。
|
# speech.platform.bing.com 走不通。上游 PR rany2/edge-tts#491 切到
|
||||||
# 上游 PR rany2/edge-tts#491 切到 api.msedgeservices.com 修好,
|
# api.msedgeservices.com 修好,但 7.2.8 仍是 PyPI 最新版本,临时把 WSS_URL 顶住。
|
||||||
# 但 7.2.8 仍是 PyPI 最新版本,临时把 WSS_URL 顶住。
|
# TODO(7.2.9): 升 edge-tts ≥ 7.2.9 后删掉这段 monkey patch。
|
||||||
edge_tts.constants.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 时把
|
||||||
|
# WSS_URL 复制成本模块局部名,只改 edge_tts.constants.WSS_URL 不会生效。
|
||||||
|
# __stream() 走 LEGB 找的是 edge_tts.communicate.WSS_URL,所以这里两个都要改。
|
||||||
|
edge_tts.constants.WSS_URL = _NEW_WSS_URL
|
||||||
|
edge_tts.communicate.WSS_URL = _NEW_WSS_URL
|
||||||
|
|
||||||
|
|
||||||
class TTSProvider(TTSProviderBase):
|
class TTSProvider(TTSProviderBase):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue