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

feat/alternative_transcripts #236

Merged
merged 3 commits into from
Jun 15, 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
22 changes: 18 additions & 4 deletions ovos_plugin_manager/templates/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading