I have a numpy audio array, I would like to write it in chunks as wav with ulaw encoding. For now I am using the soundfile library:
import soundfile as sf
# ...
audio_len = len(audio) # numpy array
chunkLen = int(0.030 * 8000)
for i in range(0, audio_len, chunkLen):
chunk = audio[i:min(i+chunkLen, audio_len)]
buffered = BytesIO()
sf.write(buffered, chunk, samplerate=8000, format="WAV", subtype="ULAW")
buffered.seek(0)
yield buffered.read()
However, the returned raw data file includes a lot of \bRIFF, which means it is still writing headers, is there anyway I can write it as headerless?