diff --git a/ovos_plugin_manager/templates/stt.py b/ovos_plugin_manager/templates/stt.py index 9d108d87..70f072b2 100644 --- a/ovos_plugin_manager/templates/stt.py +++ b/ovos_plugin_manager/templates/stt.py @@ -8,6 +8,7 @@ from abc import ABCMeta, abstractmethod from queue import Queue from threading import Thread, Event +from typing import List, Tuple, Optional from ovos_config import Configuration from ovos_utils import classproperty @@ -78,8 +79,8 @@ def recognizer(self, val): @property def lang(self): return 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): @@ -119,9 +120,15 @@ def init_language(config_core): return lang @abstractmethod - def execute(self, audio, language=None): + def execute(self, audio, language: Optional[str] = None) -> str: + # TODO - eventually deprecate this and make transcribe the @abstractmethod pass + def transcribe(self, audio, lang: Optional[str] = None) -> List[Tuple[str, float]]: + """transcribe audio data to a list of + possible transcriptions and respective confidences""" + return [(self.execute(audio, lang), 1.0)] + @property def available_languages(self) -> set: """Return languages supported by this STT implementation in this state @@ -230,9 +237,16 @@ def stream_stop(self): return text return None - def execute(self, audio, language=None): + def execute(self, audio: Optional = None, + language: Optional[str] = None): return self.stream_stop() + def transcribe(self, audio: Optional = None, + lang: Optional[str] = None) -> List[Tuple[str, float]]: + """transcribe audio data to a list of + possible transcriptions and respective confidences""" + return [(self.execute(audio, lang), 1.0)] + @abstractmethod def create_streaming_thread(self): pass