I'm getting:
Exception has occurred: TypeError
a bytes-like object is required, not 'str'
When I run the following code:
from pydub import AudioSegment
from pydub.utils import which
AudioSegment.converter = which('ffmpeg')
AudioSegment.ffmpeg = r"C:\PATH_Programs\bin\ffmpeg.exe"
audio = AudioSegment(r'C:\Users\jack_l\Documents\Cm - 120 BPM.wav') #ERROR HERE
What I know:
AudioSegment.converter
and AudioSegment.ffmpeg
lines – I just have them there to show I've tried that.What am I doing wrong? Thanks
Error message seems pretty straightforward : AudioSegment
class constructor is expecting a bytes object and you are passing a String instead.
According to the pydub doc, you could simply call from_wav()
method by passing your filepath as a string.
Example (from the doc) :
song = AudioSegment.from_wav("never_gonna_give_you_up.wav")