From cf5bace8c6f4cb24285dce2a244dcef8b292504c Mon Sep 17 00:00:00 2001
From: j1nx
Date: Thu, 10 Feb 2022 20:26:32 +0100
Subject: [PATCH] Bump ovos-plugin-manager and test PR27
---
.../0001-fail-earlier.patch | 111 ++++++++++++++++++
.../python-ovos-plugin-manager.hash | 2 +-
.../python-ovos-plugin-manager.mk | 2 +-
3 files changed, 113 insertions(+), 2 deletions(-)
create mode 100644 buildroot-external/package/python-ovos-plugin-manager/0001-fail-earlier.patch
diff --git a/buildroot-external/package/python-ovos-plugin-manager/0001-fail-earlier.patch b/buildroot-external/package/python-ovos-plugin-manager/0001-fail-earlier.patch
new file mode 100644
index 00000000..81b0d5e0
--- /dev/null
+++ b/buildroot-external/package/python-ovos-plugin-manager/0001-fail-earlier.patch
@@ -0,0 +1,111 @@
+From 304e4972c4f515bf9cd8ec5df99cab73d2e9fc31 Mon Sep 17 00:00:00 2001
+From: jarbasai
+Date: Wed, 9 Feb 2022 23:17:22 +0000
+Subject: [PATCH 1/3] fail earlier
+
+---
+ ovos_plugin_manager/templates/tts.py | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/ovos_plugin_manager/templates/tts.py b/ovos_plugin_manager/templates/tts.py
+index 558e341..9dd11a0 100644
+--- a/ovos_plugin_manager/templates/tts.py
++++ b/ovos_plugin_manager/templates/tts.py
+@@ -115,7 +115,7 @@ def _play(self):
+ except Empty:
+ pass
+ except Exception as e:
+- LOG.exception(e)
++ LOG.exception(f"TTS execution failed: {e}")
+ if self._processing_queue:
+ self.on_end(listen)
+ self._now_playing = None
+@@ -503,7 +503,11 @@ def _synth(self, sentence, sentence_hash=None, **kwargs):
+ and k not in ["sentence", "wav_file"]}
+
+ # finally do the TTS synth
+- audio.path, phonemes = self.get_tts(sentence, str(audio), **kwargs)
++ path, phonemes = self.get_tts(sentence, str(audio), **kwargs)
++ if not path:
++ self.add_metric({"metric_type": "tts.synth.failed"})
++ raise FileNotFoundError("TTS synth failed, no audio to playback")
++ audio.path = path
+ self.add_metric({"metric_type": "tts.synth.finished"})
+ # cache sentence + phonemes
+ self._cache_sentence(sentence, audio, phonemes, sentence_hash)
+
+From 681ade0adbee56f55790fd965284c2ffde650a77 Mon Sep 17 00:00:00 2001
+From: jarbasai
+Date: Thu, 10 Feb 2022 00:02:38 +0000
+Subject: [PATCH 2/3] debug logs for cache paths
+
+---
+ ovos_plugin_manager/templates/tts.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/ovos_plugin_manager/templates/tts.py b/ovos_plugin_manager/templates/tts.py
+index 9dd11a0..423daab 100644
+--- a/ovos_plugin_manager/templates/tts.py
++++ b/ovos_plugin_manager/templates/tts.py
+@@ -241,6 +241,8 @@ def __init__(self, lang="en-us", config=None, validator=None,
+ self.cache = TextToSpeechCache(
+ self.config, tts_id, self.audio_ext
+ )
++ LOG.debug(f"{self.tts_name} persistent cache: {self.cache.persistent_cache_dir}")
++ LOG.debug(f"{self.tts_name} temporary cache: {self.cache.temporary_cache_dir}")
+ self.cache.curate()
+ self.g2p = OVOSG2PFactory.create(config_core)
+ self.add_metric({"metric_type": "tts.init"})
+
+From 47cadef2aa61474f64b33b87cb084123446bfd20 Mon Sep 17 00:00:00 2001
+From: jarbasai
+Date: Thu, 10 Feb 2022 00:15:24 +0000
+Subject: [PATCH 3/3] plugin mapping improvements (and moar logs!)
+
+---
+ ovos_plugin_manager/tts.py | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/ovos_plugin_manager/tts.py b/ovos_plugin_manager/tts.py
+index 1614575..e2d17f9 100644
+--- a/ovos_plugin_manager/tts.py
++++ b/ovos_plugin_manager/tts.py
+@@ -16,6 +16,7 @@ def load_tts_plugin(module_name):
+ Returns:
+ class: found tts plugin class
+ """
++ module_name = OVOSTTSFactory.get_equivalent_plugin(module_name) or module_name
+ return load_plugin(module_name, PluginTypes.TTS)
+
+
+@@ -55,10 +56,16 @@ def get_class(config=None):
+ tts_module = config.get("module") or "dummy"
+ if tts_module == "dummy":
+ return TTS
+- if tts_module in OVOSTTSFactory.MAPPINGS:
+- tts_module = OVOSTTSFactory.MAPPINGS[tts_module]
+ return load_tts_plugin(tts_module)
+
++ @staticmethod
++ def get_equivalent_plugin(tts_module):
++ if tts_module in OVOSTTSFactory.MAPPINGS:
++ plug = OVOSTTSFactory.MAPPINGS[tts_module]
++ LOG.debug(f"tts module {tts_module} mapped to plugin {plug}")
++ return plug
++ return None
++
+ @staticmethod
+ def create(config=None):
+ """Factory method to create a TTS engine based on configuration.
+@@ -71,8 +78,10 @@ def create(config=None):
+ }
+ """
+ tts_config = get_tts_config(config)
+- tts_lang = tts_config["lang"]
++ tts_lang = tts_config.get("lang", "en-us")
+ tts_module = tts_config.get('module', 'mimic')
++ tts_module = OVOSTTSFactory.get_equivalent_plugin(tts_module) or tts_module
++ tts_config["module"] = tts_module # avoid a re-read of mappings
+ try:
+ clazz = OVOSTTSFactory.get_class(tts_config)
+ LOG.info(f'Found plugin {tts_module}')
diff --git a/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.hash b/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.hash
index 75cb20bd..16b90781 100644
--- a/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.hash
+++ b/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.hash
@@ -1 +1 @@
-sha256 5af0cdc91b39a584c4334fce8185eb10435e42369b3daa3c5b4b12968fb48c1b python-ovos-plugin-manager-4105e7633a8697c153091345a60ed06733f19777.tar.gz
+sha256 04d3a5bd1385e1767ca1daba5165cf596a3bafc725df18acd8b4406df73c0dc3 python-ovos-plugin-manager-4a1b4521f156a35c4b80b429566b2e4f76c6000c.tar.gz
diff --git a/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.mk b/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.mk
index b3258a01..6a27af0f 100644
--- a/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.mk
+++ b/buildroot-external/package/python-ovos-plugin-manager/python-ovos-plugin-manager.mk
@@ -4,7 +4,7 @@
#
################################################################################
-PYTHON_OVOS_PLUGIN_MANAGER_VERSION = 4105e7633a8697c153091345a60ed06733f19777
+PYTHON_OVOS_PLUGIN_MANAGER_VERSION = 4a1b4521f156a35c4b80b429566b2e4f76c6000c
PYTHON_OVOS_PLUGIN_MANAGER_SITE = $(call github,OpenVoiceOS,OVOS-plugin-manager,$(PYTHON_OVOS_PLUGIN_MANAGER_VERSION))
PYTHON_OVOS_PLUGIN_MANAGER_SETUP_TYPE = setuptools
PYTHON_OVOS_PLUGIN_MANAGER_LICENSE_FILES = LICENSE