Somewhat fancy voice command recognition software
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

pluginbase.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.corpus_strings = set()
  26. def recognizer_finished(self, recognizer, text):
  27. """Process a recognized voice command
  28. This method must return True if the command was handled by the plugin,
  29. and False otherwise. As soon as it has been determined that the
  30. command will be handled, this method must emit a ``processed`` signal
  31. with ``text`` as its parameter.
  32. """
  33. return False