#8391 Network connection failed:{'text': 'Hello, my dear friend, I hope every day of yours is wonderful and joyful!', 'rate':

2409**d914 Posted at: 1 hour ago

Network connection failed:
{'text': 'Hello, my dear friend, I hope every day of yours is wonderful and joyful!', 'rate': '+0%', 'role': 'Roger(Male/US)', 'filename': 'C:\Users\15533\AppData\Local\Temp/pyvideotrans/0-1792739086.950569.wav', 'tts_type': 0, 'language': 'en', 'volume': '+0%', 'pitch': '+0Hz'}
Traceback (most recent call last):
File "edge_tts\communicate.py", line 566, in stream
File "edge_tts\communicate.py", line 431, in __stream
File "aiohttp\client.py", line 1482, in aenter
File "aiohttp\client.py", line 1078, in _ws_connect
aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url='wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&ConnectionId=05edfdc6d90e4a9b8c156a2042a3d340&Sec-MS-GEC=0130ED9AB40E2150A8D82C21BCE9A39A734B9AB0A367EC9252ECA05F12F96879&Sec-MS-GEC-Version=1-143.0.3650.75'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "videotrans\util\ListenVoice.py", line 21, in run
File "videotrans\tts\__init__.py", line 119, in run
File "videotrans\tts\_base.py", line 93, in run
File "asyncio\runners.py", line 44, in run
File "asyncio\base_events.py", line 649, in run_until_complete
File "videotrans\tts\_edgetts.py", line 154, in _exec
File "edge_tts\communicate.py", line 590, in save
File "edge_tts\communicate.py", line 573, in stream
File "edge_tts\communicate.py", line 431, in __stream
File "aiohttp\client.py", line 1482, in aenter
File "aiohttp\client.py", line 1078, in _ws_connect
aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url='wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&ConnectionId=82dc6e8230b943898a15a4f3d75e4105&Sec-MS-GEC=0130ED9AB40E2150A8D82C21BCE9A39A734B9AB0A367EC9252ECA05F12F96879&Sec-MS-GEC-Version=1-143.0.3650.75'


=
system:Windows-10-10.0.22631-SP0
version:v4.14
frozen:True
language:zh_CN
root_dir:D:/Softwore/pyVideotrans/win-pyvideotrans-v4.14

1 Replies

#1 DeepSeek reply at 1 hour ago

这是 edge-tts(微软 Edge 朗读语音) 服务端返回的 403 拒绝,不是你的代码写错,也不是网络断开,而是请求被微软的 TTS 服务器"拒收"了。

关键信息

WSServerHandshakeError: 403, message='Invalid response status'
url='wss://speech.platform.bing.com/...&Sec-MS-GEC=...&Sec-MS-GEC-Version=1-143.0.3650.75'

微软的接口现在要求请求里带 Sec-MS-GEC 这个基于当前时间动态生成的校验令牌,服务器校验不通过就直接 403。

常见原因(按可能性排序)

  1. 系统时间不准(最常见)
    Sec-MS-GEC 是用当前时间算的,如果本机时间与服务器相差超过几分钟,令牌就废了。
  2. edge-tts 组件版本旧
    微软改过令牌算法,老版本 edge-tts 算出来的令牌会被判 403。
  3. 网络/地区限制
    国内直连 speech.platform.bing.com 有时会握手被拒;开了代理/加速器、或用不干净的出口 IP,也容易被拦。
  4. 该语音角色被限制
    偶发情况,换个角色/语言再试即可排除。

解决办法

① 校准系统时间(先做这个,免费且最有效)

  • Win10/11:设置 → 时间和语言 → 日期和时间 → 打开"自动设置时间/时区" → 点"立即同步"
  • 确认时区正确(中国应为 UTC+8),不要刻意改过系统时间

② 升级软件 / 更新 edge-tts 组件

  • 你现在用的是 v4.14 打包版,请到 PyVideotrans 发布页下载最新版(作者会同步更新 edge-tts 以适配微软的令牌变更)。
  • 如果是源码版,执行:

    pip install -U edge-tts

③ 配置代理

  • 软件内:菜单 → 设置 → 高级选项 → 网络代理,填入可用的 HTTP/SOCKS5 代理后重试。
  • 或者用系统级代理,确保访问 speech.platform.bing.com 和 wss://speech.platform.bing.com 走代理。

④ 换 TTS 引擎
如果 Edge TTS 一直 403,可在"配音/TTS"设置里换成:

  • Azure TTS(自己填 Key,最稳定)
  • 本地/离线 TTS(如 Piper、ChatterBox、OmniVoice 等)
  • 其他在线引擎(如 Gemini TTS、OpenAI TTS)

⑤ 换个角色试一次
比如把 Roger(Male/US) 换成 en-US-AriaNeural 之类的其他音色,如果都 403,说明是上面 1/2/3 的问题,不是个别角色。

小结

99% 的情况是 "系统时间不准" 或 "edge-tts 版本旧"。先同步时间 → 升级到最新版 PyVideotrans → 仍不行就挂代理或换 Azure/本地 TTS 引擎,即可解决。

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource