refactor: define contrato de VAD e eventos de fala

This commit is contained in:
alex alves
2026-11-03 17:01:03 -03:00
parent 76d15b8e52
commit 2d1acdac31
4 changed files with 118 additions and 0 deletions

View File

@@ -390,6 +390,7 @@ src/voice_assistant/
audio_gateway/app/ WebSocket endpoint and protocol
application/ VoiceSession and transport-independent events
domain/ Session state and domain rules
vad/ VAD port and speech boundaries; runtime integration pending
audio/ Canonical audio models
stt/ STT contract, mock and NVIDIA adapter
agent/ Agent contract and mock adapter
@@ -415,3 +416,21 @@ tools/ Integration and smoke scripts
**Status:** V1 development baseline · Python 3.12+ · WebSocket protocol 1.0
## Backend VAD contract (integration pending)
`vad/adapter.py` defines one stateful detector per continuous input stream.
Its input is the canonical PCM S16LE, mono, 16 kHz audio format. Arbitrary
complete PCM frames are buffered into model-specific windows by the adapter.
`vad/models.py` defines `SpeechStarted` and `SpeechEnded`; their sample offsets
refer to input audio since initialization or reset, with inclusive starts
and exclusive ends. Detection confirmation may arrive later than its audio
boundary. Model padding never extends the input timeline.
`process()` returns ordered boundaries, `flush()` handles normal end of input,
`reset()` discards detection state and restarts the timeline, and `aclose()`
releases resources without emitting new speech events. Calls are serialized.
These contracts do not start turns, select providers, or carry transport IDs.
The Silero implementation, application integration, and browser VAD replacement
are subsequent tasks. This step leaves the active conversation flow unchanged.