From 1722bf45e1d6f05a1800fef11185553a5404c6ea Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Thu, 9 May 2024 05:11:49 +0100 Subject: [PATCH] feat/improve_legacy_support (#63) * feat/improve_legacy_support better readme + expose ocp flag to config * only log warning if old OCP is loaded, not if legacy bus api is enabled * legacy plugins config --- README.md | 58 +++++++++++++++++++++++++++++++++++-------- ovos_audio/service.py | 11 +++++--- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9e5dfc5..7402e83 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Handles TTS generation and sounds playback plugins. Without `extras`, you will also need to manually install, -and possibly configure TTS and Audio Backend modules as described below. +and possibly configure TTS modules as described below. # Configuration @@ -20,16 +20,11 @@ under mycroft.conf { // Text to Speech parameters - // Override: REMOTE "tts": { - "pulse_duck": false, - "module": "ovos-tts-plugin-mimic3-server", + "module": "ovos-tts-plugin-server", "fallback_module": "ovos-tts-plugin-mimic", "ovos-tts-plugin-mimic": { "voice": "ap" - }, - "ovos-tts-plugin-mimic3-server": { - "voice": "en_UK/apope_low" } }, @@ -42,15 +37,56 @@ under mycroft.conf }, // Mechanism used to play WAV audio files - // Override: SYSTEM "play_wav_cmdline": "paplay %1 --stream-name=mycroft-voice", // Mechanism used to play MP3 audio files - // Override: SYSTEM "play_mp3_cmdline": "mpg123 %1", // Mechanism used to play OGG audio files - // Override: SYSTEM "play_ogg_cmdline": "ogg123 -q %1" } -``` \ No newline at end of file +``` + +## Using Legacy AudioService + +The legacy audio service supports audio playback via the old mycroft api ([@mycroft](https://github.com/MycroftAI/mycroft-core/blob/dev/mycroft/skills/audioservice.py#L43) [@ovos](https://github.com/OpenVoiceOS/ovos-bus-client/blob/dev/ovos_bus_client/apis/ocp.py#L51)) + +by default OCP acts as a translation layer for this api and no action is needed, but if you want to disable ocp this api remains available + +> **NOTE:** once ovos-media is released OCP and this api will be disabled by default and deprecated! + +```javascript +{ + "enable_old_audioservice": true, + "disable_ocp": true, + "Audio": { + "default-backend": "vlc", + "backends": { + "simple": { + "type": "ovos_audio_simple", + "active": true + }, + "vlc": { + "type": "ovos_vlc", + "active": true + } + } + } + }, +} +``` + +legacy plugins: +- [ocp](https://github.com/OpenVoiceOS/ovos-ocp-audio-plugin) +- [vlc](https://github.com/OpenVoiceOS/ovos-vlc-plugin) +- [simple](https://github.com/OpenVoiceOS/ovos-audio-plugin-simple) (no https support) + +**OCP technical details:** + +- OCP was developed for mycroft-core under this legacy system +- OCP will pose as a legacy plugin and translate the received bus events to the [OCP api](https://github.com/OpenVoiceOS/ovos-bus-client/blob/dev/ovos_bus_client/apis/ocp.py#L228) +- OCP is **always** the default audio plugin, unless you set `"disable_ocp": true` in config +- OCP uses the legacy api internally, to delegate playback when GUI is not available (or configured to do so) +- this does **NOT** bring support for old Mycroft CommonPlay skills, that is related to skills service not ovos-audio +- this brings support for [OCP skills](https://openvoiceos.github.io/ovos-technical-manual/OCP_skills) to OVOS until [ovos-media](https://github.com/OpenVoiceOS/ovos-media) is finished +- [ovos-media](https://github.com/OpenVoiceOS/ovos-media) will fully replace OCP in **ovos-audio 0.2.0** diff --git a/ovos_audio/service.py b/ovos_audio/service.py index 110e928..a941bdd 100644 --- a/ovos_audio/service.py +++ b/ovos_audio/service.py @@ -54,7 +54,7 @@ class PlaybackService(Thread): 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, - bus=None, disable_ocp=False, validate_source=True): + bus=None, disable_ocp=None, validate_source=True): super(PlaybackService, self).__init__() LOG.info("Starting Audio Service") @@ -97,6 +97,9 @@ def __init__(self, ready_hook=on_ready, error_hook=on_error, self.audio = None self.audio_enabled = self.config.get("enable_old_audioservice", True) # TODO default to False soon + if disable_ocp is None: + disable_ocp = self.config.get("disable_ocp", False) # TODO default to True soon + self.disable_ocp = disable_ocp if self.audio_enabled: try: self.audio = AudioService(self.bus, disable_ocp=disable_ocp, validate_source=validate_source) @@ -243,8 +246,10 @@ def handle_opm_audio_query(self, message): def run(self): self.status.set_alive() if self.audio_enabled: - LOG.warning("audio service has moved to ovos-media, if you already migrated to ovos-media " - 'set "enable_old_audioservice": false in mycroft.conf') + LOG.info("Legacy AudioService enabled") + if not self.disable_ocp: + LOG.warning("OCP has moved to ovos-media, if you already migrated to ovos-media " + 'set "disable_ocp": true in mycroft.conf') if self.audio.wait_for_load(): if len(self.audio.service) == 0: LOG.warning('No audio backends loaded! '