If a PCM wav audio file is converted into base64 format, to load in the original data
with open("wav_b64.txt", "rb") as f:
input_sig = base64.b64decode(f.read()) # read in the txt file
binaryHeader = input_sig[:44]
# https: // onestepcode.com / read - wav - header /
samplerate = np.frombuffer(binaryHeader[24:28], dtype=np.int32)[0]
binarySound = input_sig[44:]
# following conversion is suggested by Thorin
# convert to integers
sig = np.frombuffer(binarySound, dtype=np.int16)
# convert PCM to float
i = np.iinfo(sig.dtype)
abs_max = 2 ** (i.bits - 1)
offset = i.min + abs_max
y_data = (sig.astype('float32') - offset) / abs_max