1234567891011121314151617181920212223242526272829303132333435 |
- # This is part of Kaylee
- # -- this code is licensed GPLv3
- # Copyright 2015-2016 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 recognizer_finished(self, recognizer, text):
- """Print the phrase when it is spoken"""
- # Is there a matching command?
- if text == self.options['phrase']:
- self.emit('processed', text)
- print("Simple plugin says:", text)
- self.emit('tts', text)
- return True
- else:
- return False
|