with boo
parent
97006d95c8
commit
11789a5c98
|
|
@ -67,16 +67,21 @@ class Reader(threading.Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
log("Reader.run: start")
|
log("Reader.run: start")
|
||||||
while not self.should_stop():
|
while not self.should_stop():
|
||||||
|
mic = None
|
||||||
try:
|
try:
|
||||||
with sr.Microphone(device_index=self.mic_idx()) as mic:
|
mic = sr.Microphone(device_index=self.mic_idx())
|
||||||
while not self.should_stop():
|
mic.__enter__()
|
||||||
self.outq.put(self._run(mic))
|
while not self.should_stop():
|
||||||
|
self.outq.put(self._run(mic))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not "timed out" in str(e):
|
if not "timed out" in str(e):
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exception(e)
|
traceback.print_exception(e)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
log("Reader.run: error:", e)
|
log("Reader.run: error:", e)
|
||||||
|
finally:
|
||||||
|
if mic:
|
||||||
|
mic.__exit__(None, None, None)
|
||||||
self.outq.put(None)
|
self.outq.put(None)
|
||||||
log("Reader.run: stop")
|
log("Reader.run: stop")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue