spafe.utils.preprocessing¶
-
spafe.utils.preprocessing.
framing
(sig, fs=16000, win_len=0.025, win_hop=0.01)[source]¶ transform a signal into a series of overlapping frames (=Frame blocking).
Parameters: - sig (array) – a mono audio signal (Nx1) from which to compute features.
- fs (int) – the sampling frequency of the signal we are working with. Default is 16000.
- win_len (float) – window length in sec. Default is 0.025.
- win_hop (float) – step between successive windows in sec. Default is 0.01.
Returns: array of frames. frame length.
Uses the stride trick to accelerate the processing.
-
spafe.utils.preprocessing.
pre_emphasis
(sig, pre_emph_coeff=0.97)[source]¶ perform preemphasis on the input signal.
Parameters: - sig (array) – signal to filter.
- coeff (float) – preemphasis coefficient. 0 is no filter, default is 0.95.
Returns: the filtered signal.
-
spafe.utils.preprocessing.
remove_silence
(sig, fs, win_len=0.25, win_hop=0.25, threshold=-35)[source]¶ generate and apply a window function to avoid spectral leakage.
Parameters: - frames (array) – array including the overlapping frames.
- frame_len (int) – frame length.
- win_type (str) – type of window to use. Default is “hamming”
Returns: windowed frames.
-
spafe.utils.preprocessing.
stride_trick
(a, stride_length, stride_step)[source]¶ apply framing using the stride trick from numpy.
Parameters: - a (array) – signal array.
- stride_length (int) – length of the stride.
- stride_step (int) – stride step.
Returns: blocked/framed array.
-
spafe.utils.preprocessing.
windowing
(frames, frame_len, win_type='hamming', beta=14)[source]¶ generate and apply a window function to avoid spectral leakage.
Parameters: - frames (array) – array including the overlapping frames.
- frame_len (int) – frame length.
- win_type (str) – type of window to use. Default is “hamming”
Returns: windowed frames.