Search code examples
javascriptnode.jsbase64web-audio-api

Combine multiple base64 audio strings into into one in node.js


I want to combine six base64 strings (which I get from getAllAudioBase64 method in the google-tts-api npm package) into one in node.js. I have tried multiple solutions like this one, but none of them seem to work. Is there a way to combine them directly instead of converting them into mp3 and then using ffmpeg to combine them?


Solution

  • The files have headers and padding, so cannot just be concatanated together. Each file must be decoded from Base64, and then needs to be decoded to raw audio, then audio joined, and then reencoded and header added.

    You can stream decode / encode files one at a time during the process to avoid loading them all into memory if that is an issue.