How can I:
- read my audio file
- stores in a binary file,
Can somebody give me examples to implement encoder and decoder in python?
How can I:
Can somebody give me examples to implement encoder and decoder in python?
You can use scipy.wave to read and write the wav file. To store the data, you could use numpy.
If the audio file is effectively encoded with 16 bits per sample, you don't have to do anything and this should will something like:
from scipy.io.wavfile import read as wavread
from scipy.io.wavfile import write as wavwrite
import numpy as np
sr, sig = wavread(audioFileName) #read the audio file (samplig rate, signal)
sig_int8 = np.uint8(sig) # cast the data in uint8
np.savez(out_file, sig = sig_int8) # store the data
npzfile = np.load(out_file + '.npz') #load the data
sig = npzfile['sig']
wavwrite(audioFileName2, sr, sig) #write data in wav file