# false activation or speach not recognised
                  self.speaker.play("../static/audio/beep_hi.mp3")
                
          except KeyboardInterrupt:
            print 'got break'
            break



if __name__ == "__main__":
    l = jasperLogger.jasperLogger(level=logging.DEBUG, logFile='persistentCache.log', console=True)
    logger = l.getLogger()
    profile = yaml.safe_load(open("profile.yml", "r"))
    #spk = speaker.DummySpeaker(logger, profile)
    spk = speaker.newSpeaker(logger, profile)
    activeSTT  = stt.newSTTEngine(profile['stt_engine'], logger=logger, api_key=profile['keys']['GOOGLE_SPEECH'])

    logger.info("start")
    if len(sys.argv) < 2:
      f = "active.wav"
    else:
      f = sys.argv[1]
    
    
    mic = Mic(spk, activeSTT, activeSTT, logger, profile)
    #f = 'samples/wlacz_dekoder_ncplusAt1003_4m_RodeM3_SBLive.wav'
    #f = 'samples/wlacz_dekoder_ncplusAt1003_1m_RodeM3_SBLive.wav'
    #mic.find_input_device()
    #print f
    #raw_input("<pause>")
    #t = mic.fetchThreshold(               RATE=48000, CHUNK=8192, THRESHOLD_TIME=60, AVERAGE_TIME=3)
Beispiel #2
0
    def __init__(self):
        self._logger = logging.getLogger(__name__)

        # Create config dir if it does not exist yet
        if not os.path.exists(saschapath.CONFIG_PATH):
            try:
                os.makedirs(saschapath.CONFIG_PATH)
            except OSError:
                self._logger.error("Could not create config dir: '%s'",
                                   saschapath.CONFIG_PATH, exc_info=True)
                raise

        # Check if config dir is writable
        if not os.access(saschapath.CONFIG_PATH, os.W_OK):
            self._logger.critical("Config dir %s is not writable. Jasper " +
                                  "won't work correctly.",
                                  saschapath.CONFIG_PATH)

        # FIXME: For backwards compatibility, move old config file to newly
        #        created config dir
        old_configfile = os.path.join(saschapath.LIB_PATH, 'profile.yml')
        new_configfile = saschapath.config('profile.yml')
        if os.path.exists(old_configfile):
            if os.path.exists(new_configfile):
                self._logger.warning("Deprecated profile file found: '%s'. " +
                                     "Please remove it.", old_configfile)
            else:
                self._logger.warning("Deprecated profile file found: '%s'. " +
                                     "Trying to copy it to new location '%s'.",
                                     old_configfile, new_configfile)
                try:
                    shutil.copy2(old_configfile, new_configfile)
                except shutil.Error:
                    self._logger.error("Unable to copy config file. " +
                                       "Please copy it manually.",
                                       exc_info=True)
                    raise

        # Read config
        self._logger.debug("Trying to read config file: '%s'", new_configfile)
        try:
            with open(new_configfile, "r") as f:
                self.config = yaml.safe_load(f)
        except OSError:
            self._logger.error("Can't open config file: '%s'", new_configfile)
            raise

        try:
            api_key = self.config['keys']['GOOGLE_SPEECH']
        except KeyError:
            api_key = None

        try:
            stt_engine_type = self.config['stt_engine']
        except KeyError:
            stt_engine_type = "sphinx"
            self._logger.warning("stt_engine not specified in profile, " +
                                 "defaulting to '%s'", stt_engine_type)

        try:
            tts_engine_slug = self.config['tts_engine']
        except KeyError:
            tts_engine_slug = tts.get_default_engine_slug()
            logger.warning("tts_engine not specified in profile, defaulting " +
                           "to '%s'", tts_engine_slug)
        tts_engine_class = tts.get_engine_by_slug(tts_engine_slug)

        # Initialize Mic
        self.mic = Mic(tts_engine_class(),
                       stt.PocketSphinxSTT(**stt.PocketSphinxSTT.get_config()),
                       stt.newSTTEngine(stt_engine_type, api_key=api_key))
