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:runtime_lang #165

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions ovos_dinkum_listener/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def transcribe(self, audio: Optional[Union[bytes, AudioData]] = None,
audiod = audio
else:
raise ValueError(f"'audio' must be 'bytes' or 'AudioData', got '{type(audio)}'")
LOG.debug(f"Transcribing with lang: {lang}")
return self.engine.transcribe(audiod, lang)


Expand Down
11 changes: 7 additions & 4 deletions ovos_dinkum_listener/voice_loop/voice_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ def _get_tx(self, stt_context: dict) -> (str, dict):
@return: string transcription and dict context
"""
# handle lang detection from speech
lang = self.stt.lang
if "stt_lang" in stt_context:
lang = self._validate_lang(stt_context["stt_lang"])
stt_context["stt_lang"] = lang
Expand All @@ -711,16 +712,18 @@ def _get_tx(self, stt_context: dict) -> (str, dict):

# get text and trigger callback
try:
utts = self.stt.transcribe() or []
except:
utts = self.stt.transcribe(lang=lang) or []
except Exception as e:
LOG.exception(f"Primary STT transcription failed: {str(e)}")
LOG.exception("STT failed")
utts = []

if not utts and self.fallback_stt is not None:
LOG.info("Attempting fallback STT plugin")
try:
utts = self.fallback_stt.transcribe() or []
except:
utts = self.fallback_stt.transcribe(lang=lang) or []
except Exception as e:
LOG.exception(f"Fallback STT transcription failed: {str(e)}")
LOG.exception("Fallback STT failed")

if not utts:
Expand Down
Loading