Last Modified : Tuesday, Aug 13, 2024
Error
Traceback (most recent call last): with wave-open(audio_file, mode='rb') as file: return Wave_read (f) self.initfp(f) self._read_fmt_chunk(chunk) File "/home/ubuntu/miniconda3/envs/test/lib/python3.8/wave-py", line 269, in _read_fmt_chunk raise Error('unknown format: %r' % (wFormatTag,)) wave.Error: unknown format: 49
Why did this happened
Audio files are compressed into multiple formats like pcm, gsm and many more, now any python package or any audio player first needs to be able to read that compressed audio file, but the wave python package can only read pcm compressed audio files.
So you need to convert your audio file to pcm.
Solve
Convert it to pcm using ffmpeg
ffmpeg -i $input_audio_file $output_audio_file
This will convert any type of compressed audio file to pcm compressed audio file.
Now pass your audio file to wave package.
linux
wave
python
pip