diff --git a/.github/workflows/license_tests.yml b/.github/workflows/license_tests.yml index 7d0c4f6..c57fbca 100644 --- a/.github/workflows/license_tests.yml +++ b/.github/workflows/license_tests.yml @@ -8,3 +8,5 @@ on: jobs: license_tests: uses: neongeckocom/.github/.github/workflows/license_tests.yml@master + with: + packages-exclude: '^(precise-runner|fann2|tqdm|bs4|ovos-phal-plugin|ovos-skill|neon-core|nvidia|neon-phal-plugin|bitstruct|audioread).*' diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f59cf3..f4e306b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,60 @@ # Changelog -## [4.0.1a2](https://github.com/NeonGeckoCom/neon_speech/tree/4.0.1a2) (2023-07-18) +## [4.2.0](https://github.com/NeonGeckoCom/neon_speech/tree/4.2.0) (2023-10-27) -[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.0.1a1...4.0.1a2) +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a6...4.2.0) + +**Fixed bugs:** + +- \[BUG\] Docker `start_listening` resource missing [\#170](https://github.com/NeonGeckoCom/neon_speech/issues/170) + +## [4.1.1a6](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a6) (2023-10-26) + +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a5...4.1.1a6) + +**Merged pull requests:** + +- OVOS Dinkum Listener Backwards Compat [\#178](https://github.com/NeonGeckoCom/neon_speech/pull/178) ([NeonDaniel](https://github.com/NeonDaniel)) + +## [4.1.1a5](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a5) (2023-10-26) + +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a4...4.1.1a5) + +**Merged pull requests:** + +- Stable dependencies for release [\#177](https://github.com/NeonGeckoCom/neon_speech/pull/177) ([NeonDaniel](https://github.com/NeonDaniel)) + +## [4.1.1a4](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a4) (2023-10-13) + +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a3...4.1.1a4) + +**Merged pull requests:** + +- Update Dinkum Listener dependency [\#176](https://github.com/NeonGeckoCom/neon_speech/pull/176) ([NeonDaniel](https://github.com/NeonDaniel)) + +## [4.1.1a3](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a3) (2023-10-03) + +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a2...4.1.1a3) + +**Merged pull requests:** + +- Add timing metrics for minerva testing [\#175](https://github.com/NeonGeckoCom/neon_speech/pull/175) ([NeonDaniel](https://github.com/NeonDaniel)) + +## [4.1.1a2](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a2) (2023-07-28) + +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.1a1...4.1.1a2) **Merged pull requests:** -- Update dependencies and mark deprecation [\#171](https://github.com/NeonGeckoCom/neon_speech/pull/171) ([NeonDaniel](https://github.com/NeonDaniel)) +- Kubernetes/No-audio server compat. [\#174](https://github.com/NeonGeckoCom/neon_speech/pull/174) ([NeonDaniel](https://github.com/NeonDaniel)) -## [4.0.1a1](https://github.com/NeonGeckoCom/neon_speech/tree/4.0.1a1) (2023-06-27) +## [4.1.1a1](https://github.com/NeonGeckoCom/neon_speech/tree/4.1.1a1) (2023-07-27) -[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.0.0...4.0.1a1) +[Full Changelog](https://github.com/NeonGeckoCom/neon_speech/compare/4.1.0...4.1.1a1) **Merged pull requests:** -- Update Docker to use OVOS\_CONFIG envvars [\#169](https://github.com/NeonGeckoCom/neon_speech/pull/169) ([NeonDaniel](https://github.com/NeonDaniel)) +- Update container config handling and resolve logged warnings [\#173](https://github.com/NeonGeckoCom/neon_speech/pull/173) ([NeonDaniel](https://github.com/NeonDaniel)) diff --git a/Dockerfile b/Dockerfile index 709629d..eb50f4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ LABEL vendor=neon.ai \ ENV OVOS_CONFIG_BASE_FOLDER neon ENV OVOS_CONFIG_FILENAME neon.yaml +ENV XDG_CONFIG_HOME /config RUN apt-get update && \ apt-get install -y \ diff --git a/docker_overlay/etc/neon/neon.yaml b/docker_overlay/etc/neon/neon.yaml index 7835100..34d2e6d 100644 --- a/docker_overlay/etc/neon/neon.yaml +++ b/docker_overlay/etc/neon/neon.yaml @@ -57,6 +57,7 @@ sounds: start_listening: snd/start_listening.wav end_listening: snd/end_listening.wav acknowledge: snd/acknowledge.mp3 + error: snd/error.mp3 MQ: server: mq.2021.us port: 5672 diff --git a/neon_speech/service.py b/neon_speech/service.py index df02f37..769842b 100644 --- a/neon_speech/service.py +++ b/neon_speech/service.py @@ -35,8 +35,9 @@ from pydub import AudioSegment from speech_recognition import AudioData from neon_utils.file_utils import decode_base64_string_to_file -from ovos_utils.log import LOG +from ovos_utils.log import LOG, log_deprecation from neon_utils.configuration_utils import get_neon_user_config +from neon_utils.metrics_utils import Stopwatch from neon_utils.user_utils import apply_local_user_profile_updates from ovos_bus_client import Message from ovos_config.config import update_mycroft_config @@ -79,6 +80,8 @@ def on_started(): class NeonSpeechClient(OVOSDinkumVoiceService): + _stopwatch = Stopwatch("get_stt") + def __init__(self, ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, alive_hook=on_alive, started_hook=on_started, watchdog=lambda: None, @@ -113,12 +116,16 @@ def __init__(self, ready_hook=on_ready, error_hook=on_error, init_signal_bus init_signal_bus(self.bus) init_signal_handlers() + try: + self._default_user = get_neon_user_config() + except PermissionError: + LOG.warning("Unable to get writable config path; fallback to /tmp") + self._default_user = get_neon_user_config("/tmp") - self._default_user = get_neon_user_config() self._default_user['user']['username'] = "local" self.lock = Lock() - + self._stop_service = Event() if self.config.get('listener', {}).get('enable_stt_api', True): self.api_stt = STTFactory.create(config=self.config, results_event=None) @@ -126,9 +133,36 @@ def __init__(self, ready_hook=on_ready, error_hook=on_error, LOG.info("Skipping api_stt init") self.api_stt = None + def _validate_message_context(self, message: Message, native_sources=None): + if message.context.get('destination') and \ + "audio" not in message.context['destination']: + log_deprecation(f"Adding audio to destination context for " + f"{message.msg_type}", "5.0.0") + message.context['destination'].append('audio') + return OVOSDinkumVoiceService._validate_message_context(self, message, + native_sources) + + def run(self): + if self.config.get('listener', {}).get('enable_voice_loop', True): + OVOSDinkumVoiceService.run(self) + else: + LOG.info(f"Running without voice_loop") + self.register_event_handlers() + self.status.set_ready() + try: + self._stop_service.wait() + except KeyboardInterrupt: + self.status.set_stopping() + except Exception as e: + LOG.exception("voice_loop failed") + self.status.set_error(str(e)) + LOG.info("Service stopped") + self._after_stop() + def shutdown(self): LOG.info("Shutting Down") self.stop() + self._stop_service.set() def register_event_handlers(self): OVOSDinkumVoiceService.register_event_handlers(self) @@ -350,10 +384,12 @@ def build_context(msg: Message): wav_file_path = message.data.get("audio_file") lang = message.data.get("lang") try: - _, parser_data, transcriptions = \ - self._get_stt_from_file(wav_file_path, lang) + with self._stopwatch: + _, parser_data, transcriptions = \ + self._get_stt_from_file(wav_file_path, lang) message.context["audio_parser_data"] = parser_data context = build_context(message) + context['timing']['get_stt'] = self._stopwatch.time data = { "utterances": transcriptions, "lang": message.data.get("lang", "en-us") diff --git a/requirements/docker.txt b/requirements/docker.txt index 37f32e8..bb0aae8 100644 --- a/requirements/docker.txt +++ b/requirements/docker.txt @@ -1,5 +1,7 @@ ovos-stt-plugin-vosk~=0.1 neon-stt-plugin-nemo~=0.0.2 +onnxruntime!=1.16.0 # TODO: Patching https://github.com/microsoft/onnxruntime/issues/17631 + # Load alternative WW plugins so they are available ovos-ww-plugin-pocketsphinx~=0.1 ovos-ww-plugin-precise-lite~=0.1 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index c65553f..c9f6b97 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,4 +1,4 @@ -ovos-dinkum-listener~=0.0.2 +ovos-dinkum-listener==0.0.3a16 ovos-bus-client~=0.0.3 ovos-utils~=0.0.30 ovos-plugin-manager~=0.0.23 @@ -8,4 +8,5 @@ neon-utils[network,audio]~=1.6 ovos-config~=0.0.7 ovos-vad-plugin-webrtcvad~=0.0.1 -ovos-ww-plugin-vosk~=0.1 \ No newline at end of file +ovos-ww-plugin-vosk~=0.1 +ovos-microphone-plugin-alsa~=0.0.0 \ No newline at end of file diff --git a/requirements/test_requirements.txt b/requirements/test_requirements.txt index ea60ae7..94bb8f2 100644 --- a/requirements/test_requirements.txt +++ b/requirements/test_requirements.txt @@ -5,4 +5,5 @@ ovos-stt-plugin-server~=0.0.3 pytest mock~=4.0 pydub~=0.23 -SpeechRecognition~=3.8 \ No newline at end of file +SpeechRecognition~=3.8 +onnxruntime!=1.16.0 # TODO: Patching https://github.com/microsoft/onnxruntime/issues/17631 diff --git a/version.py b/version.py index 085223d..de7eb74 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "4.1.0" +__version__ = "4.2.0"