Beispiel #3
0
if __name__ == "__main__":

    print "==========================================================="
    print " JASPER The Talking Computer                               "
    print " Copyright 2013 Shubhro Saha & Charlie Marsh               "
    print "==========================================================="

    profile = yaml.safe_load(open("profile.yml", "r"))

    try:
        api_key = profile["keys"]["GOOGLE_SPEECH"]
    except KeyError:
        api_key = None

    try:
        stt_engine_type = profile["stt_engine"]
    except KeyError:
        print "stt_engine not specified in profile, defaulting to PocketSphinx"
        stt_engine_type = "sphinx"

    mic = Mic(speaker.newSpeaker(), stt.PocketSphinxSTT(), stt.newSTTEngine(stt_engine_type, api_key=api_key))

    addendum = ""
    if "first_name" in profile:
        addendum = ", %s" % profile["first_name"]
    mic.say("How can I be of service%s?" % addendum)

    conversation = Conversation("JASPER", mic, profile)

    conversation.handleForever()
Beispiel #4
0
        stt_engine_type = profile['stt_engine']
    except KeyError:
        log.warn("stt_engine not specified in profile, defaulting to PocketSphinx")
        stt_engine_type = "sphinx"
    
    log.debug("command line args: %s" % args)
    
    try:
      if args.no_speaker:
        spk = speaker.DummySpeaker(log, profile)
      else:
        spk = speaker.newSpeaker(log, profile)
      
      if not args.pipe and not args.sock and not args.local and not args.half_local and not args.dynamic:
        passiveSTT = stt.PocketSphinxSTT(logger=log)
        activeSTT  = stt.newSTTEngine(stt_engine_type, logger=log, api_key=api_key)
      elif args.half_local or args.dynamic:
        passiveSTT = None
        activeSTT  = stt.newSTTEngine(stt_engine_type, logger=log, api_key=api_key)
      else:
        passiveSTT = None
        activeSTT  = None

      mic = Mic(spk, passiveSTT, activeSTT, log, profile=profile)      
    except:
        log.critical( "fatal error creating mic", exc_info=True)
        exit(1)

    addendum = ""
    if 'first_name' in profile:
        addendum = ", %s" % profile["first_name"]
Beispiel #5
0
    print "==========================================================="
    print " JASPER The Talking Computer                               "
    print " Copyright 2013 Shubhro Saha & Charlie Marsh               "
    print "==========================================================="

    profile = yaml.safe_load(open("profile.yml", "r"))

    try:
        api_key = profile['keys']['GOOGLE_SPEECH']
    except KeyError:
        api_key = None

    try:
        stt_engine_type = profile['stt_engine']
    except KeyError:
        print "stt_engine not specified in profile, defaulting to PocketSphinx"
        stt_engine_type = "sphinx"

    mic = Mic(speaker.newSpeaker(), stt.PocketSphinxSTT(),
              stt.newSTTEngine(stt_engine_type, api_key=api_key))
    house = House(mic)
    addendum = ""
    if 'first_name' in profile:
        addendum = ", %s" % profile["first_name"]
    mic.say("How can I be of service%s?" % addendum)

    conversation = Conversation("JASPER", mic, profile, house)

    conversation.handleForever()
Beispiel #6
0
            except KeyboardInterrupt:
                print 'got break'
                break


if __name__ == "__main__":
    l = jasperLogger.jasperLogger(level=logging.DEBUG,
                                  logFile='persistentCache.log',
                                  console=True)
    logger = l.getLogger()
    profile = yaml.safe_load(open("profile.yml", "r"))
    #spk = speaker.DummySpeaker(logger, profile)
    spk = speaker.newSpeaker(logger, profile)
    activeSTT = stt.newSTTEngine(profile['stt_engine'],
                                 logger=logger,
                                 api_key=profile['keys']['GOOGLE_SPEECH'])

    logger.info("start")
    if len(sys.argv) < 2:
        f = "active.wav"
    else:
        f = sys.argv[1]

    mic = Mic(spk, activeSTT, activeSTT, logger, profile)
    #f = 'samples/wlacz_dekoder_ncplusAt1003_4m_RodeM3_SBLive.wav'
    #f = 'samples/wlacz_dekoder_ncplusAt1003_1m_RodeM3_SBLive.wav'
    #mic.find_input_device()
    #print f
    #raw_input("<pause>")
    #t = mic.fetchThreshold(               RATE=48000, CHUNK=8192, THRESHOLD_TIME=60, AVERAGE_TIME=3)