kxxt / aspeak

A simple text-to-speech client for Azure TTS API.
MIT License
494 stars 57 forks source link

WebSocket upgrade failed: Unspecified connection error (200). USP state: 2. Received audio size: 0 bytes. #33

Closed ganjunhong closed 1 year ago

ganjunhong commented 1 year ago

The result returned each time is ResultReason.Canceled

ganjunhong commented 1 year ago

more detail msg: WebSocket upgrade failed: Unspecified connection error (200). USP state: 2. Received audio size: 0 bytes.

kxxt commented 1 year ago

It seems that Microsoft has deliberately done some changes to prevent 3rd party tools(such as aspeak) using their trial service.

kxxt commented 1 year ago

image

I guess these two cookies are the main reason that prevents aspeak from functioning, but I will double check it later.

If this is the case. The fix won't be easy because we need to reimplement most of azure-cognitiveservices-speech and remove it from requirements.txt.

kxxt commented 1 year ago

I decided to end this mouse & cat game and thus drop support for the trial service. I do not have enough time to fight against Microsoft. I'm just an undergraduate with tons of course works to do and lots of deadlines to catch. (And I have another PR to work on: jobisoft/CategoryManager#86)

However, I'm willing to accept PRs that re-enable the token-free trial service.

You need an azure subscription to continue to use the next major version of aspeak.

A free azure subscription(credit card needed) provides you 5 audio hours free per month, which is enough for daily usage. You can also choose a nearby region to lower latency, which is not possible in the trial service.

Unfortunately, azure didn't accept my prepaid card, which means I do not have a subscription for testing purpose.

ganjunhong commented 1 year ago

Although have some regrets, I still appreciate what you have done before. I'm also trying to use Python selenium to solve this problem temporarily. Good luck.

Funktionar commented 1 year ago

Can anyone else fix up the code?

kxxt commented 1 year ago

Can anyone else fix up the code?

This won't be an easy fix.

I have already fixed the voice listing function(aspeak -L): https://github.com/kxxt/aspeak/commit/127a7a42a2785796e68102cf3e0cb3ed71de25ab

To fix other things, you need to attach header Origin: https://azure.microsoft.com to the websocket connection. But that is controlled by Microsoft propriety native code.

ujmyvq1582 commented 1 year ago

https://azure.microsoft.com/zh-cn/products/cognitive-services/speech-translation/ This address can obtain the token as before

kxxt commented 1 year ago

Fixed in v3.1.0.