# 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 . import PluginBase, Handler 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 get_handler(self, text): """Return a handler if and only if the phrase is heard""" if text == self.options['phrase']: return SimpleHandler(1, text) else: return None class SimpleHandler(Handler): """Handler for the simple plugin""" def __init__(self, confidence, text): """Store the phrase that was heard""" super().__init__(confidence) self.text = text def __call__(self, tts): """Print and speak the phrase""" print("Simple plugin says:", self.text) tts(self.text)