Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 error is back/need to implement Sec-MS-GEC token #290

Closed
xyxy opened this issue Oct 25, 2024 · 177 comments · Fixed by #303
Closed

403 error is back/need to implement Sec-MS-GEC token #290

xyxy opened this issue Oct 25, 2024 · 177 comments · Fixed by #303

Comments

@xyxy
Copy link

xyxy commented Oct 25, 2024

Traceback (most recent call last):
File "/usr/local/bin/edge-tts", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/edge_tts/util.py", line 139, in main
loop.run_until_complete(amain())
File "/usr/local/Cellar/[email protected]/3.8.18_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/site-packages/edge_tts/util.py", line 132, in amain
await _run_tts(args)
File "/usr/local/lib/python3.8/site-packages/edge_tts/util.py", line 66, in _run_tts
async for chunk in tts.stream():
File "/usr/local/lib/python3.8/site-packages/edge_tts/communicate.py", line 316, in stream
async with aiohttp.ClientSession(
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1167, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 821, in _ws_connect
raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url=URL('wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&ConnectionId=4b190acbbb4548049ac8faa8772ce020')

@rany2
Copy link
Owner

rany2 commented Oct 25, 2024

Are you using 6.1.15?

@xyxy
Copy link
Author

xyxy commented Oct 25, 2024

@rany2

Are you using 6.1.15?

pip show edge-tts [17:54:01]
Name: edge-tts
Version: 6.1.9
Summary: Microsoft Edge's TTS
Home-page: https://github.com/rany2/edge-tts
Author: rany
Author-email: [email protected]
License:
Location: /usr/local/lib/python3.8/site-packages
Requires: aiohttp, certifi
Required-by:

@utmux
Copy link

utmux commented Oct 25, 2024

升级即可:
pip install --upgrade edge-tts

@xyxy
Copy link
Author

xyxy commented Oct 25, 2024

pip install --upgrade edge-tts

解决了,谢谢您!

@xyxy xyxy closed this as completed Oct 25, 2024
@yixian3500
Copy link

今天发现有同样的问题报错
aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url=URL('wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&ConnectionId=0bd1f374edc249d8ac960f2d6f264779

然后升级了
edge-tts 6.1.15

现在还是同样的报错哎

@rany2
Copy link
Owner

rany2 commented Oct 29, 2024

@yixian3500 unfortunately these blocks are only mainland China, I don't have access to a proxy that's in mainland china so I can't assist a lot.

I ask, can you try to change the user agent to see if the blocks are still user agent based? It's interesting because if it really is user agent based, then this means they're also blocking users that use the latest Edge browser.

@rany2
Copy link
Owner

rany2 commented Oct 29, 2024

That is, unless there is another criteria they're using to prevent blocks on legitimate Edge Browser. If they actually are then it needs to be examined what the criteria is.

@rany2 rany2 reopened this Oct 29, 2024
@rany2 rany2 changed the title 今天运行命令一直报错是怎么回事? 403 error might be back for 6.1.15 (not a lot of reports) Oct 29, 2024
@rany2 rany2 mentioned this issue Oct 29, 2024
@yixian3500
Copy link

I'm sorry how to change the user agent?
it works on my little linux machine.
anyway I'll ask AI to find out.

@rany2
Copy link
Owner

rany2 commented Oct 29, 2024

It's in constants.py :)

@HuntZhaozq
Copy link

what user agent need to change? It doesn't work.

@PrivateMyLife
Copy link

I used a proxy, but the problem still persists

@PrivateMyLife
Copy link

When I turn on the proxy and change the IP, it can work normally

@pengpengtao
Copy link

当我打开代理并更改 IP 时,它可以正常工作

Could you please share?

@BG5T
Copy link
Contributor

BG5T commented Oct 30, 2024

@rany2 The reading feature in the EDGE browser works, but edge-tts does not, returning a 403 status. It is already the latest version.

@nosaywanan
Copy link

当我打开代理并更改 IP 时,它可以正常工作

Could you please share?

open ur proxy ,change ur code for tts ,communicate = edge_tts.Communicate(content,proxy="http://127.0.0.1:port")

@nosaywanan
Copy link

当我打开代理并更改 IP 时,它可以正常工作

Could you please share?

open ur proxy ,change ur code for tts ,communicate = edge_tts.Communicate(content,proxy="http://127.0.0.1:port")

even through i can solved this problem by using proxy, but i hope find a way to using tts without proxy

@PrivateMyLife
Copy link

当我打开代理并更改 IP 时,它可以正常工作

Could you please share?

用了翻墙软件。。。

@PrivateMyLife
Copy link

even through i can solved this problem by using proxy, but i hope find a way to using tts without proxy

I hope too

@MRchenao
Copy link

I hope too too,how to dealwith this probrem

@pengpengtao
Copy link

当我打开代理并更改 IP 时,它可以正常工作

您能分享一下吗?

用了翻墙软件。。。

However, it seems to be unstable, sometimes working normally and sometimes resulting in a 403 error.

@MRchenao
Copy link

MRchenao commented Oct 30, 2024 via email

@wlhpange
Copy link

Same question! Has collapsed..

@einsqing
Copy link

Same issue

@mufenzhimi
Copy link

same issue

@uvtong
Copy link

uvtong commented Oct 30, 2024

Same issue

@luomo-pro
Copy link

@rany2
Hello, I've found that this issue only exists in mainland China.
Additionally, Edge browser works fine.
After analyzing network traffic, I discovered that Edge browser's requests include two additional parameters: "Sec-MS-GEC" and "Sec-MS-GEC-Version". For example:
wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&Sec-MS-GEC=C14242292B2241ECB17DD93BD17E481FADED759D70DCE83CA526064D9E90420C&Sec-MS-GEC-Version=1-114.0.1823.67
The key parameter here is "Sec-MS-GEC", which is different each time and has a very short validity period - it expires after a short while.
If we can figure out how "Sec-MS-GEC" is generated, we'll be able to successfully make the calls!

@lincyang
Copy link

Nice job bro!

@zhongtanru
Copy link

Good people should be rewarded.

@zhongtanru
Copy link

It can' t work in China again.

@zhongtanru
Copy link

03,message='Invalid
response status
url='wss://speech,platform,bing.com/consumer/speech/synth
esize/readaloud/edge/1?TrustedclientToken=6A5AA1D4EAFF
4E9FB37E23068491D6F48SeC-MS-GEC=951A6D4FD7C99AF5E
C48E4FB4E35AFF9925812CEA2729B447D9A772AF4CEBC51&Se
c-MS-GEC-Version=1-132.0,2917.0&connectionld=2b4cfdf476
c54a39aa5d765fbbc4c965'

@wkjl34
Copy link

wkjl34 commented Nov 11, 2024

03,message='Invalid response status url='wss://speech,platform,bing.com/consumer/speech/synth esize/readaloud/edge/1?TrustedclientToken=6A5AA1D4EAFF 4E9FB37E23068491D6F48SeC-MS-GEC=951A6D4FD7C99AF5E C48E4FB4E35AFF9925812CEA2729B447D9A772AF4CEBC51&Se c-MS-GEC-Version=1-132.0,2917.0&connectionld=2b4cfdf476 c54a39aa5d765fbbc4c965'

我刚刚试了,我的好像还可以用

@HTYpig
Copy link

HTYpig commented Nov 11, 2024

aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status', url='wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4&Sec-MS-GEC=951A6D4FD7C99AF5EC48E4FB4E35AFF9925812CEA2729B447D9A772AF4CEBC51&Sec-MS-GEC-Version=1-132.0.2917.0&ConnectionId=b7ebe8510d3348f59828a7abde6d9e81'
我的也是无法使用呢,已更新版本到6.1.17了python版本为3.11

@zhongtanru
Copy link

zhongtanru commented Nov 11, 2024 via email

@1212145
Copy link

1212145 commented Nov 11, 2024

If it is only unavailable on the Chinese server, can it be used directly through the intermediate proxy of the Japanese mirror or the reverse proxy through the clash of the Chinese server?

@CHN-STUDENT
Copy link

I have gotten Error generating speech: 403, message='Invalid response status', seems it banned our chinese ip?

@rany2
Copy link
Owner

rany2 commented Nov 11, 2024

I can't reproduce on 6.1.17. Do you have an accurate clock?

@rany2
Copy link
Owner

rany2 commented Nov 11, 2024

If people don't have an accurate clock, I should be able to adjust it on retry by checking the Date header.

@rany2
Copy link
Owner

rany2 commented Nov 11, 2024

Should be fixed by #309

@rany2
Copy link
Owner

rany2 commented Nov 11, 2024

edge-tts version 6.1.18 was released with this fix for clock skew.

@HTYpig
Copy link

HTYpig commented Nov 12, 2024

非常感谢,已经成功生成了

@CHN-STUDENT
Copy link

Sorry, i update the lastest version, now it work!

@zhongtanru

This comment was marked as off-topic.

@zhongtanru
Copy link

it can't work after updating v6.1.19

@rany2
Copy link
Owner

rany2 commented Nov 22, 2024

@zhongtanru I think it's an issue with your packaging, you might be bundling an outdated edge-tts version somehow.

@rany2 rany2 unpinned this issue Nov 22, 2024
@zhongtanru

This comment was marked as off-topic.

@zhongtanru

This comment was marked as off-topic.

@zhongtanru

This comment was marked as off-topic.

@zhongtanru
Copy link

zhongtanru commented Nov 24, 2024 via email

@rany2
Copy link
Owner

rany2 commented Nov 24, 2024

Report it to pyinstaller maybe, you've already mentioned that the non-packaged variant doesn't have any issues.

@zhongtanru
Copy link

zhongtanru commented Nov 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.