Skip to content

Commit

Permalink
train
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Apr 11, 2022
1 parent 4a356d4 commit 172f119
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mycroft/skills/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready,

# Connect this process to the Mycroft message bus
bus = start_message_bus_client("SKILLS")
_register_intent_services(bus)
intentservice = _register_intent_services(bus)
event_scheduler = EventScheduler(bus, autostart=False)
event_scheduler.daemon = True
event_scheduler.start()
Expand All @@ -68,6 +68,7 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready,

wait_for_exit_signal()

intentservice.shutdown()
shutdown(skill_manager, event_scheduler)


Expand Down
11 changes: 11 additions & 0 deletions mycroft/skills/intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def __init__(self, bus):

self.bus.on('recognizer_loop:utterance', self.handle_utterance)
self.bus.on('mycroft.skills.loaded', self.update_skill_name_dict)
self.bus.on('mycroft.skills.initialized', self.handle_train)

def shutdown(self):
self.bus.remove('recognizer_loop:utterance', self.handle_utterance)
self.bus.remove('mycroft.skills.loaded', self.update_skill_name_dict)
self.bus.remove('mycroft.skills.initialized', self.handle_train)

def load_intent_services(self):
config = Configuration.get().get("intentBox", {})
Expand Down Expand Up @@ -97,6 +103,11 @@ def get_skill_name(self, skill_id):
return self.skill_names.get(skill_id, skill_id)

# intent matching
def handle_train(self, message):
for engine in self.services:
engine.train()
self.bus.emit(message.reply('mycroft.skills.trained'))

def _match_intents(self, utterances, lang, message, converse=False, fallback=False):
message.data["utterances"] = utterances
message.data["lang"] = lang
Expand Down
5 changes: 4 additions & 1 deletion mycroft/skills/intent_services/fallback_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
from mycroft.configuration import Configuration
from ovos_plugin_manager.intents import IntentMatch, IntentPriority, IntentEngine
from mycroft.messagebus.message import get_message_lang
from ovos_plugin_manager.intents import IntentMatch, IntentPriority, IntentEngine

FallbackRange = namedtuple('FallbackRange', ['start', 'stop'])


class FallbackService:
class FallbackService(IntentEngine):
"""Intent Service handling fallback skills."""

def __init__(self, bus):
config = Configuration.get().get("skills", {}).get("fallback") or {}
super().__init__("ovos.intentbox.fallback", bus=bus, config=config)
self.bus = bus

def _fallback_range(self, utterances, lang, message, fb_range):
Expand Down

0 comments on commit 172f119

Please sign in to comment.