-2

I am currently putting together a band-pass filter using the following code: https://ipython-books.github.io/116-applying-digital-filters-to-speech-sounds/

I made few edits to the above code, namely the file is no longer pulled from an url but instead from a local WAV file. Here are the associated edits

def speak(voice):
    audio = pydub.AudioSegment.from_wav(BytesIO(voice))    

    with tempfile.temporaryfile() as fn:
        wavef = audio.export(fn, format='wav')
        wavef.seek(0)                            
        wave = wavef.read()
...

voice = open("C:\\Users\\tkim1\\Documents\\librosa\\NEUT 41s 
shaking_gold.wav", "rb").read

Currently the "audio = pydub.AudioSegment.from_wav" line of the code outputs the following error: a bytes-like object is required, not 'builtin_function_or_method." I have gone over the two scripts line by line and cannot determine why this error is surfacing. Thank you so much for reading everyone. Any insights would be greatly appreciated!

1 Answers1

2

You didn't call read, which is a method.

voice = open("...", "rb").read()
#                             ^
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895