feat: allow no audio input while robot is speaking

The VAD agent will discard its current buffer and retry receiving data.

ref: N25B-213
This commit is contained in:
Twirre Meulenbelt
2025-10-28 10:58:28 +01:00
parent a44df4781b
commit 833dd6c9d4
2 changed files with 3 additions and 11 deletions

View File

@@ -53,20 +53,14 @@ class Streaming(CyclicBehaviour):
self.audio_out_socket = audio_out_socket
self.audio_buffer = np.array([], dtype=np.float32)
self.i_since_data = 0 # Used to avoid logging every cycle if audio input stops
self.i_since_speech = 100 # Used to allow small pauses in speech
async def run(self) -> None:
data = await self.audio_in_poller.poll()
if data is None:
if self.i_since_data % 10 == 0:
logger.debug(
"Failed to receive audio from socket for %d ms.",
self.audio_in_poller.timeout_ms * (self.i_since_data + 1),
)
self.i_since_data += 1
logger.debug("No audio data received. Discarding buffer until new data arrives.")
self.audio_buffer = np.array([], dtype=np.float32)
return
self.i_since_data = 0
# copy otherwise Torch will be sad that it's immutable
chunk = np.frombuffer(data, dtype=np.float32).copy()