Ok, take this answer with a piece of salt, as I don’t know pydub
enough to make sure that it works correctly, but you should be able to do this from the class initializer, providing all the parameters it needs: / p>
sample_rate, wav_sample = scipy.io.wavfile.read(file_path)
segment = AudioSegment(data=wav_sample.tobytes(),
sample_width=2,
frame_rate=sample_rate, channels=1)
It seems to work as it should, assuming a 16-bit single-channel sample.
(- wav_sample.nbytes() / len(wav_sample)
).
!
: , pydub
, scipy . , numpy pydub
, - ( )?
np.vstack((wav_sample[:,0],wav_sample[:,1])).reshape((-1,), order='F')