Spaces:
Sleeping
Sleeping
Delete highPassFilter.ipynb
Browse files- highPassFilter.ipynb +0 -72
highPassFilter.ipynb
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 2,
|
6 |
-
"id": "b2d45592-5695-40ec-ad90-7d03275337a6",
|
7 |
-
"metadata": {},
|
8 |
-
"outputs": [],
|
9 |
-
"source": [
|
10 |
-
"# import scipy.signal\n",
|
11 |
-
"\n",
|
12 |
-
"# def high_pass_filter(audio, sr, cutoff=200, order=3):\n",
|
13 |
-
"# \"\"\"\n",
|
14 |
-
"# Applies a high-pass filter to an audio signal.\n",
|
15 |
-
"\n",
|
16 |
-
"# Parameters:\n",
|
17 |
-
"# audio (numpy array): The input audio signal.\n",
|
18 |
-
"# sr (int): The sample rate of the audio signal.\n",
|
19 |
-
"# cutoff (float): The cutoff frequency in Hz. Default is 100 Hz.\n",
|
20 |
-
"# order (int): The order of the filter. Default is 5.\n",
|
21 |
-
" \n",
|
22 |
-
"# Returns:\n",
|
23 |
-
"# numpy array: The filtered audio signal.\n",
|
24 |
-
"# \"\"\"\n",
|
25 |
-
"# # Design the high-pass filter using a Butterworth filter design\n",
|
26 |
-
"# sos = scipy.signal.butter(order, cutoff, btype='highpass', fs=sr, output='sos')\n",
|
27 |
-
" \n",
|
28 |
-
"# # Apply the filter using sosfilt (second-order sections filter)\n",
|
29 |
-
"# filtered_audio = scipy.signal.sosfilt(sos, audio)\n",
|
30 |
-
" \n",
|
31 |
-
"# return filtered_audio"
|
32 |
-
]
|
33 |
-
},
|
34 |
-
{
|
35 |
-
"cell_type": "code",
|
36 |
-
"execution_count": null,
|
37 |
-
"id": "8a1efa78-61d4-4545-b50a-080161bb6aa5",
|
38 |
-
"metadata": {},
|
39 |
-
"outputs": [],
|
40 |
-
"source": [
|
41 |
-
"def high_pass_filter(audio, sr, cutoff=300):\n",
|
42 |
-
" # Design a Butterworth high-pass filter\n",
|
43 |
-
" nyquist = 0.5 * sr\n",
|
44 |
-
" normal_cutoff = cutoff / nyquist\n",
|
45 |
-
" b, a = butter(1, normal_cutoff, btype='high', analog=False)\n",
|
46 |
-
" filtered_audio = lfilter(b, a, audio)\n",
|
47 |
-
" return filtered_audio"
|
48 |
-
]
|
49 |
-
}
|
50 |
-
],
|
51 |
-
"metadata": {
|
52 |
-
"kernelspec": {
|
53 |
-
"display_name": "Python 3 (ipykernel)",
|
54 |
-
"language": "python",
|
55 |
-
"name": "python3"
|
56 |
-
},
|
57 |
-
"language_info": {
|
58 |
-
"codemirror_mode": {
|
59 |
-
"name": "ipython",
|
60 |
-
"version": 3
|
61 |
-
},
|
62 |
-
"file_extension": ".py",
|
63 |
-
"mimetype": "text/x-python",
|
64 |
-
"name": "python",
|
65 |
-
"nbconvert_exporter": "python",
|
66 |
-
"pygments_lexer": "ipython3",
|
67 |
-
"version": "3.11.7"
|
68 |
-
}
|
69 |
-
},
|
70 |
-
"nbformat": 4,
|
71 |
-
"nbformat_minor": 5
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|