Merge branch 'dev' into feat/pause-functionality

This commit is contained in:
Storm
2026-01-20 12:50:34 +01:00
7 changed files with 347 additions and 62 deletions

View File

@@ -97,34 +97,9 @@ class AudioSender(SocketBase):
stream = open_stream()
while not state.exit_event.is_set():
if not state.active_event.is_set(): # when paused
# Stop and close the stream if it is open to prevent buffer overflow
if stream:
try:
stream.stop_stream()
stream.close()
except IOError:
pass # Ignore errors on closing
stream = None
state.active_event.wait() # Wait until unpaused
# Check if exit_event was set while waiting
if state.exit_event.is_set():
break
stream = open_stream()
if stream:
try:
data = stream.read(chunk)
self.socket.send(data)
except IOError as e:
logger.warn("Audio read error occurred.", exc_info=e)
if stream:
stream.close()
stream = open_stream()
data = stream.read(chunk)
if (state.is_speaking): continue # Do not send audio while the robot is speaking
self.socket.send(data)
except IOError as e:
logger.error("Stopped listening: failed to get audio from microphone.", exc_info=e)
finally: