Somewhat fancy voice command recognition software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pluginbase.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # This is part of Kaylee
  2. # -- this code is licensed GPLv3
  3. # Copyright 2015-2016 Clayton G. Hobbs
  4. # Portions Copyright 2013 Jezra
  5. from gi.repository import GObject
  6. class PluginBase(GObject.Object):
  7. """Base class for Kaylee plugins
  8. Each Kaylee plugin module must define a subclass of this class, named
  9. ``Plugin``.
  10. """
  11. __gsignals__ = {
  12. 'processed' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
  13. (GObject.TYPE_STRING,))
  14. }
  15. def __init__(self, config, name):
  16. """Initialize the plugin
  17. All strings to be included in the corpus should be elements of
  18. ``corpus_strings`` by the end of __init__'s execution. Note however
  19. that the words required for number support are automatically included,
  20. so they need not be listed explicitly on a per-plugin basis.
  21. """
  22. super().__init__()
  23. self.config = config
  24. self.name = name
  25. self.options = config.plugins[name]
  26. self.corpus_strings = set()
  27. def recognizer_finished(self, recognizer, text):
  28. """Process a recognized voice command
  29. This method must return True if the command was handled by the plugin,
  30. and False otherwise. As soon as it has been determined that the
  31. command will be handled, this method must emit a ``processed`` signal
  32. with ``text`` as its parameter.
  33. """
  34. return False