Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Issues/122 (#220)
Browse files Browse the repository at this point in the history
* added mouth spelling

* spell word after talking

* removed speech to test

* test

* re-added speech

* used emitter

* mycroft/skills/spelling/__init__.py

* emitters 102: intermediate emitters

* emitters 103: importing the right method

* trying enclosure methods

* more fixing

* sorry slack

* added brief pause

* added api listener method

* fixed syntax

* further edited syntax

* slightly changed syntax

* added brief pause before listener reactivation

* changed ordering

* testing method

* further tests

* test test test

* logger

* further logger

* altered logic

* i really need to fork

* more debug

* changed boolean logic

* more debug

* fixed it??

* added brief pause again

* final commit

* test

* test

* fixed it

* sleep

* more testing

* stuff

* added constants:

* pep8
  • Loading branch information
isaacnward authored and ethanaward committed Jun 22, 2016
1 parent df2cb5f commit 083bda8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mycroft/client/enclosure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ def mouth_smile(self):
def mouth_text(self, text=""):
self.client.emit(
Message("enclosure.mouth.text", metadata={'text': text}))

def activate_mouth_listeners(self, active):
msg = Message('enclosure.mouth.listeners', metadata={'active': active})
self.client.emit(msg)
11 changes: 9 additions & 2 deletions mycroft/client/enclosure/enclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from mycroft.messagebus.message import Message
from mycroft.util import kill
from mycroft.util.log import getLogger
from mycroft.skills.volume import VolumeSkill

__author__ = 'aatchison + jdorleans'

Expand Down Expand Up @@ -171,8 +170,17 @@ def __init_serial(self):

def __register_events(self):
self.client.on('mycroft.paired', self.__update_events)
self.client.on('enclosure.mouth.listeners', self.__mouth_listeners)
self.__register_mouth_events()

def __mouth_listeners(self, event=None):
if event and event.metadata:
active = event.metadata['active']
if active:
self.__register_mouth_events()
else:
self.__remove_mouth_events()

def __register_mouth_events(self):
self.client.on('recognizer_loop:record_begin', self.mouth.listen)
self.client.on('recognizer_loop:record_end', self.mouth.reset)
Expand All @@ -186,7 +194,6 @@ def __remove_mouth_events(self):
self.mouth.talk)
self.client.remove('recognizer_loop:audio_output_end',
self.mouth.reset)
self.mouth.reset()

def __update_events(self, event=None):
if event and event.metadata:
Expand Down
11 changes: 11 additions & 0 deletions mycroft/skills/spelling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from os.path import dirname, join

import time

from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill

Expand All @@ -26,6 +28,9 @@

# TODO - Localization
class SpellingSkill(MycroftSkill):
SEC_PER_LETTER = 5.0 / 7.0
LETTERS_PER_SCREEN = 7.0

def __init__(self):
super(SpellingSkill, self).__init__(name="SpellingSkill")

Expand All @@ -46,8 +51,14 @@ def __register_prefixed_regex(self, prefixes, suffix_regex):

def handle_intent(self, message):
word = message.metadata.get("Word")
self.emitter.once("recognizer_loop:audio_output_start",
self.enclosure.mouth_text(word))
spelled_word = ', '.join(word).lower()
self.enclosure.activate_mouth_listeners(False)
self.speak(spelled_word)
time.sleep((self.LETTERS_PER_SCREEN + len(word)) * self.SEC_PER_LETTER)
self.enclosure.activate_mouth_listeners(True)
self.enclosure.mouth_reset()

def stop(self):
pass
Expand Down

0 comments on commit 083bda8

Please sign in to comment.