Audio Filtering is necessary when you need to remove or reduce the unwanted part of a sound.

Common Types of Filters

Import the pydub, scipy, and numpy library:

from pydub import AudioSegment
from pydub.generators import Sine, Square, WhiteNoise
from pydub.playback import play
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, lfilter

Filtering with pydub since it has built-in low-pass and high-pass filters:

low_passed = combined.low_pass_filter(1000)   # Cut above 1kHz
high_passed = combined.high_pass_filter(1000) # Cut below 1kHz
print("Playing low-pass filtered...")
play(low_passed)
print("Playing high-pass filtered...")
play(high_passed)

Output:

Playing low-pass filtered...
Input #0, wav, from '/var/folders/gc/49grx5f90nv3f12yh4jhhf740000gn/T/tmp128b0_oy.wav':
  Duration: 00:00:06.00, bitrate: 705 kb/s
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
   5.91 M-A:  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B 

Playing high-pass filtered...
Input #0, wav, from '/var/folders/gc/49grx5f90nv3f12yh4jhhf740000gn/T/tmpn9swuzo6.wav':
  Duration: 00:00:06.00, bitrate: 705 kb/s
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
   5.88 M-A:  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B