0

I had audio that was recorded through unity, converted to binary and then to base64 for uploading to Google's Cloud processing. I now need to take that same base64 encoded binary audio and play it back in a php page.

I've tried to use various online base64 decoders and the output is a .bin file which I can't work out how to play. I've tried to copy what was done on this site: https://jsfiddle.net/Sl1v3r/af9av0o4/ but nothing seems to play. I'm not quite sure what should be in the data field in the javascript file.

I copied the content from the above site onto my server and it plays fine, but when I replace it with the base64 string for my audio as below it doesn't work

window.beeb = new Audio('data:audio/wav;base64,[my code]');

I've posted the full audio file in base64 format to pastebin: https://pastebin.com/sSp0SWp8

I would like to be able to decode the base64 audio and play it on a php site using javascript (or any other ways I can get the audio to play through a php page)

jcoutie
  • 1
  • 2
  • Why is the audio converted to Base64 in the first place? Far better to play it as a binary, saving you 33% in size, using less CPU, and reducing complexity. – Brad Sep 10 '19 at 04:52
  • See also: https://stackoverflow.com/q/695151/362536 – Brad Sep 10 '19 at 04:54
  • Brad, firstly, thanks for the reply! The data needs to be in Base64 Binary format for Google's API to accept it. Something I read on their page about binary data not being handled well when stored in a json. I might look at modifying my code to also upload the binary version of the audio, but would prefer a way to be able to decode the Base64 version that I already have to send. – jcoutie Sep 10 '19 at 05:32

0 Answers0