hearing.vad¶
Voice-activity detection and utterance segmentation — re-exported from scribed.
The VAD logic (energy/neural detectors + utterance segmentation) is now owned by
scribed.vad so it can be shared across every scribed consumer. hearing keeps
this module as the stable import path; the names below are scribed’s.
See the hearing-live-pipeline skill for the rationale and the latency budget.
Functions
|
Group an async stream of audio blocks into utterances. |
Classes
|
Decides whether a block of audio contains speech. |
|
RMS-energy threshold VAD — the dependency-free default. |
|
Neural VAD via silero-vad (optional, lazy). |
- class hearing.vad.EnergyVAD(threshold=0.01)[source]¶
Bases:
objectRMS-energy threshold VAD — the dependency-free default.
A block counts as speech when its RMS energy exceeds
threshold(in the same units as the float audio, roughly[-1, 1]). Simple and deterministic; for noisy real-world audio preferSileroVAD.
- class hearing.vad.SileroVAD(speech_prob_threshold=0.5)[source]¶
Bases:
objectNeural VAD via silero-vad (optional, lazy). Accurate on noisy audio.
Requires
pip install silero-vad(or torch.hub). Raises an informative error if unavailable;EnergyVADneeds no dependencies.
- class hearing.vad.VAD(*args, **kwargs)[source]¶
Bases:
ProtocolDecides whether a block of audio contains speech.
- async hearing.vad.segment_utterances(frames, *, sample_rate, vad=None, silence_ms=700, min_speech_ms=200, max_utterance_ms=30000)[source]¶
Group an async stream of audio blocks into utterances.
Yields
(utterance_samples, start_ms)once per finalized utterance: speech accumulates into a buffer; aftersilence_msof trailing silence (ormax_utterance_msof continuous speech) the buffer is emitted with its start offset (integer ms from the beginning of the stream). Utterances with less thanmin_speech_msof actual speech are dropped as noise.sample_rateis the rate of the incoming blocks (used only for the ms arithmetic).- Return type:
AsyncIterator[Tuple[ndarray,int]]