0 votes

So, I am wanting to use Godot to get a (binary) file using HTTP and then either save it or, even better, turn it into a Resource in memory that I can use. It'll be WAV files that I'm getting in return (trying to implement MaryTTS, which is running as a server on localhost). I had a look at the docs for HTTPRequest, but can't seem to get a working solution.

I do $HTTPRequest.request("http://...") when a particular keypress is made, and I have the _on_HTTPRequest_request_completed() function, but this never seems to be called. I tried with the function in the same Node as the request (as per the docs' example), and I also tried putting it as part of a script for the HTTPRequest Node. If I hit the triggering key fast enough, it gives an error ("HTTPRequest is processing a request"), but if I do it slower, it doesn't give that error, so it appears it is finishing. It just doesn't do anything when it finishes. HTTPRequest gives a return value of 0, which I assume means no error? (Or should this give me HTTP status codes?)

Any idea what I'm doing wrong? Can HTTPRequest handle binary files? How do I get this working? Should I be using HTTPClient instead?

(Any suggestions on a better way to implement MaryTTS are also welcome).


Edit: have made some progress using HTTPClient. My code now looks like the below, where I can get a response (and even manage it in its own thread, so there's no freezing of the main game), but the audio player doesn't play anything.

Code is here: https://www.dropbox.com/s/ey71w3g09raf4bw/httpTest.gd?dl=0

asked Sep 15 in Engine by BevanFindlay (19 points)

1 Answer

0 votes
Best answer

Eventually got this working, once I learned how the data for the audio player needed to be structured. It's still a little slower than I'd like, though I don't know if that's Godot's end or just how long it takes MaryTTS to process (will be test this some more), but it works!

Full code is here: https://pastebin.com/P1GYkvAX

answered Sep 28 by BevanFindlay (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.