Esempio n. 1
0
 def __init__(self, name, emitter=None):
     self.name = name
     self.bind(emitter)
     config = ConfigurationManager.get_config()
     self.config = config.get(name)
     self.config_core = config.get('core')
     self.dialog_renderer = None
     self.file_system = FileSystemAccess(join('skills', name))
     self.registered_intents = []
Esempio n. 2
0
 def __init__(self, name, emitter=None):
     self.name = name
     self.bind(emitter)
     config = ConfigurationManager.get_config()
     self.config = config.get(name)
     self.config_core = config.get('core')
     self.dialog_renderer = None
     self.file_system = FileSystemAccess(join('skills', name))
     self.registered_intents = []
Esempio n. 3
0
 def __init_serial(self):
     try:
         self.config = ConfigurationManager.get_config().get("enclosure")
         self.port = self.config.get("port")
         self.rate = int(self.config.get("rate"))
         self.timeout = int(self.config.get("timeout"))
         self.serial = serial.serial_for_url(url=self.port, baudrate=self.rate, timeout=self.timeout)
         LOGGER.info("Connected to: " + self.port + " rate: " + str(self.rate) + " timeout: " + str(self.timeout))
     except:
         LOGGER.error("It is not possible to connect to serial port: " + self.port)
         raise
Esempio n. 4
0
def main():
    import tornado.options
    tornado.options.parse_command_line()
    ConfigurationManager.load()
    config = ConfigurationManager.get_config()
    service_config = config.get("messagebus_service")

    routes = [(service_config.get('route'), WebsocketEventHandler)]

    application = web.Application(routes, **settings)

    application.listen(service_config.get("port"), service_config.get("host"))
    loop = ioloop.IOLoop.instance()
    loop.start()
Esempio n. 5
0
 def __init_serial(self):
     try:
         self.config = ConfigurationManager.get_config().get("enclosure")
         self.port = self.config.get("port")
         self.rate = int(self.config.get("rate"))
         self.timeout = int(self.config.get("timeout"))
         self.serial = serial.serial_for_url(url=self.port,
                                             baudrate=self.rate,
                                             timeout=self.timeout)
         LOGGER.info("Connected to: " + self.port + " rate: " +
                     str(self.rate) + " timeout: " + str(self.timeout))
     except:
         LOGGER.error("It is not possible to connect to serial port: " +
                      self.port)
         raise
Esempio n. 6
0
def main():
    import tornado.options
    tornado.options.parse_command_line()
    ConfigurationManager.load()
    config = ConfigurationManager.get_config()
    service_config = config.get("messagebus_service")

    routes = [
        (service_config.get('route'), WebsocketEventHandler)
    ]

    application = tornado.web.Application(routes, **settings)

    application.listen(service_config.get("port"), service_config.get("host"))
    ioloop = tornado.ioloop.IOLoop.instance()
    ioloop.start()
Esempio n. 7
0
def create():
    """
    Factory method to create a TTS engine based on configuration.

    The configuration file ``defaults.ini`` contains a ``tts`` section with
    the name of a TTS module to be read by this method.

    [tts]

    module = <engine_name>
    """

    logging.basicConfig()
    config = ConfigurationManager.get_config().get('tts')
    name = config.get('module')
    lang = config.get(name + '.lang', None)
    voice = config.get(name + '.voice')

    if name == mimic_tts.NAME:
        tts = mimic_tts.Mimic(lang, voice)
        mimic_tts.MimicValidator().validate(tts)
    elif name == google_tts.NAME:
        tts = google_tts.GoogleTTS(lang, voice)
        google_tts.GoogleTTSValidator().validate(tts)
    elif name == mary_tts.NAME:
        tts = mary_tts.MaryTTS(lang, voice, config[name + '.url'])
        mary_tts.MaryTTSValidator().validate(tts)
    elif name == fa_tts.NAME:
        tts = fa_tts.FATTS(lang, voice, config[name + '.url'])
        fa_tts.FATTSValidator().validate(tts)
    elif name == espeak_tts.NAME:
        tts = espeak_tts.ESpeak(lang, voice)
        espeak_tts.ESpeakValidator().validate(tts)
    else:
        tts = spdsay_tts.SpdSay(lang, voice)
        spdsay_tts.SpdSayValidator().validate(tts)
    return tts
Esempio n. 8
0
# 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/>.


import subprocess
from os.path import join

from mycroft import MYCROFT_ROOT_PATH
from mycroft.tts import TTS, TTSValidator
from mycroft.configuration.config import ConfigurationManager

__author__ = 'jdorleans'

config = ConfigurationManager.get_config().get("tts", {})

NAME = 'mimic'
BIN = config.get(
    "mimic.path", join(MYCROFT_ROOT_PATH, 'mimic', 'bin', 'mimic'))


class Mimic(TTS):
    def __init__(self, lang, voice):
        super(Mimic, self).__init__(lang, voice)

    def execute(self, sentence):
        subprocess.call([BIN, '-voice', self.voice, '-t', sentence])


class MimicValidator(TTSValidator):
Esempio n. 9
0
# You should have received a copy of the GNU General Public License
# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.


import json
import threading
import time
import requests

from mycroft.util import str2bool
from mycroft.util.log import getLogger
from mycroft.configuration.config import ConfigurationManager
from mycroft.session import SessionManager
from mycroft.util.setup_base import get_version

config = ConfigurationManager.get_config().get('metrics_client')
metrics_log = getLogger("METRICS")


class Stopwatch(object):
    def __init__(self):
        self.timestamp = None

    def start(self):
        self.timestamp = time.time()

    def lap(self):
        cur_time = time.time()
        start_time = self.timestamp
        self.timestamp = cur_time
        return cur_time - start_time
Esempio n. 10
0
# 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/>.

import time
from uuid import uuid4
from threading import Lock
from mycroft.util import log
from mycroft.configuration.config import ConfigurationManager

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


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())
        self.expiration_seconds = expiration_seconds

    def touch(self):
        """
        update the touch_time on the session
Esempio n. 11
0
from threading import Thread, Lock

from mycroft.client.speech.listener import RecognizerLoop
from mycroft.configuration.config import ConfigurationManager
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.messagebus.message import Message
from mycroft.tts import tts_factory
from mycroft.util.log import getLogger

logger = getLogger("SpeechClient")
client = None
tts = tts_factory.create()
mutex = Lock()
loop = None

config = ConfigurationManager.get_config()


def handle_listening():
    logger.info("Listening...")
    client.emit(Message('recognizer_loop:listening'))


def handle_wakeword(event):
    logger.info("Wakeword Detected: " + event['utterance'])
    client.emit(Message('recognizer_loop:wakeword', event))


def handle_utterance(event):
    logger.info("Utterance: " + str(event['utterances']))
    client.emit(Message('recognizer_loop:utterance', event))
Esempio n. 12
0
from mycroft.client.speech import wakeword_recognizer
from mycroft.client.speech.mic import MutableMicrophone, Recognizer
from mycroft.client.speech.recognizer_wrapper import (
    RemoteRecognizerWrapperFactory
)
from mycroft.configuration.config import ConfigurationManager
from mycroft.messagebus.message import Message
from mycroft.metrics import MetricsAggregator, Stopwatch
from mycroft.session import SessionManager
from mycroft.util import read_stripped_lines, CerberusAccessDenied
from mycroft.util.log import getLogger

logger = getLogger(__name__)

core_config = ConfigurationManager.get_config().get('core')
speech_config = ConfigurationManager.get_config().get('speech_client')


class AudioProducer(threading.Thread):
    """
    AudioProducer
    given a mic and a recognizer implementation, continuously listens to the
    mic for potential speech chunks and pushes them onto the queue.
    """
    def __init__(self, state, queue, mic, recognizer, emitter):
        threading.Thread.__init__(self)
        self.daemon = True
        self.state = state
        self.queue = queue
        self.mic = mic
Esempio n. 13
0
from threading import Thread, Lock

from mycroft.client.speech.listener import RecognizerLoop
from mycroft.configuration.config import ConfigurationManager
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.messagebus.message import Message
from mycroft.tts import tts_factory
from mycroft.util.log import getLogger

logger = getLogger("SpeechClient")
client = None
tts = tts_factory.create()
mutex = Lock()
loop = None

config = ConfigurationManager.get_config()


def handle_listening():
    logger.info("Listening...")
    client.emit(Message('recognizer_loop:listening'))


def handle_wakeword(event):
    logger.info("Wakeword Detected: " + event['utterance'])
    client.emit(Message('recognizer_loop:wakeword', event))


def handle_utterance(event):
    logger.info("Utterance: " + str(event['utterances']))
    client.emit(Message('recognizer_loop:utterance', event))
Esempio n. 14
0
from pyowm.webapi25 import observationparser
from pyowm.webapi25 import observationlistparser
from pyowm.webapi25 import forecastparser
from pyowm.webapi25 import weatherhistoryparser
from pyowm.webapi25 import stationparser
from pyowm.webapi25 import stationlistparser
from pyowm.webapi25 import stationhistoryparser
from pyowm.webapi25 import weathercoderegistry
from pyowm.webapi25 import cityidregistry

from mycroft.configuration.config import ConfigurationManager
"""
Configuration for the PyOWM library specific to OWM web API version 2.5
"""

config = ConfigurationManager.get_config().get('WeatherSkill')

if config.get('api_key'):
    ROOT_API_URL = 'http://api.openweathermap.org/data/2.5'
else:
    ROOT_API_URL = 'https://cerberus.mycroft.ai/weather/owm'

# OWM web API URLs
ICONS_BASE_URL = 'http://openweathermap.org/img/w'
OBSERVATION_URL = ROOT_API_URL + '/weather'
STATION_URL = ROOT_API_URL + '/station'
FIND_OBSERVATIONS_URL = ROOT_API_URL + '/find'
FIND_STATION_URL = ROOT_API_URL + '/station/find'
BBOX_STATION_URL = ROOT_API_URL + '/box/station'
THREE_HOURS_FORECAST_URL = ROOT_API_URL + '/forecast'
DAILY_FORECAST_URL = ROOT_API_URL + '/forecast/daily'
Esempio n. 15
0
# You should have received a copy of the GNU General Public License
# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os
import argparse
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.skills.core import create_skill_descriptor, load_skill
from mycroft.util.log import getLogger
from mycroft.configuration.config import ConfigurationManager
from mycroft.skills.intent import create_skill as create_intent_skill

__author__ = 'seanfitz'

logger = getLogger("SkillContainer")
messagebus_config = ConfigurationManager.get_config().get("messagebus_client")


class SkillContainer(object):
    def __init__(self, args):
        parser = argparse.ArgumentParser()
        parser.add_argument("--dependency-dir", default="./lib")
        parser.add_argument("--messagebus-host",
                            default=messagebus_config.get("host"))
        parser.add_argument("--messagebus-port",
                            type=int,
                            default=messagebus_config.get("port"))
        parser.add_argument("--use-ssl", action='store_true', default=False)
        parser.add_argument("--enable-intent-skill",
                            action='store_true',
                            default=False)
Esempio n. 16
0
 def __init__(self, name):
     super(MediaSkill, self).__init__(name)
     self.isPlaying = False
     config = ConfigurationManager.get_config()
     self.base_conf = config.get('Media')
Esempio n. 17
0
import json
import threading
import time
import requests

from mycroft.util import str2bool
from mycroft.util.log import getLogger
from mycroft.configuration.config import ConfigurationManager
from mycroft.session import SessionManager
from mycroft.util.setup_base import get_version

config = ConfigurationManager.get_config().get('metrics_client')
metrics_log = getLogger("METRICS")


class Stopwatch(object):
    def __init__(self):
        self.timestamp = None

    def start(self):
        self.timestamp = time.time()

    def lap(self):
        cur_time = time.time()
        start_time = self.timestamp
        self.timestamp = cur_time
        return cur_time - start_time

    def stop(self):
        cur_time = time.time()
        start_time = self.timestamp
Esempio n. 18
0
import time
from uuid import uuid4
from threading import Lock
from mycroft.util import log
from mycroft.configuration.config import ConfigurationManager

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


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())
        self.expiration_seconds = expiration_seconds

    def touch(self):
        """
        update the touch_time on the session

        :return:
        """
        self.touch_time = int(time.time())

    def expired(self):
        """
        determine if the session has expired
from pyowm.webapi25 import observationlistparser
from pyowm.webapi25 import forecastparser
from pyowm.webapi25 import weatherhistoryparser
from pyowm.webapi25 import stationparser
from pyowm.webapi25 import stationlistparser
from pyowm.webapi25 import stationhistoryparser
from pyowm.webapi25 import weathercoderegistry
from pyowm.webapi25 import cityidregistry

from mycroft.configuration.config import ConfigurationManager

"""
Configuration for the PyOWM library specific to OWM web API version 2.5
"""

config = ConfigurationManager.get_config().get('WeatherSkill')

if config.get('api_key'):
    ROOT_API_URL = 'http://api.openweathermap.org/data/2.5'
else:
    ROOT_API_URL = 'https://cerberus.mycroft.ai/weather/owm'

# OWM web API URLs
ICONS_BASE_URL = 'http://openweathermap.org/img/w'
OBSERVATION_URL = ROOT_API_URL + '/weather'
STATION_URL = ROOT_API_URL + '/station'
FIND_OBSERVATIONS_URL = ROOT_API_URL + '/find'
FIND_STATION_URL = ROOT_API_URL + '/station/find'
BBOX_STATION_URL = ROOT_API_URL + '/box/station'
THREE_HOURS_FORECAST_URL = ROOT_API_URL + '/forecast'
DAILY_FORECAST_URL = ROOT_API_URL + '/forecast/daily'
Esempio n. 20
0
import sys
import os
import argparse
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.skills.core import create_skill_descriptor, load_skill
from mycroft.util.log import getLogger
from mycroft.configuration.config import ConfigurationManager
from mycroft.skills.intent import create_skill as create_intent_skill

__author__ = 'seanfitz'

logger = getLogger("SkillContainer")
messagebus_config = ConfigurationManager.get_config().get("messagebus_client")


class SkillContainer(object):
    def __init__(self, args):
        parser = argparse.ArgumentParser()
        parser.add_argument("--dependency-dir", default="./lib")
        parser.add_argument("--messagebus-host", default=messagebus_config.get("host"))
        parser.add_argument("--messagebus-port", type=int, default=messagebus_config.get("port"))
        parser.add_argument("--use-ssl", action='store_true', default=False)
        parser.add_argument("--enable-intent-skill", action='store_true', default=False)
        parser.add_argument("skill_directory", default=os.path.dirname(__file__))

        parsed_args = parser.parse_args(args)
        if os.path.exists(parsed_args.dependency_dir):
            sys.path.append(parsed_args.dependency_dir)

        self.skill_directory = parsed_args.skill_directory
        self.enable_intent_skill = parsed_args.enable_intent_skill
Esempio n. 21
0
from mycroft.client.speech.local_recognizer import LocalRecognizer
from mycroft.client.speech.mic import MutableMicrophone, Recognizer
from mycroft.client.speech.recognizer_wrapper import \
    RemoteRecognizerWrapperFactory
from mycroft.client.speech.word_extractor import WordExtractor
from mycroft.configuration.config import ConfigurationManager
from mycroft.messagebus.message import Message
from mycroft.metrics import MetricsAggregator, Stopwatch
from mycroft.session import SessionManager
from mycroft.util import CerberusAccessDenied
from mycroft.util.log import getLogger

logger = getLogger(__name__)

core_config = ConfigurationManager.get_config().get('core')
speech_config = ConfigurationManager.get_config().get('speech_client')


class AudioProducer(threading.Thread):
    """
    AudioProducer
    given a mic and a recognizer implementation, continuously listens to the
    mic for potential speech chunks and pushes them onto the queue.
    """
    def __init__(self, state, queue, mic, recognizer, emitter):
        threading.Thread.__init__(self)
        self.daemon = True
        self.state = state
        self.queue = queue
        self.mic = mic
Esempio n. 22
0
# 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/>.

import subprocess
from os.path import join

from mycroft import MYCROFT_ROOT_PATH
from mycroft.tts import TTS, TTSValidator
from mycroft.configuration.config import ConfigurationManager

__author__ = 'jdorleans'

config = ConfigurationManager.get_config().get("tts", {})

NAME = 'mimic'
BIN = config.get("mimic.path", join(MYCROFT_ROOT_PATH, 'mimic', 'bin',
                                    'mimic'))


class Mimic(TTS):
    def __init__(self, lang, voice):
        super(Mimic, self).__init__(lang, voice)

    def execute(self, sentence):
        subprocess.call([BIN, '-voice', self.voice, '-t', sentence])


class MimicValidator(TTSValidator):