1234567891011121314151617181920212223242526272829303132333435363738 |
- # This is part of Kaylee
- # -- this code is licensed GPLv3
- # Copyright 2015-2017 Clayton G. Hobbs
- # Portions Copyright 2013 Jezra
-
- """A simple plugin to serve as an example
-
- This is an extremely minimal Kaylee plugin to serve as an example for
- developing more complex plugins. It takes a single configuration
- option, "phrase", which is a sentence to be recognized. Once this is
- heard, the plugin prints "Simple plugin says: [phrase]".
- """
-
- from .pluginbase import PluginBase
-
-
- class Plugin(PluginBase):
- """Main class for the simple plugin"""
-
- def __init__(self, config, name):
- """Initialize the simple plugin"""
- super().__init__(config, name)
-
- self.corpus_strings.add(self.options['phrase'])
-
- def confidence(self, text):
- """Return 0 if text is not the phrase, 1 if it is"""
- return 1 if text == self.options['phrase'] else 0
-
- def handle(self, text):
- """Print and speak the phrase"""
- # Is there a matching command?
- if self.confidence(text):
- print("Simple plugin says:", text)
- self.emit('tts', text)
- return True
- else:
- return False
|