Skip to content

Commit c7c8499

Browse files
authored
Merge pull request #64 from eryk-urbanski/feature/pre-emphasis
Replace np.append method with scipy.signal.lfilter (preemphasis)
2 parents b6b1428 + 3a5e4fe commit c7c8499

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spafe/utils/preprocessing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
For a copy, see <https://github.com/SuperKogito/spafe/blob/master/LICENSE>.
77
88
"""
9+
910
from typing import Tuple
1011

1112
import numpy as np
13+
from scipy.signal import lfilter
1214
from dataclasses import dataclass
1315
from typing_extensions import Literal
1416

@@ -67,7 +69,7 @@ def pre_emphasis(sig: np.ndarray, pre_emph_coeff: float = 0.97) -> np.ndarray:
6769
6870
y[t] = x[t] - \\alpha \\times x[t-1]
6971
"""
70-
return np.append(sig[0], sig[1:] - pre_emph_coeff * sig[:-1])
72+
return lfilter([1, -pre_emph_coeff], [1], sig)
7173

7274

7375
def stride_trick(a: np.ndarray, stride_length: int, stride_step: int) -> np.ndarray:

0 commit comments

Comments
 (0)