Skip to content

Commit

Permalink
,
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 24, 2024
1 parent e280939 commit b526f89
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ovos_plugin_manager/templates/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

from ovos_config import Configuration
from ovos_utils import classproperty
from ovos_utils.lang import standardize_lang_tag
from ovos_utils.log import deprecated, LOG
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils.lang import standardize_lang_tag
from ovos_plugin_manager.utils.config import get_plugin_config

from ovos_plugin_manager.templates.transformers import AudioLanguageDetector
from ovos_plugin_manager.utils.config import get_plugin_config


class STT(metaclass=ABCMeta):
Expand Down Expand Up @@ -90,8 +91,8 @@ def recognizer(self, val):
@property
def lang(self):
return standardize_lang_tag(self._lang or \
self.config.get("lang") or \
Configuration().get("lang", "en-US"))
self.config.get("lang") or \
Configuration().get("lang", "en-US"))

@lang.setter
def lang(self, val):
Expand Down Expand Up @@ -136,7 +137,11 @@ def transcribe(self, audio, lang: Optional[str] = None) -> List[Tuple[str, float
"""transcribe audio data to a list of
possible transcriptions and respective confidences"""
if lang is not None and lang == "auto":
lang, prob = self.detect_language(audio, self.available_languages)
try:
lang, prob = self.detect_language(audio, self.available_languages)
except Exception as e:
LOG.error(f"Language detection failed: {e}. Falling back to default language.")
lang = self.lang # Fall back to default language
return [(self.execute(audio, lang), 1.0)]

@property
Expand Down

0 comments on commit b526f89

Please sign in to comment.