retry slower on bad mic things but ultimately segfault still
parent
465193b60d
commit
bb578e98f6
|
|
@ -52,26 +52,30 @@ class Reader(threading.Thread):
|
|||
self.inq = inq
|
||||
self.outq = outq
|
||||
|
||||
def run(self):
|
||||
log("Reader.run: start")
|
||||
try:
|
||||
idx = [
|
||||
def mic_idx(self):
|
||||
mics = []
|
||||
while not mics:
|
||||
log(f'searching for one of {self.name.split(",")} in {sr.Microphone.list_microphone_names()}...')
|
||||
time.sleep(1)
|
||||
mics = [
|
||||
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:
|
||||
]
|
||||
return mics[0]
|
||||
|
||||
def run(self):
|
||||
log("Reader.run: start")
|
||||
while not self.should_stop():
|
||||
try:
|
||||
with sr.Microphone(device_index=self.mic_idx()) as mic:
|
||||
while not self.should_stop():
|
||||
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)
|
||||
except Exception as e:
|
||||
if not "timed out" in str(e):
|
||||
time.sleep(5)
|
||||
log("Reader.run: error:", e)
|
||||
self.outq.put(None)
|
||||
log("Reader.run: stop")
|
||||
|
||||
def should_stop(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue