0

I am in the process of making a talking robot and I have linked my ESP32 to a Google text-to-speech service. The service returns me a base64 8-bit audio response.

I need to play this audio and I can't figure out how to do it. I know that an audio playing library exist for PCM but the data that it requires is not base64.

ocrdu
1,7953 gold badges12 silver badges24 bronze badges
asked Jan 23, 2021 at 11:16
3
  • Base64 is just an encoding to encapsulate 8 bit data into ASCII text. It has nothing to do with audio. Decode it first into your binary data then use a suitable library for your hardware to play it. Commented Jan 23, 2021 at 11:41
  • On the esp, there is also an offline version of text to speech. Just if you want to try it... Commented Jan 23, 2021 at 20:26
  • I don't know weather this will help you there is a guy who makes cool stuff in GitHub text to speech in esp8266 hope it will work in esp32 too github.com/earlephilhower/ESP8266SAM Commented Jan 24, 2021 at 5:52

1 Answer 1

1

Base64 has nothing to do with audio. It is merely a way of encapsulating binary data into ASCII text so that it can safely be included in text-based structures like JSON, or transmitted over a text-based communication channel.

There is no library to "play" base64 simply because base64 is not something you play.

First you decode the base64 text into raw 8-bit binary. It's then that data that you play through whatever library is most suitable for your hardware.

For example on the ESP32 you have the function base64_decode() available. You can read up on how to use it in this tutorial.

answered Jan 23, 2021 at 11:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.