Merge pull request #228 from jasonehines/speak-skill

Speak skill
pull/269/head
Arron Atchison 2016-06-23 16:13:10 -05:00 committed by GitHub
commit 8fa6d0a2d9
3 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,57 @@
# Copyright 2016 Mycroft AI, Inc.
#
# This file is part of Mycroft Core.
#
# Mycroft Core is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mycroft Core is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.
from os.path import dirname, join
from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill
__author__ = 'jasonehines'
# TODO - Localization
class SpeakSkill(MycroftSkill):
def __init__(self):
super(SpeakSkill, self).__init__(name="SpeakSkill")
def initialize(self):
self.load_vocab_files(join(dirname(__file__), 'vocab', 'en-us'))
prefixes = [
'speak', 'say', 'repeat']
self.__register_prefixed_regex(prefixes, "(?P<Words>.*)")
intent = IntentBuilder("SpeakIntent").require(
"SpeakKeyword").require("Words").build()
self.register_intent(intent, self.handle_speak_intent)
def __register_prefixed_regex(self, prefixes, suffix_regex):
for prefix in prefixes:
self.register_regex(prefix + ' ' + suffix_regex)
def handle_speak_intent(self, message):
words = message.metadata.get("Words")
self.speak(words)
def stop(self):
pass
def create_skill():
return SpeakSkill()

View File

@ -0,0 +1,8 @@
{
"utterance": "Speak Hello Jason",
"intent_type": "SpeakIntent",
"intent": {
"SpeakKeyword": "speak",
"Words": "hello jason"
}
}

View File

@ -0,0 +1,3 @@
speak
say
repeat