Python open raw audio data file

前端 未结 3 1284
抹茶落季
抹茶落季 2020-12-18 03:19

I have these files with the extension \".adc\". They are simply raw data files. I can open them with Audacity using File->Import->Raw data with encoding \"Signed 16 bit\" an

3条回答
  •  星月不相逢
    2020-12-18 03:35

    You can use PySoundFile to open the file as a NumPy array and play it with python-sounddevice.

    import soundfile as sf
    import sounddevice as sd
    
    sig, fs = sf.read('myfile.adc', channels=2, samplerate=16000,
                      format='RAW', subtype='PCM_16')
    sd.play(sig, fs)
    

    You can use indexing on the NumPy array to select a certain part of the audio data.

提交回复
热议问题