Skip to content

Commit

Permalink
fix:callback_error_logs (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Dec 28, 2024
1 parent 6fcd4f5 commit 11c3b40
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ovos_simple_listener/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def run(self):

if ww:
if self.callbacks:
self.callbacks.listen_callback()
try:
self.callbacks.listen_callback()
except Exception as e:
LOG.exception(f"listen callback error: {e}")
self.state = State.IN_COMMAND
sil_start = total_silence_duration = 0.0
start = time.time()
Expand Down Expand Up @@ -127,20 +130,32 @@ def run(self):
if timed_out:
audio = sr.AudioData(speech_data, self.mic.sample_rate, self.mic.sample_width)
if self.callbacks:
self.callbacks.audio_callback(audio)
try:
self.callbacks.audio_callback(audio)
except Exception as e:
LOG.exception(f"audio callback error: {e}")

tx = self.stt.transcribe(audio)
if self.callbacks:
if tx:
if tx[0][0]:
utt = tx[0][0].rstrip(" '\"").lstrip(" '\"")
self.callbacks.text_callback(utt, self.lang)
try:
self.callbacks.text_callback(utt, self.lang)
except Exception as e:
LOG.exception(f"text callback error: {e}")
else:
self.callbacks.error_callback(audio)
try:
self.callbacks.error_callback(audio)
except Exception as e:
LOG.exception(f"error callback error: {e}")

speech_data = b""
self.state = State.WAITING_WAKEWORD
if self.callbacks:
self.callbacks.end_listen_callback()
try:
self.callbacks.end_listen_callback()
except Exception as e:
LOG.exception(f"end listen callback error: {e}")
except KeyboardInterrupt:
break
except Exception as e:
Expand Down

0 comments on commit 11c3b40

Please sign in to comment.