1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # This is part of Kaylee
- # -- this code is licensed GPLv3
- # Copyright 2015-2016 Clayton G. Hobbs
- # Portions Copyright 2013 Jezra
-
- from gi.repository import GObject
-
-
- class PluginBase(GObject.Object):
- """Base class for Kaylee plugins
-
- Each Kaylee plugin module must define a subclass of this class, named
- ``Plugin``.
- """
-
- __gsignals__ = {
- 'processed' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
- (GObject.TYPE_STRING,)),
- 'tts' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
- (GObject.TYPE_STRING,))
- }
-
- def __init__(self, config, name):
- """Initialize the plugin
-
- All strings to be included in the corpus should be elements of
- ``corpus_strings`` by the end of __init__'s execution. Note however
- that the words required for number support are automatically included,
- so they need not be listed explicitly on a per-plugin basis.
- """
- super().__init__()
- self.config = config
- self.name = name
- self.options = config.plugins[name]
- self.corpus_strings = set()
-
- def recognizer_finished(self, recognizer, text):
- """Process a recognized voice command
-
- This method must return True if the command was handled by the plugin,
- and False otherwise. As soon as it has been determined that the
- command will be handled, this method must emit a ``processed`` signal
- with ``text`` as its parameter. If the plugin wants to speak some
- words to the user, it can do so by emitting a ``tts`` signal with the
- words to be spoken as its parameter.
- """
- return False
|