OpenAI TTS - help with playing returned MP3

Hey All,

I’m trying to get OpenAI’s TTS to work in my app. I’ve managed to generate MP3’s with this using python and I can load them into my app and play them just fine but playing them in app… I’m not even sure it’s possible.

I’m making a successful API call (so the Auth and Content-Type and end point are all OK):

I’m getting a response from the end point but it’s just 4x diamonds with ?'s in each one. I assume this is because it’s trying to send an MP3 back. If I just try to ‘play’ block the response, I get nothing.

I tried a couple of other things:

  1. Treating it a base 64 encoded and playing it my appending the base64 string - no dice

  2. immediately uploading the response to cloudinary and playing from there… also no good.

any ideas?

PS - here’s the API docs:

I’m not sure if this will work for what you’re trying to do but this worked for me with the Google Cloud API:

1 Like

So that was the arrangement I first went with for the base 64 decoding. That didn’t work here as it doesn’t seem like OpenAI is returning a JSON file - I’ve tried just printing what comes back to inspect it but it either comes out as null / the four diamonds.

What are the other two blocks though? At first I thought the green one was relating to a webviewer or video control but I don’t see “set X’s source…” block relating to either. I also don’t see it in the logic box (which is green). Is it an advance version of some other block?

Ditto the particular play arrangement you have there too. I don’t see an advanced vs of play which would let do that either.

Ohh you’re in Snap-to-place. OK, I just built a test app in StP and did exactly what you showed here which didn’t work :frowning:

Since the OpenAI TTS API is returning just an mp3, I also tried just playing the ‘response’ from the API call too. Again, no dice :frowning:

Sorry for any confusion there.

I actually had to go back and find the topic where we discussed a solution to this: Play mp3 sound from API response

I was able to finally get it to work… I don’t remember all of the details but they should be in that topic.

1 Like

Ahh thanks man, I appreciate that!

Hmm looks like I might have to start from scratch (open an StP then convert to DnD and then rebuild…ugh Thunkable - this is the stuff that breaks my heart about this program).

Hello @nathanburley21656
A solution could be to use a backend service such as Xano or Firebase.
I mean to use a third-party API to call OpenAI API, and then store the files from the response on your backend and return it as a URL on Thunkable.