pydrobert.speech.pre

Classes for pre-processing speech signals

class pydrobert.speech.pre.Dither(coeff=1.0)[source]

Bases: PreProcessor

Add random noise to a signal tensor

The default axis of apply has been set to None, which will generate random noise for each coefficient. This is likely the desired behaviour. Setting axis to an integer will add random values along 1D slices of that axis.

Intermediate values are calculated as 64-bit floats. The result is cast back to the input data type.

Parameters:

coeff (float) – Standard deviation of dither

aliases = {'dither', 'dithering'}
coeff
class pydrobert.speech.pre.PreProcessor[source]

Bases: AliasedFactory

A container for pre-processing signals with a transform

abstract apply(signal, axis=None, in_place=False)[source]

Applies the transformation to a signal tensor

Consult the class documentation for more details on what the transformation is.

Parameters:
  • signal (ndarray) –

  • axis (Optional[int]) – Deprecated. The axis to apply the transform to.

  • in_place – Whether it is okay to modify signal (True) or whether a copy should be made (False)

Returns:

out (numpy.ndarray) – The transformed features

class pydrobert.speech.pre.Preemphasize(coeff=0.97)[source]

Bases: PreProcessor

Attenuate the low frequencies of a signal by taking sample differences

The following transformation is applied along the target axis

new[i] = old[i] - coeff * old[i-1] for i > 1
new[0] = old[0]

This is essentially a convolution with a Haar wavelet for positive coeff. It emphasizes high frequencies.

Intermediate values are calculated as 64-bit floats. The result is cast back to the input data type.

Parameters:

coeff (float) – Preemphasis coefficient

aliases = {'preemph', 'preemphasis', 'preemphasize'}
coeff