Adding flag for file writting recording case

This commit is contained in:
CarolinePascal 2025-04-09 15:00:18 +02:00
parent d53035d047
commit 1e5e631743
No known key found for this signature in database
1 changed files with 5 additions and 1 deletions

View File

@ -158,6 +158,7 @@ class Microphone:
self.logs = {}
self.is_connected = False
self.is_recording = False
self.is_writing = False
def connect(self) -> None:
if self.is_connected:
@ -220,6 +221,7 @@ class Microphone:
logging.warning(status)
# Slicing makes copy unecessary
# Two separate queues are necessary because .get() also pops the data from the queue
if self.is_writing:
self.record_queue.put(indata[:,self.channels])
self.read_queue.put(indata[:,self.channels])
@ -301,6 +303,8 @@ class Microphone:
self.record_thread.daemon = True
self.record_thread.start()
self.is_writing = True
self.is_recording = True
self.stream.start()