pythonbuffersoundfile

Using PySoundFile, how can I get a buffer of bytes?


I am trying to load an audio file (via PySoundFile) and have it return a buffer of bytes. But current dtype's are ['float32', 'float64', 'int16', 'int32']

I need it as bytes to use with pocketsphinx: decoder.process_raw


Solution

  • audio_data = self.SOUND_FILE.read(sample_frames, dtype='int16')
    audio_bytes = audio_data.tobytes()