Skip to content

Commit 62c4acb

Browse files
authored
Merge pull request #290 from OpenVoiceOS/release-0.7.0a1
Release 0.7.0a1
2 parents ea81695 + 63ad6fd commit 62c4acb

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
# Changelog
22

3-
## [0.6.0a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.6.0a1) (2024-11-20)
3+
## [0.7.0a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.7.0a1) (2024-11-24)
44

5-
[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.7a1...0.6.0a1)
5+
[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.6.0...0.7.0a1)
66

77
**Merged pull requests:**
88

9-
- feat: chat history [\#286](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/286) ([JarbasAl](https://github.com/JarbasAl))
10-
11-
## [0.5.7a1](https://github.com/OpenVoiceOS/ovos-plugin-manager/tree/0.5.7a1) (2024-11-18)
12-
13-
[Full Changelog](https://github.com/OpenVoiceOS/ovos-plugin-manager/compare/0.5.6...0.5.7a1)
14-
15-
**Merged pull requests:**
16-
17-
- Update `config` default value handling with updated unit test [\#276](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/276) ([NeonDaniel](https://github.com/NeonDaniel))
9+
- feat: STT lang detector [\#289](https://github.com/OpenVoiceOS/ovos-plugin-manager/pull/289) ([JarbasAl](https://github.com/JarbasAl))
1810

1911

2012

ovos_plugin_manager/templates/stt.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
from abc import ABCMeta, abstractmethod
99
from queue import Queue
1010
from threading import Thread, Event
11-
from typing import List, Tuple, Optional
11+
from typing import List, Tuple, Optional, Set, Union
1212

1313
from ovos_config import Configuration
1414
from ovos_utils import classproperty
15-
from ovos_utils.log import deprecated
16-
from ovos_utils.process_utils import RuntimeRequirements
1715
from ovos_utils.lang import standardize_lang_tag
16+
from ovos_utils.log import deprecated, LOG
17+
from ovos_utils.process_utils import RuntimeRequirements
18+
19+
from ovos_plugin_manager.templates.transformers import AudioLanguageDetector
1820
from ovos_plugin_manager.utils.config import get_plugin_config
1921

2022

@@ -31,6 +33,16 @@ def __init__(self, config=None):
3133

3234
self.can_stream = False
3335
self._recognizer = None
36+
self._detector = None
37+
38+
def bind(self, detector: AudioLanguageDetector):
39+
self._detector = detector
40+
LOG.debug(f"{self.__class__.__name__} - Assigned lang detector: {detector}")
41+
42+
def detect_language(self, audio, valid_langs: Optional[Union[Set[str], List[str]]] = None) -> Tuple[str, float]:
43+
if self._detector is None:
44+
raise NotImplementedError(f"{self.__class__.__name__} does not support audio language detection")
45+
return self._detector.detect(audio, valid_langs=valid_langs or self.available_languages)
3446

3547
@classproperty
3648
def runtime_requirements(self):
@@ -79,8 +91,8 @@ def recognizer(self, val):
7991
@property
8092
def lang(self):
8193
return standardize_lang_tag(self._lang or \
82-
self.config.get("lang") or \
83-
Configuration().get("lang", "en-US"))
94+
self.config.get("lang") or \
95+
Configuration().get("lang", "en-US"))
8496

8597
@lang.setter
8698
def lang(self, val):
@@ -124,10 +136,16 @@ def execute(self, audio, language: Optional[str] = None) -> str:
124136
def transcribe(self, audio, lang: Optional[str] = None) -> List[Tuple[str, float]]:
125137
"""transcribe audio data to a list of
126138
possible transcriptions and respective confidences"""
139+
if lang is not None and lang == "auto":
140+
try:
141+
lang, prob = self.detect_language(audio, self.available_languages)
142+
except Exception as e:
143+
LOG.error(f"Language detection failed: {e}. Falling back to default language.")
144+
lang = self.lang # Fall back to default language
127145
return [(self.execute(audio, lang), 1.0)]
128146

129147
@property
130-
def available_languages(self) -> set:
148+
def available_languages(self) -> Set[str]:
131149
"""Return languages supported by this STT implementation in this state
132150
This property should be overridden by the derived class to advertise
133151
what languages that engine supports.

ovos_plugin_manager/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# START_VERSION_BLOCK
22
VERSION_MAJOR = 0
3-
VERSION_MINOR = 6
3+
VERSION_MINOR = 7
44
VERSION_BUILD = 0
5-
VERSION_ALPHA = 0
5+
VERSION_ALPHA = 1
66
# END_VERSION_BLOCK

0 commit comments

Comments
 (0)