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

When using non-English characters in the text parameter, encode does not occur #11

Closed
MrPandir opened this issue Feb 21, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@MrPandir
Copy link
Member

curl -v 'localhost:8000/generate?speaker=aidar&text=тест'
> GET /generate?speaker=aidar&text=тест HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.4.0
> Accept: */*
> 
< HTTP/1.1 400 Bad Request
< content-type: text/plain; charset=utf-8
< Connection: close
Invalid HTTP request received.

It works:

curl -v 'http://localhost:8000/generate?speaker=aidar&text=%D1%82%D0%B5%D1%81%D1%82' --output test.wav
> GET /generate?speaker=aidar&text=%D1%82%D0%B5%D1%81%D1%82 HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.4.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< date: Wed, 21 Feb 2024 17:47:56 GMT
< server: uvicorn
< content-type: audio/wav
< content-length: 43244

I'm not sure if this should be fixed at all 🤔
And is it possible to do this in uvicorn?

@MrPandir MrPandir added the bug Something isn't working label Feb 21, 2024
@MrPandir MrPandir self-assigned this Feb 21, 2024
@crashmax-dev
Copy link
Member

@MrPandir Why not use POST request?

@MrPandir
Copy link
Member Author

One of the problems with using POST is how Swagger UI inserts audio into the interface, which I use for auto-documentation endpoints and for quick and easy manual testing.
swagger-api/swagger-ui#8378

There is also a difference between using POST and GET. GET requests can be cached by the browser, which is an advantage.

This problem seems impossible to fix using GET. Maybe I'll add support for POST request

@MrPandir
Copy link
Member Author

This is not a litestar or uvicorn problem. And the lack of decoding in the curl request. To fix this you need to make the following request:

curl -G 'http://localhost:8000/generate' --data-urlencode 'text=тест' --data-urlencode 'speaker=aidar' --output test.wav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants