Gorilla.Audio.STT.VAD Unit Reference
Overview
The Gorilla.Audio.STT.VAD unit contains the voice activity detection of the
speech recognition subsystem: the backend independent IGorillaVAD interface,
the TGorillaVADBase state machine, the energy based detector registered by
default, and the registry that makes detectors selectable by name.
A detector is stateful and belongs to exactly one audio stream, so every
listener creates its own instance. Feed() is called from the capture thread,
everything else from the same thread.
Class Hierarchy
TInterfacedObject
└── TGorillaVADBase (IGorillaVAD)
└── TGorillaEnergyVAD
TGorillaVADRegistry (class with class methods only)
Enumerations
TGorillaVADState
| Value |
Description |
| Silence |
No speech, the noise floor is being tracked |
| Speech |
Speech is running, samples are collected |
Records
TGorillaVADSegment
One complete utterance cut out of the microphone stream.
| Field |
Description |
| Samples |
16 kHz mono float samples of the utterance |
| StartTime |
Start of the utterance in the stream, in seconds |
| EndTime |
End of the utterance in the stream, in seconds |
| PeakLevel |
Loudest sample of the utterance, 0..1 |
| AverageLevel |
Average level of the utterance, 0..1 |
| Truncated |
True when the maximum length forced the cut |
Duration() |
Length of the utterance in seconds |
IsValid() |
True when the segment carries audio |
IGorillaVAD
| Method |
Description |
GetName() |
Human readable name of the detector |
IsAvailable() |
False when the detector cannot work, e.g. a missing library |
Configure(ASampleRate) |
Prepares the detector for a stream of that rate; resets all state, so it may be called again whenever the capture format changed |
Reset() |
Drops the collected audio and returns to silence |
Feed(ASamples, ACount) |
Pushes new samples in; returns the number of segments completed during this call |
Flush() |
Closes a running utterance immediately, e.g. when push-to-talk was released; returns the number of completed segments |
TakeSegment(out ASegment) |
Removes the oldest completed segment from the queue; false when none is waiting |
PendingSegments() |
Number of segments waiting |
GetState() |
Current TGorillaVADState |
GetLevel() |
Current input level, 0..1 |
GetNoiseFloor() |
Tracked noise floor |
GetStreamTime() |
Position in the stream, in seconds |
TGorillaVADBase
Implements the state machine shared by all detectors: threshold handling,
pre-roll buffer, minimum durations and the segment queue. A concrete detector
only implements the per-frame classification.
Properties
| Property |
Type |
Default |
Description |
Threshold |
Single |
0.012 |
Absolute level a frame has to exceed to count as speech. It acts as the lower bound of the adaptive threshold: the effective threshold is the larger of this value and NoiseFloor * NoiseMultiplier |
NoiseMultiplier |
Single |
2.5 |
Factor the tracked noise floor is multiplied with |
MinSpeechDuration |
Single |
0.25 |
Shortest utterance reported, in seconds; anything shorter is discarded as a click or a cough |
MinSilenceDuration |
Single |
0.6 |
Pause that ends an utterance, in seconds. Too short cuts sentences apart at every breath, too long adds latency to every result |
PreRollDuration |
Single |
0.3 |
Audio in front of the detected speech that is kept, in seconds; without it the plosive at the start of a word is cut off |
MaxSegmentDuration |
Single |
15.0 |
Emergency brake: an utterance is cut after this many seconds even when the speaker does not pause |
Normalize |
Boolean |
— |
Normalizes the collected audio before it is reported |
Protected Methods (for implementers)
| Method |
Description |
DoDetectFrame(ASamples, ...) |
Classifies one complete frame; true when it contains speech |
DoConfigure() |
Called after Configure() so a detector can size its state |
DoReset() |
Called by Reset() so a detector can drop its state |
GetVADName() |
Name the detector registers itself under |
TGorillaEnergyVAD
The default detector: frame energy against an adaptive threshold, with a zero
crossing rate check to keep loud non-speech noise out. Registered under the name
Energy with priority 0.
| Property |
Type |
Default |
Description |
MaxZeroCrossingRate |
Single |
0.42 |
Crossing rate above which a loud frame is treated as noise, 0..1 |
NoiseAdaption |
Single |
0.05 |
Speed the noise floor follows the input, 0..1; larger values adapt faster but are more easily fooled by slow speech |
TGorillaVADRegistry
| Class Method |
Description |
RegisterVAD(AClass, APriority) |
Registers a detector with a priority |
UnregisterVAD(AClass) |
Removes it again |
FindVADClass(AName) |
Resolves a detector class by name |
CreateVAD(AName) |
Creates an instance; an empty name picks the highest priority detector |
VADNames() |
Names of all registered detectors |
DefaultVADName() |
Name of the highest priority detector |
Constants
| Constant |
Value |
GORILLA_VAD_THRESHOLD |
0.012 |
GORILLA_VAD_NOISE_MULTIPLIER |
2.5 |
GORILLA_VAD_MIN_SPEECH |
0.25 |
GORILLA_VAD_MIN_SILENCE |
0.6 |
GORILLA_VAD_PREROLL |
0.3 |
GORILLA_VAD_MAX_SEGMENT |
15.0 |
GORILLA_VAD_MAX_ZCR |
0.42 |
GORILLA_VAD_NOISE_ADAPTION |
0.05 |
See Also