Somewhat fancy voice command recognition software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

simple.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  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. """A simple plugin to serve as an example
  6. This is an extremely minimal Kaylee plugin to serve as an example for
  7. developing more complex plugins. It takes a single configuration
  8. option, "phrase", which is a sentence to be recognized. Once this is
  9. heard, the plugin prints "Simple plugin says: [phrase]".
  10. """
  11. from .pluginbase import PluginBase
  12. class Plugin(PluginBase):
  13. """Main class for the simple plugin"""
  14. def __init__(self, config, name):
  15. """Initialize the simple plugin"""
  16. super().__init__(config, name)
  17. self.corpus_strings.add(self.options['phrase'])
  18. def recognizer_finished(self, recognizer, text):
  19. """Print and speak the phrase when it is heard"""
  20. # Is there a matching command?
  21. if text == self.options['phrase']:
  22. self.emit('processed', text)
  23. print("Simple plugin says:", text)
  24. self.emit('tts', text)
  25. return True
  26. else:
  27. return False