Opening a wave file in Python: unknown format: 49. What's going wrong?

前端 未结 2 1419
轻奢々
轻奢々 2020-12-10 14:29

I try to open a wave file with the wave module, but I keep getting the same error whatever I try. The line with the error is the following:

wav          


        
相关标签:
2条回答
  • 2020-12-10 15:07

    The file is compressed and the wave module does not support this type of compression.

    0 讨论(0)
  • 2020-12-10 15:20

    Python's wave module works with a specific type of WAV: PCM (WAVE_FORMAT_PCM: 0x0001).

    In your case, you're using a WAV of type WAVE_FORMAT_GSM610 [0x0031 = hex(49)].

    You can use a program like Audacity or some lib for converting codecs to change the type of the WAV file.

    You can see a list of WAV types here: https://www.videolan.org/developers/vlc/doc/doxygen/html/vlc__codecs_8h.html

    Python's wave module source code: https://github.com/python/cpython/blob/master/Lib/wave.py

    0 讨论(0)
提交回复
热议问题