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

WebsocketError with ErrorCode 429 #56

Closed
kxxt opened this issue Mar 25, 2023 · 15 comments
Closed

WebsocketError with ErrorCode 429 #56

kxxt opened this issue Mar 25, 2023 · 15 comments

Comments

@kxxt
Copy link
Owner

kxxt commented Mar 25, 2023

The free trial API is heavily rate limited by Microsoft.

If you are constantly hitting this with an error code 429, please consider registering an Azure account and use aspeak with an azure subscription key. (There is a free tier)

Or you can try to use the edge tts endpoint which comes with fewer features(You need at least aspeak v4.2.0). You can figure out what options are needed by looking at edge-tts's code:

@kxxt kxxt changed the title WebsocketError WebsocketError with ErrorCode 429 Mar 25, 2023
@kxxt kxxt pinned this issue Mar 25, 2023
@babykidp
Copy link

babykidp commented Apr 5, 2023

Hi, I registered an Azure account and used aspeak with my subscription key. But I constantly hit some similar errors when I used my configuration file:

Error:
0: Websocket error
1: HTTP error: 429 Too Many Requests

Location:
src\main.rs:79

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Could you help me?

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

Hi, I registered an Azure account and used aspeak with my subscription key. But I constantly hit some similar errors when I used my configuration file:

Hi, @babykidp. What's the command you used and the relevant config entries(region and endpoint)?

You should use an official API endpoint instead of the default trial endpoint. For example, for eastus region, you can run aspeak -r eastus -k YOUR_KEY text "Hello World".

@babykidp
Copy link

babykidp commented Apr 5, 2023

I use the command:
aspeak --profile MY_PROFILE text "Hello"

My profile looks like this:

[auth]
endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken"
region = "eastasia"

It‘s OK when I only run aspeak -r eastasia -k MY_KEY text "Hello World".

@babykidp
Copy link

babykidp commented Apr 5, 2023

And I met another error about endpoint:

Error:
0: TOML parse error at line 19, column 12
0: |
0: 19 | endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken"
0: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0: unknown variant https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken, expected Endpoint or Region
0:

Location:
src\cli\config.rs:64

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

When my profile is set up without endpoint, I met some other error:
[auth]
region = "eastasia"

Error:
0: Websocket error
1: HTTP error: 200 OK

Location:
src\main.rs:79

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

[auth]
endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken"
region = "eastasia"

The endpoint url should be something like "wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1". You don't need to specify endpoint url if you have specified region. The endpoint url setting will be used instead of the region setting if you specified both.

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

And I met another error about endpoint:

Error: 0: TOML parse error at line 19, column 12 0: | 0: 19 | endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken" 0: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0: unknown variant https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken, expected Endpoint or Region 0:

Location: src\cli\config.rs:64

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it. Run with RUST_BACKTRACE=full to include source snippets.

This should be a bug of aspeak. I will fix it.

@babykidp
Copy link

babykidp commented Apr 5, 2023

[auth]
endpoint = "https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken"
region = "eastasia"

The endpoint url should be something like "wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1". You don't need to specify endpoint url if you have specified region. The endpoint url setting will be used instead of the region setting if you specified both.

My Azure Keys and Endpoint page shows the endpoint as: https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken. That's different from the default endpoint.

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

My Azure Keys and Endpoint page shows the endpoint as: https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken. That's different from the default endpoint.

The endpoint url in aspeak config is not the issuetoken API url. A list of TTS endpoints can be found at https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech?tabs=streaming#prebuilt-neural-voices . And you need to change https:// to wss:// as aspeak is using the websocket API.

There is a bug that caused the endpoint/region settings in profile ineffective. I will fix it soon.

@babykidp
Copy link

babykidp commented Apr 5, 2023

I see, thank you!

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

@babykidp The region setting should now be effective with aspeak v4.3.1. Thanks for your error report.

@babykidp
Copy link

babykidp commented Apr 5, 2023

You're welcome. The new version works well now.

@babykidp
Copy link

babykidp commented Apr 5, 2023

My Azure Keys and Endpoint page shows the endpoint as: https://eastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken. That's different from the default endpoint.

The endpoint url in aspeak config is not the issuetoken API url. A list of TTS endpoints can be found at https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech?tabs=streaming#prebuilt-neural-voices . And you need to change https:// to wss:// as aspeak is using the websocket API.

There is a bug that caused the endpoint/region settings in profile ineffective. I will fix it soon.

I found some new error. No matter whether I set the region or not, once I set the endpoint as your guide, a new error occurs. The new version works well when I only specify region.

[auth]
endpoint = "wss://eastasia.tts.speech.microsoft.com/cognitiveservices/v1"
region = "eastasia"

Error:
0: Websocket error
1: HTTP error: 404 Not Found

Location:
src\main.rs:79

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

@kxxt
Copy link
Owner Author

kxxt commented Apr 5, 2023

I found some new error. No matter whether I set the region or not, once I set the endpoint as your guide, a new error occurs. The new version works well when I only specify region.

[auth] endpoint = "wss://eastasia.tts.speech.microsoft.com/cognitiveservices/v1" region = "eastasia"

Ah, it should be wss://eastasia.tts.speech.microsoft.com/cognitiveservices/websocket/v1. There is a subtle difference between the REST API endpoint and the websocket API endpoint.

@babykidp
Copy link

babykidp commented Apr 5, 2023

Thank you for your help. I missed "websocket".

@kxxt
Copy link
Owner Author

kxxt commented Apr 21, 2023

The trial endpoint has been removed in v5.0.

@kxxt kxxt closed this as completed Apr 21, 2023
@kxxt kxxt mentioned this issue May 10, 2023
@kxxt kxxt unpinned this issue Jun 7, 2023
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

No branches or pull requests

2 participants