Beispiel #1
0
    def __init__(self, PERSONA, mic, mpdwrapper):
        self._logger = logging.getLogger(__name__)
        self.persona = PERSONA
        # self.mic - we're actually going to ignore the mic they passed in
        self.music = mpdwrapper

        # index spotify playlists into new dictionary and language models
        original = [
            "STOP", "CLOSE", "PLAY", "PAUSE", "NEXT", "PREVIOUS", "LOUDER",
            "SOFTER", "LOWER", "HIGHER", "VOLUME", "PLAYLIST"
        ] + self.music.get_soup_playlist()
        pronounced = g2p.translateWords(original)
        zipped = zip(original, pronounced)
        lines = ["%s %s" % (x, y) for x, y in zipped]

        with open("dictionary_spotify.dic", "w") as f:
            f.write("\n".join(lines) + "\n")

        with open("sentences_spotify.txt", "w") as f:
            f.write("\n".join(original) + "\n")
            f.write("<s> \n </s> \n")
            f.close()

        # make language model
        os.system("text2idngram -vocab sentences_spotify.txt < " +
                  "sentences_spotify.txt -idngram spotify.idngram")
        os.system("idngram2lm -idngram spotify.idngram -vocab " +
                  "sentences_spotify.txt -arpa languagemodel_spotify.lm")

        # create a new mic with the new music models
        self.mic = Mic(
            mic.speaker, mic.passive_stt_engine,
            stt.PocketSphinxSTT(lmd_music="languagemodel_spotify.lm",
                                dictd_music="dictionary_spotify.dic"))
Beispiel #2
0
    def __init__(self, PERSONA, mic):
        self.persona = PERSONA
        # self.mic - we're actually going to ignore the mic they passed in
        self.music = Music()

        # index spotify playlists into new dictionary and language models
        words = self.music.get_soup_playlist() + [
            "STOP", "CLOSE", "PLAY", "PAUSE", "NEXT", "PREVIOUS", "LOUDER",
            "SOFTER", "LOWER", "HIGHER", "VOLUME", "PLAYLIST"
        ]
        text = "\n".join(["<s> %s </s>" for word in words])
        # make language model
        vocabcompiler.compile_text(text, languagemodel_spotify)

        # create a new mic with the new music models
        self.mic = Mic(
            speaker.newSpeaker(),
            stt.PocketSphinxSTT(lmd_music=languagemodel_spotify,
                                dictd_music=dictionary_spotify),
            stt.PocketSphinxSTT(lmd_music=languagemodel_spotify,
                                dictd_music=dictionary_spotify))
    def __init__(self, PERSONA, mic, mpdwrapper):
        self._logger = logging.getLogger(__name__)
        self.persona = PERSONA
        # self.mic - we're actually going to ignore the mic they passed in
        self.music = mpdwrapper

        # index spotify playlists into new dictionary and language models
        phrases = [
            "STOP", "CLOSE", "PLAY", "PAUSE", "NEXT", "PREVIOUS", "LOUDER",
            "SOFTER", "LOWER", "HIGHER", "VOLUME", "PLAYLIST"
        ]
        phrases.extend(self.music.get_soup_playlist())

        vocabulary_music = vocabcompiler.PocketsphinxVocabulary(
            name='music', path=jasperpath.config('vocabularies'))
        vocabulary_music.compile(phrases)

        # create a new mic with the new music models
        config = stt.PocketSphinxSTT.get_config()

        self.mic = Mic(
            mic.speaker, mic.passive_stt_engine,
            stt.PocketSphinxSTT(vocabulary_music=vocabulary_music, **config))
Beispiel #4
0
    try:
        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:
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()