finally close reader
parent
eda12d9cb6
commit
0e278fffcb
|
|
@ -70,19 +70,24 @@ class Reader(threading.Thread):
|
|||
|
||||
def run(self):
|
||||
log("Reader.run: start")
|
||||
idx = [
|
||||
idx for idx,v in enumerate(
|
||||
sr.Microphone.list_microphone_names(),
|
||||
) if v in self.name.split(",")
|
||||
][0]
|
||||
with sr.Microphone(device_index=idx) as mic:
|
||||
while not self.should_stop():
|
||||
try:
|
||||
self.outq.put(self._run(mic))
|
||||
except Exception as e:
|
||||
if not "timed out" in str(e):
|
||||
log("Reader.run: error:", e)
|
||||
self.outq.put(None)
|
||||
try:
|
||||
idx = [
|
||||
idx for idx,v in enumerate(
|
||||
sr.Microphone.list_microphone_names(),
|
||||
) if v in self.name.split(",")
|
||||
][0]
|
||||
with sr.Microphone(device_index=idx) as mic:
|
||||
while not self.should_stop():
|
||||
try:
|
||||
self.outq.put(self._run(mic))
|
||||
except Exception as e:
|
||||
if not "timed out" in str(e):
|
||||
log("Reader.run: error:", e)
|
||||
except Exception as e:
|
||||
log("Reader.run panic:", e)
|
||||
log("microphones:", sr.Microphone.list_microphone_names())
|
||||
finally:
|
||||
self.outq.put(None)
|
||||
log("Reader.run: stop")
|
||||
|
||||
def should_stop(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue