Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
Issues 356 - Rebasing with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan D'Orleans committed Dec 17, 2016
1 parent 14c6eae commit 4c1ba4e
Show file tree
Hide file tree
Showing 31 changed files with 227 additions and 359 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ These are the keys currently in use in Mycroft Core.

## Configuration
Mycroft configuration consists of 3 possible config files.
- `mycroft-core/mycroft/configuration/mycroft.ini`
- `/etc/mycroft/mycroft.ini`
- `$HOME/.mycroft/mycroft.ini`
- `mycroft-core/mycroft/configuration/mycroft.conf`
- `/etc/mycroft/mycroft.conf`
- `$HOME/.mycroft/mycroft.conf`

When the configuration loader starts, it looks in those locations in that order, and loads ALL configuration. Keys that exist in multiple config files will be overridden by the last file to contain that config value. This results in a minimal amount of config being written for a specific device/user, without modifying the distribution files.

Expand Down
2 changes: 1 addition & 1 deletion mycroft-base-MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
recursive-include mycroft/client/speech/model *
include requirements.txt
include mycroft/configuration/*.ini
include mycroft/configuration/*.conf
recursive-include mycroft/skills/*/dialog *
recursive-include mycroft/skills/*/vocab *
recursive-include mycroft/skills/*/regex *
Expand Down
37 changes: 15 additions & 22 deletions mycroft/client/enclosure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def system_unmute(self):
self.client.emit(Message("enclosure.system.unmute"))

def system_blink(self, times):
self.client.emit(
Message("enclosure.system.blink", {'times': times}))
self.client.emit(Message("enclosure.system.blink", {'times': times}))

def eyes_on(self):
self.client.emit(Message("enclosure.eyes.on"))
Expand All @@ -54,34 +53,30 @@ def eyes_off(self):
self.client.emit(Message("enclosure.eyes.off"))

def eyes_blink(self, side):
self.client.emit(
Message("enclosure.eyes.blink", {'side': side}))
self.client.emit(Message("enclosure.eyes.blink", {'side': side}))

def eyes_narrow(self):
self.client.emit(Message("enclosure.eyes.narrow"))

def eyes_look(self, side):
self.client.emit(
Message("enclosure.eyes.look", {'side': side}))
self.client.emit(Message("enclosure.eyes.look", {'side': side}))

def eyes_color(self, r=255, g=255, b=255):
self.client.emit(
Message("enclosure.eyes.color", {'r': r, 'g': g, 'b': b}))
self.client.emit(Message("enclosure.eyes.color",
{'r': r, 'g': g, 'b': b}))

def eyes_brightness(self, level=30):
self.client.emit(
Message("enclosure.eyes.level", {'level': level}))
self.client.emit(Message("enclosure.eyes.level", {'level': level}))

def eyes_reset(self):
self.client.emit(Message("enclosure.eyes.reset"))

def eyes_timed_spin(self, length):
self.client.emit(
Message("enclosure.eyes.timedspin", {'length': length}))
self.client.emit(Message("enclosure.eyes.timedspin",
{'length': length}))

def eyes_volume(self, volume):
self.client.emit(
Message("enclosure.eyes.volume", {'volume': volume}))
self.client.emit(Message("enclosure.eyes.volume", {'volume': volume}))

def mouth_reset(self):
self.client.emit(Message("enclosure.mouth.reset"))
Expand All @@ -98,18 +93,16 @@ def mouth_listen(self):
def mouth_smile(self):
self.client.emit(Message("enclosure.mouth.smile"))

def mouth_viseme(self, visCode):
self.client.emit(
Message("enclosure.mouth.viseme", {'code': visCode}))
def mouth_viseme(self, codes, durations):
self.client.emit(Message("enclosure.mouth.viseme",
{'codes': codes, 'durations': durations}))

def mouth_text(self, text=""):
self.client.emit(
Message("enclosure.mouth.text", {'text': text}))
self.client.emit(Message("enclosure.mouth.text", {'text': text}))

def weather_display(self, img_code, temp):
self.client.emit(
Message("enclosure.weather.display",
{'img_code': img_code, 'temp': temp}))
self.client.emit(Message("enclosure.weather.display",
{'img_code': img_code, 'temp': temp}))

def activate_mouth_events(self):
self.client.emit(Message('enclosure.mouth.events.activate'))
Expand Down
31 changes: 13 additions & 18 deletions mycroft/client/enclosure/mouth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


from time import time, sleep

from mycroft.util.log import getLogger
from mycroft.util import check_for_signal
import time

__author__ = 'jdorleans'

LOGGER = getLogger(__name__)
LOG = getLogger(__name__)


class EnclosureMouth:
Expand Down Expand Up @@ -62,22 +62,17 @@ def smile(self, event=None):
self.writer.write("mouth.smile")

def viseme(self, event=None):
visCmds = ''
if event and event.metadata:
visCmds = event.metadata.get("code", visCmds)
# visCmds will be string of viseme codes and cumulative durations
# ex: '0:0.34,1:1.23,0:1.32,'
lisPairs = visCmds.split(",")
timeStart = time.time()
for pair in lisPairs:
if check_for_signal('buttonPress'):
return # abort! (aplay should have already been killed)
vis_dur = pair.split(":")
if vis_dur[0] >= "0" and vis_dur[0] <= "6":
elap = time.time() - timeStart
self.writer.write("mouth.viseme=" + vis_dur[0])
if elap < float(vis_dur[1]):
time.sleep(float(vis_dur[1]) - elap)
start = time()
codes = event.metadata.get("codes")
durations = event.metadata.get("durations")
for idx, code in enumerate(codes):
if "0" <= code <= "6":
self.writer.write("mouth.viseme=" + code)
duration = float(durations[idx])
delta = time() - start
if delta < duration:
sleep(duration - delta)

def text(self, event=None):
text = ""
Expand Down
4 changes: 2 additions & 2 deletions mycroft/client/speech/local_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


import tempfile
import time

import os
from os.path import join, dirname, abspath
from pocketsphinx import Decoder
import tempfile

__author__ = 'seanfitz, jdorleans'

Expand Down Expand Up @@ -53,7 +53,7 @@ def create_config(self, dict_name):
config.set_string('-hmm', join(BASEDIR, 'model', self.lang, 'hmm'))
config.set_string('-dict', dict_name)
config.set_string('-keyphrase', self.key_phrase)
config.set_float('-kws_threshold', float(self.threshold))
config.set_float('-kws_threshold', self.threshold)
config.set_float('-samprate', self.sample_rate)
config.set_int('-nfft', 2048)
config.set_string('-logfn', '/dev/null')
Expand Down
2 changes: 1 addition & 1 deletion mycroft/client/speech/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def mute_and_speak(utterance):
try:
logger.info("Speak: " + utterance)
loop.mute()
tts.execute(utterance, client)
tts.execute(utterance)
finally:
loop.unmute()
mutex.release()
Expand Down
12 changes: 4 additions & 8 deletions mycroft/client/speech/mic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


import collections
import audioop
import os
import os.path
import collections
from time import sleep

import pyaudio
import speech_recognition
from speech_recognition import (
Microphone,
AudioSource,
AudioData
)
import speech_recognition

from mycroft.configuration import ConfigurationManager
from mycroft.util.log import getLogger
Expand Down Expand Up @@ -148,10 +146,8 @@ def __init__(self, wake_word_recognizer):
speech_recognition.Recognizer.__init__(self)
self.wake_word_recognizer = wake_word_recognizer
self.audio = pyaudio.PyAudio()
self.threshold_multiplier = float(
listener_config.get('threshold_multiplier'))
self.dynamic_energy_ratio = float(
listener_config.get('dynamic_energy_ratio'))
self.threshold_multiplier = listener_config.get('threshold_multiplier')
self.dynamic_energy_ratio = listener_config.get('dynamic_energy_ratio')

@staticmethod
def record_sound_chunk(source):
Expand Down
110 changes: 0 additions & 110 deletions mycroft/configuration/mycroft.ini

This file was deleted.

11 changes: 6 additions & 5 deletions mycroft/session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@


import time
from uuid import uuid4
from threading import Lock
from mycroft.util import log
from uuid import uuid4

from mycroft.configuration import ConfigurationManager
from mycroft.util import log

__author__ = 'seanfitz'
logger = log.getLogger(__name__)
config = ConfigurationManager.get().get('session_management', {})
config = ConfigurationManager.get().get('session')


class Session(object):
"""
An object representing a Mycroft Session Identifier
"""

def __init__(self, session_id, expiration_seconds=180):
self.session_id = session_id
self.touch_time = int(time.time())
Expand Down Expand Up @@ -74,8 +76,7 @@ def get():
if (not SessionManager.__current_session or
SessionManager.__current_session.expired()):
SessionManager.__current_session = Session(
str(uuid4()),
expiration_seconds=config.get('session_ttl_seconds', 180))
str(uuid4()), expiration_seconds=config.get('ttl', 180))
logger.info(
"New Session Start: " +
SessionManager.__current_session.session_id)
Expand Down
11 changes: 6 additions & 5 deletions mycroft/skills/alarm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@


import time
import yaml
from alsaaudio import Mixer
from datetime import datetime, timedelta
from os.path import dirname, join

import yaml
from adapt.intent import IntentBuilder
from os.path import dirname, join

from mycroft.skills.scheduled_skills import ScheduledCRUDSkill
from mycroft.util import play_mp3

Expand All @@ -34,9 +35,9 @@ class AlarmSkill(ScheduledCRUDSkill):
def __init__(self):
super(AlarmSkill, self).__init__("AlarmSkill", None, dirname(__file__))
self.alarm_on = False
self.max_delay = int(self.config.get('max_delay'))
self.repeat_time = int(self.config.get('repeat_time'))
self.extended_delay = int(self.config.get('extended_delay'))
self.max_delay = self.config.get('max_delay')
self.repeat_time = self.config.get('repeat_time')
self.extended_delay = self.config.get('extended_delay')
self.file_path = join(self.basedir, self.config.get('filename'))

def initialize(self):
Expand Down
Loading

0 comments on commit 4c1ba4e

Please sign in to comment.