How to decode base64 String directly to binary audio format
问题 Audio file is sent to us via API which is Base64 encoded PCM format. I need to convert it to PCM and then WAV for processing. I was able to decode -> save to pcm -> read from pcm -> save as wav using the following code. decoded_data = base64.b64decode(data, ' /') with open(pcmfile, 'wb') as pcm: pcm.write(decoded_data) with open(pcmfile, 'rb') as pcm: pcmdata = pcm.read() with wave.open(wavfile, 'wb') as wav: wav.setparams((1, 2, 16000, 0, 'NONE', 'NONE')) wav.writeframes(pcmdata) It'd be a