|
@@ -2,6 +2,7 @@ import logging
|
|
|
import os
|
|
|
from cffi import FFI as _FFI
|
|
|
|
|
|
+from core.Utils import Utils
|
|
|
from core.ConfigurationManager import SettingLoader
|
|
|
|
|
|
logging.basicConfig()
|
|
@@ -28,36 +29,14 @@ class OrderListener:
|
|
|
|
|
|
def load_stt_plugin(self):
|
|
|
if self.stt is None:
|
|
|
- self.stt = self.settings.default_stt_name
|
|
|
+ self.stt_module_name = self.settings.default_stt_name
|
|
|
|
|
|
for stt_object in self.settings.stts:
|
|
|
- if stt_object.name == self.stt:
|
|
|
- stt_args = stt_object.parameters
|
|
|
-
|
|
|
- # capitalizes the first letter (because classes have first letter upper case)
|
|
|
- default_stt_plugin = self.stt.capitalize()
|
|
|
- self._run_stt_plugin(default_stt_plugin, stt_args)
|
|
|
-
|
|
|
- def _run_stt_plugin(self, stt_plugin, parameters=None):
|
|
|
- """
|
|
|
- Dynamic loading of a STT module
|
|
|
- :param stt_plugin: Module name to load
|
|
|
- :param parameters: Parameter of the module
|
|
|
- :return:
|
|
|
- """
|
|
|
- logger.debug("Running STT %s with parameter %s" % (stt_plugin, parameters))
|
|
|
- mod = __import__('stt', fromlist=[stt_plugin])
|
|
|
-
|
|
|
- klass = getattr(mod, stt_plugin)
|
|
|
-
|
|
|
- if klass is not None:
|
|
|
- # run the plugin
|
|
|
- if not parameters:
|
|
|
- klass(self.callback)
|
|
|
- elif isinstance(parameters, dict):
|
|
|
- klass(self.callback, **parameters)
|
|
|
- else:
|
|
|
- klass(self.callback, parameters)
|
|
|
+ if stt_object.name == self.stt_module_name:
|
|
|
+ stt_object.parameters["callback"] = self.callback
|
|
|
+ Utils.get_dynamic_class_instantiation('stt',
|
|
|
+ stt_object.name.capitalize(),
|
|
|
+ parameters=stt_object.parameters)
|
|
|
|
|
|
@staticmethod
|
|
|
def _ignore_stderr():
|