Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #1566 #37

Open
wants to merge 2 commits into
base: 20.08
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@

from adapt.intent import IntentBuilder
from mycroft.messagebus.message import Message
from mycroft.skills.core import MycroftSkill, intent_handler, intent_file_handler
from mycroft.skills.core import FallbackSkill, intent_handler, intent_file_handler
from mycroft.skills.skill_data import read_vocab_file


class StopSkill(MycroftSkill):
class StopSkill(FallbackSkill):
def __init__(self):
super().__init__(name="StopSkill")

@intent_handler(IntentBuilder("").require("Stop"))
def initialize(self):
self.register_fallback(self.handle_fallback, 50)
self.stopwords = read_vocab_file(self.find_resource('Stop.voc', 'vocab'))

def handle_fallback(self, message):
utt = message.data.get('utterance').lower()
if [utt] in self.stopwords:
self.handle_stop(None)
return True
return False

def handle_stop(self, event):
# Framework catches this, invokes stop() method on all skills
self.bus.emit(Message("mycroft.stop"))
Expand Down Expand Up @@ -53,5 +64,9 @@ def handle_ssh_enable(self, event):
def handle_ssh_disable(self, event):
self.bus.emit(Message("system.ssh.disable"))

def shutdown(self):
self.remove_fallback(self.handle_fallback)
super(StopSkill, self).shutdown()

def create_skill():
return StopSkill()
7 changes: 4 additions & 3 deletions vocab/de-de/Stop.voc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Stop
Ruhe
halt den Mund
stop
ruhe
halt den mund
sei leise
ruhe bitte
4 changes: 3 additions & 1 deletion vocab/en-us/Stop.voc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
stop
silence
shut up
be quiet
be quiet
please stop
quiet please