Invoke cleanup method on VAD analyzer.

This commit is contained in:
filipi87
2026-03-24 10:49:14 -03:00
parent 311afef7da
commit 02cfb129d3
2 changed files with 19 additions and 0 deletions

View File

@@ -242,3 +242,12 @@ class VADAnalyzer(ABC):
self._vad_stopping_count = 0
return self._vad_state
async def cleanup(self):
"""Clean up resources.
This method should be called when the object is no longer needed.
It waits for all currently executing event handler tasks to finish
before returning.
"""
pass

View File

@@ -109,6 +109,16 @@ class VADController(BaseObject):
# Broadcast initial VAD params so other services (e.g. STT) can use them
await self.broadcast_frame(SpeechControlParamsFrame, vad_params=self._vad_analyzer.params)
async def cleanup(self):
"""Clean up resources.
This method should be called when the object is no longer needed.
It waits for all currently executing event handler tasks to finish
before returning.
"""
if self._vad_analyzer:
await self._vad_analyzer.cleanup()
async def _handle_audio(self, frame: InputAudioRawFrame):
"""Process an audio chunk and emit speech events as needed.