basic_tools¶
This module contains a set of basic classes and functions that are commonly used by the other modules of the package.
Classes¶
SignalObj Class¶
The SignalObj Class stores the speech signal and all the parameters related to it.
USAGE:
-
amfm_decompy.basic_tools.
SignalObj
(*args, **kwargs)¶ - Parameters
args – the input argument can be a string with the wav file path OR two arguments, where the first one is a numpy array containing the speech signal data and the second one represents its fundamental frequency in Hz.
kwargs – please check below for the options.
- Return type
speech signal object.
KWARGS OPTIONS:
‘data’ - instead of initializing a SignalObj with two arguments, the input signal data can be alternatively passed using this kwarg. It must used along with the ‘fs’ kwarg.
‘fs’ - instead of initializing a SignalObj with two arguments, the input signal sample frequency can be alternatively passed using this kwarg. It must used along with the ‘data’ kwarg.
‘name’ - instead of initializing a SignalObj with one argument, the input wav file path can be alternatively passed using this kwarg.
‘output_dtype’ - the numpy dtype of the output signal data.
SIGNAL OBJECT ATTRIBUTES:¶
-
SignalObj.
data
¶ Numpy array containing the speech signal data. It is set during the object’s initialization.
-
SignalObj.
fs
¶ Sample frequency in Hz. It is set during the object’s initialization.
-
SignalObj.
size
¶ Speech signal length. It is set during the object’s initialization.
-
SignalObj.
filtered
¶ Bandpassed version from the speech data. It is set by the SignalObj.filtered_version method.
-
SignalObj.
new_fs
¶ Downsampled fundamental frequency from the speech data. It is set by the SignalObj.filtered_version method.
-
SignalObj.
clean
¶ When the SignalObj.noiser method is called, this attribute is created and used to store a clean copy from the original signal.
SIGNAL OBJECT METHODS:¶
-
SignalObj.
filtered_version
(bp_filter)¶ - Parameters
bp_filter – BandpassFilter object.
Filters the signal data by a bandpass filter.
-
SignalObj.
set_nharm
(pitch_track, n_harm_max)¶ - Parameters
pitch_track (numpy array) – pitch extracted values for each signal sample.
n_harm_max (int) – represents the maximum number of components that can be extracted from the signal.
Uses the pitch values to estimate the number of modulated components in the signal.
-
SignalObj.
noiser
(pitch_track, SNR)¶ - Parameters
pitch_track (numpy array) – pitch extracted values for each signal sample.
SNR (float) – desired signal-to-noise ratio from the output signal.
Adds a zero-mean gaussian noise to the signal.
Functions¶
pcm2float¶
USAGE:
-
amfm_decompy.basic_tools.
pcm2float
(sig[, dtype=numpy.float64])¶ - Parameters
sig (numpy array) – PCM speech signal data.
dtype (float) – data type from the elements of the output array (default: numpy.float64).
- Return type
numpy array.
Transform a PCM raw signal into a float one, with values limited between -1 and 1.