Skip to content

Commit b695854

Browse files
committed
feat/g2p_plugins (#21)
1 parent 1b7d8b5 commit b695854

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

ovos_plugin_manager/g2p.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from ovos_plugin_manager.utils import load_plugin, find_plugins, PluginTypes
22
from ovos_plugin_manager.templates.g2p import Grapheme2PhonemePlugin, PhonemeAlphabet
3+
from ovos_utils.log import LOG
4+
from ovos_utils.configuration import read_mycroft_config
35

46

57
def find_g2p_plugins():
@@ -13,7 +15,7 @@ def load_g2p_plugin(module_name):
1315
class OVOSG2PFactory:
1416
""" replicates the base mycroft class, but uses only OPM enabled plugins"""
1517
MAPPINGS = {
16-
"cmudict": "ovos-g2p-plugin-cmudict",
18+
"dummy": "ovos-g2p-plugin-dummy",
1719
"phoneme_guesser": "neon-g2p-plugin-phoneme-guesser",
1820
"gruut": "neon-g2p-plugin-gruut"
1921
}
@@ -30,9 +32,9 @@ def get_class(config=None):
3032
}
3133
"""
3234
config = config or get_g2p_config()
33-
g2p_module = config.get("module") or 'cmudict'
34-
if g2p_module == 'cmudict':
35-
return G2P
35+
g2p_module = config.get("module") or 'dummy'
36+
if g2p_module == 'dummy':
37+
return Grapheme2PhonemePlugin
3638
if g2p_module in OVOSG2PFactory.MAPPINGS:
3739
g2p_module = OVOSG2PFactory.MAPPINGS[g2p_module]
3840
return load_g2p_plugin(g2p_module)
@@ -49,12 +51,11 @@ def create(config=None):
4951
}
5052
"""
5153
g2p_config = get_g2p_config(config)
52-
g2p_module = g2p_config.get('module', 'cmudict')
54+
g2p_module = g2p_config.get('module', 'dummy')
5355
try:
5456
clazz = OVOSG2PFactory.get_class(g2p_config)
5557
LOG.info(f'Found plugin {g2p_module}')
56-
g2p = clazz(g2p_lang, g2p_config)
57-
g2p.validator.validate()
58+
g2p = clazz(g2p_config)
5859
LOG.info(f'Loaded plugin {g2p_module}')
5960
except Exception:
6061
LOG.exception('The selected G2P plugin could not be loaded.')
@@ -66,7 +67,7 @@ def get_g2p_config(config=None):
6667
config = config or read_mycroft_config()
6768
if "g2p" in config:
6869
config = config["g2p"]
69-
g2p_module = config.get('module', 'cmudict')
70+
g2p_module = config.get('module', 'dummy')
7071
g2p_config = config.get(g2p_module, {})
7172
g2p_config["module"] = g2p_module
7273
return g2p_config

ovos_plugin_manager/templates/tts.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ class TTS:
203203
def __init__(self, lang="en-us", config=None, validator=None,
204204
audio_ext='wav', phonetic_spelling=True, ssml_tags=None):
205205
self.log_timestamps = False
206-
if not config:
207-
try:
208-
config_core = read_mycroft_config() or {}
209-
except FileNotFoundError:
210-
config_core = {}
211-
config = config_core.get("tts", {})
212-
config["lang"] = config_core.get("lang")
206+
207+
try:
208+
config_core = read_mycroft_config() or {}
209+
except FileNotFoundError:
210+
config_core = {}
211+
212+
config = config or config_core.get("tts", {})
213+
config["lang"] = config.get("lang") or config_core.get("lang")
213214

214215
self.stopwatch = Stopwatch()
215216
self.tts_name = self.__class__.__name__

0 commit comments

Comments
 (0)