Skip to content

Commit

Permalink
Merge pull request #64 from eryk-urbanski/feature/pre-emphasis
Browse files Browse the repository at this point in the history
Replace np.append method with scipy.signal.lfilter (preemphasis)
  • Loading branch information
SuperKogito authored Apr 28, 2024
2 parents b6b1428 + 3a5e4fe commit c7c8499
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spafe/utils/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
For a copy, see <https://github.com/SuperKogito/spafe/blob/master/LICENSE>.
"""

from typing import Tuple

import numpy as np
from scipy.signal import lfilter
from dataclasses import dataclass
from typing_extensions import Literal

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


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

0 comments on commit c7c8499

Please sign in to comment.