Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:callback_error_logs #5

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading