I want to load my audio into python so that I can cut parts of it together and then resave as a shorter file. Pydub is in theory perfect for this.
from pydub import AudioSegment
from pydub.utils import make_chunks
from pydub.utils import which
AudioSegment.converter = which("ffmpeg")
myaudio = AudioSegment.from_file(path+ wavfile+".wav" , "wav")
However I get the following error on trying to load the file.
ffmpeg version 2021-04-11-git-309e3cc15c-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 72.100 / 56. 72.100
libavcodec 58.136.101 / 58.136.101
libavformat 58. 78.100 / 58. 78.100
libavdevice 58. 14.100 / 58. 14.100
libavfilter 7.111.100 / 7.111.100
libswscale 5. 10.100 / 5. 10.100
libswresample 3. 10.100 / 3. 10.100
libpostproc 55. 10.100 / 55. 10.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'D:/OneDrive/DataSci/Tennis/01_data/201121_SebMatch/JJO_ingameAUDIO.wav':
Duration: 00:48:03.03, bitrate: 192 kb/s
Stream #0:0: Audio: adpcm_ima_wav ([17][0][0][0] / 0x0011), 48000 Hz, mono, s16p, 192 kb/s
**Unknown encoder 'pcm_s4le'**
I do not see this specific error on any questions, and have logged the question on the git respository for pydub here There is also an example testfile to test upon. Whilst this is not the actual file I want to process (which is 70mb), this generates the same output.
I managed to load the file using soundfile, but when I sliced the data, it then wouldn't let me export it as they were 2 different lengths. Hence I went back to pydub.
Any suggestions are appreciated.
Digging around with other libraries, I found this link which highlights the differnt methods for looking at the audio.
The soundfile demo shows how to identify the encoding using these lines:
f = sf.SoundFile('data/test_wav_pcm16.wav')
f.format, f.subtype, f.endian
This told me that my wav file was infact encoded with "IMA ADPCM".
I then loaded the file in soundfile, and resaved it as soundfile by default saves to PCM_16, which can then be recognised by pydub....