emvoice.energy

Energy-related voice features.

Module Contents

Classes

HnrFrames

Estimate and store harmonics-to-noise ratios (HNRs).

RmsEnergyFrames

Calculate and store the root mean squared (RMS) energy.

class emvoice.energy.HnrFrames(frames: numpy.ndarray, sr: int, frame_len: int, hop_len: int, center: bool, pad_mode: str, lower: float, rel_silence_threshold)[source]

Bases: emvoice.frames.BaseFrames

Estimate and store harmonics-to-noise ratios (HNRs).

Parameters:
  • frames (numpy.ndarray) – HNR frames in dB with shape (num_frames,).

  • lower (float) – Lower fundamental frequency limit for choosing pitch candidates.

  • rel_silence_threshold (float) – Relative threshold for treating signal frames as silent.

Notes

Estimate the HNR for each signal frame with np.max(np.abs(frames), axis=1) > rel_silence_threshold*np.max(np.abs(frames)) by:

  1. Compute the autocorrelation function (ACF) using the short-term Fourier transform (STFT).

  2. Find the lags of peaks in the ACF excluding the zero-th lag.

  3. Filter out peaks that correspond to pitch candidates below lower and above the Nyquist frequency.

  4. Compute the harmonic component R0 as the highest of the remaining peaks divided by the ACF at lag zero.

  5. Compute the HNR as R0/(1-R0) and convert to dB.

classmethod from_frames(sig_frames_obj: emvoice.frames.BaseFrames, lower: float = 75.0, rel_silence_threshold: float = 0.1)[source]

Estimate the HNR from signal frames.

Parameters:
  • sig_frames_obj (BaseFrames) – Signal frames object.

  • lower (float, default = 75.0) – Lower fundamental frequency limit for choosing pitch candidates.

  • rel_silence_threshold (float, default = 0.1) – Relative threshold for treating signal frames as silent.

class emvoice.energy.RmsEnergyFrames(frames: numpy.ndarray, sr: int, window: str, frame_len: int, hop_len: int, center: bool = True, pad_mode: str = 'constant')[source]

Bases: emvoice.spectral.SpecFrames

Calculate and store the root mean squared (RMS) energy.

Parameters:

frames (numpy.ndarray) – RMS energy frames in dB with shape (num_frames,).

classmethod from_spec_frames(spec_frames_obj: emvoice.spectral.SpecFrames)[source]

Calculate the RMS energy from spectrogram frames.

Parameters:

spec_frames_obj (SpecFrames) – Spectrogram frames object.