|
|
|
|
|
|
|
|
|
|
|
|
|
import scipy.signal
|
|
|
|
def high_pass_filter(audio, sr, cutoff=100, order=5):
|
|
"""
|
|
Applies a high-pass filter to an audio signal.
|
|
|
|
Parameters:
|
|
audio (numpy array): The input audio signal.
|
|
sr (int): The sample rate of the audio signal.
|
|
cutoff (float): The cutoff frequency in Hz. Default is 100 Hz.
|
|
order (int): The order of the filter. Default is 5.
|
|
|
|
Returns:
|
|
numpy array: The filtered audio signal.
|
|
"""
|
|
|
|
sos = scipy.signal.butter(order, cutoff, btype='highpass', fs=sr, output='sos')
|
|
|
|
|
|
filtered_audio = scipy.signal.sosfilt(sos, audio)
|
|
|
|
return filtered_audio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|