Play mp3 sound from API response

I am using an API POST call and it’s returning an mp3 file. This works fine in Postman and plays the sound but not in Thunkable Live.

Can I just attach the green response block to the play block and have it play the sound? I’ve tried that and it’s not working and I’m not sure what else to try. I included the get object from JSON block and that didn’t work either.

This topic makes me think it’s probably not possible: Download mp3 and play via Sound

HUGE thanks to @ioannis for this since he figured out a fix.

The mp3 binary was tricky and I had been trying to get this to work using the base64 string that Google Cloud’s text-to-speech API returns but I hadn’t had any luck.

@ioannis used Any Component blocks to set the sound source and play the sound:

Initially, those blocks looked like they were from a StP project but they aren’t; they are from DnD. Specifically, they are these two blocks:

It would be great to also figure out how to play the mp3 file. This method doesn’t seem to work for that whether I set the sound source to the green response block or get object from JSON [response].

You are welcome @tatiang

@ioannis I’m curious if you know how to get the Sound1 component to show up in the Any Component blocks? I’m trying to set this up in a new project and when I add a “call” block or “set [component]” block as above, sound is not an option in either menu.

Why do you want to use the “any component” block?

That was how I managed to use the Play and Stop blocks that work for base64 sounds. See my screenshot above for the Call and Set blocks I used. They have to be those because the normal Play and Stop blocks don’t work with base64.

And I was able to get those from the Any Component drawer before (which is how I assumed you created them, too) but now “Sound” isn’t an option in the menu for those blocks and I’m not sure how to add it.

@ioannis Okay, I think the Set sound1’s source block was found by using a Set button’s Text block and changing the component to Sound1. I still don’t know how to add Sound1 as a component in a drag and drop project, though.

And then the Call block from Any Component just happened to have Sound as an option. I can’t seem to recreate this any more…

@tatiang Actually the way I did this was by first creating the project into Stap to Place and then transforming it into Drag and Drop. :sweat_smile:

About your functionality, you don’t need to use the same blocks. You can make it also like that

The standard play block has never worked for me for playing base64 sounds. :slightly_frowning_face:

But you’re right, in a converted StP project that’s now DnD, I can add the sound blocks that work to play base64 sounds. In a standard DnD project, I can’t. That’s unfortunate.

I’m trying to re-create a project I already made but I started with a standard DnD project so I guess I need to go back and start with a converted StP project.

@tatiang If you want to add these blocks to your project, a workaround is to save the transformed page and then add it to the original project and copy-paste the blocks between the two screens

Can you say a little bit more about that? I know I can save a screen in StP but I don’t see a way to save a screen in DnD and I don’t see a way to load a saved screen in DnD.

Is that in DnD? This is what I see in DnD:

I don’t see an item for saved screens anywhere in my DND either.

1 Like

I understand your frustration. At the moment, the option to save screens anywhere in DND and add them to DND projects is available to Business or Team Level Users.

This isn’t a workaround for the majority of your users though…

Is this a thing that in general Thunkable just can’t support?

If our sales and management team decide to make a change in our pricing and features structure, we will be sure to let you and all of our Thunkable community know.