Somewhat fancy voice command recognition software
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

simple.py 1.0KB

12345678910111213141516171819202122232425262728293031323334
  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 the phrase when it is spoken"""
  20. # Is there a matching command?
  21. if text == self.options['phrase']:
  22. self.emit('processed', text)
  23. print("Simple plugin says:", text)
  24. return True
  25. else:
  26. return False