mstar.model.omnivoice.components.silence

Contents

mstar.model.omnivoice.components.silence#

The reference’s silence trim (omnivoice.utils.audio.remove_silence), vectorized and sample-exact.

The reference runs pydub: an RMS window every 10 ms, each a fresh AudioSegment slice and an audioop.rms call, which costs about 14 ms of Python per second of audio and ran inside the code2wav forward, stalling the worker’s loop for every finished request. This computes the same windows from one prefix sum of squared int16 samples and replays pydub’s millisecond slicing (int(ms * rate / 1000) samples, zero-filled past the end), its range merging and its edge trim, so the output is the reference’s to the sample; test_omnivoice_silence checks it against pydub.

Functions

remove_silence(audio, sampling_rate[, ...])

omnivoice.utils.audio.remove_silence for mono (1, T) float audio.

mstar.model.omnivoice.components.silence.remove_silence(audio, sampling_rate, mid_sil=300, lead_sil=100, trail_sil=300)[source]#

omnivoice.utils.audio.remove_silence for mono (1, T) float audio.

Parameters:
  • audio (ndarray)

  • sampling_rate (int)

  • mid_sil (int)

  • lead_sil (int)

  • trail_sil (int)

Return type:

ndarray