Q:

Filtering frequencies above limit in wav file (Low pass filter)

I need to filter frequencies above 5Khz in a wav file. I made some research and found about butterworth algorithm but couldn't apply it.
Assume that I have a mono channel wav file. I read it, then I want to use a low pass filter to filter frequencies above 5Khz.
What I've done so far is this. I read the file, read frames and convert them to numerical values.
from pydub import AudioSegment

song = AudioSegment.from_wav("audio.wav")
frame_count = int(song.frame_count())
all_frames = [song.get_frame(i) for i in range(frame_count)]

def sample_to_int(sample):
    return int(sample.encode("hex"), 16)

int_freqs = [sample_to_int(frame) for frame in all_frames]

If I make change values >5000 to 0 is it enough? I don't think that's the way, I am very confused and would be glad to hear any help.

A:

Pydub includes a lopass filter -- there's no need for you to implement it yourself:
from pydub import AudioSegment

song = AudioSegment.from_wav("audio.wav")
new = song.low_pass_filter(5000)

It's "documented" in effects.py.

