Ejemplo n.º 1
0
    def run(self):
        if 'first_name' in self.config:
            salutation = (u"%s 我能为您做什么?" % self.config["first_name"])
        else:
            salutation = "主人,我能为您做什么?"

        persona = 'DINGDANG'
        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        #ender: create conversation robot instance with config file.
        conversation = Conversation(persona, self.mic, self.config)

        # create wechat robot
        if self.config['wechat']:
            self.wxBot = WechatBot.WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        self.mic.say(salutation, cache=True)

        #ender: this is the entrance of the robot
        conversation.handleForever()
Ejemplo n.º 2
0
    def run(self):
        greet = ["How can I be of service master?", "I live again master", "hal 9000 now on line", "hello how are you master"]
        
        salutation = random.choice(greet)
        self.mic.say(salutation)

        conversation = Conversation("JARVIS", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 3
0
    def run(self):
        if 'first_name' in self.config:
            salutation = "How can I be of service, %s?" % self.config["first_name"]
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 4
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("무엇을 도와드릴까요?")
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("JJ", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 5
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("%s 很高兴为你服务" % self.config["first_name"])
        else:
            salutation = "很高兴为你服务"
        self.mic.say(salutation)

        conversation = Conversation("OKEY TOMMY", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 6
0
    def run(self):
        if 'first_name' in self.config:
            salutation = "How can I be of service, %s?" % self.config["first_name"]
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 7
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "Powering up in LVL1. It's good to be back."
        self.mic.say(salutation)

        conversation = Conversation("WHOPPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 8
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("What can I do for you today, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("NAOMI", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 9
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config) # It's looking like the python app doesn't do any voice processing?
        conversation.handleForever()
Ejemplo n.º 10
0
    def run(self):
        greet = ["How can I be of service master?", "I live again master", "hal 9000 now on line", "hello how are you master"]
        
        salutation = random.choice(greet)
        self.pygm.blitimg('nu.png', size, black, x, y)

        self.mic.say(salutation)

        conversation = Conversation("JARVIS", self.mic, self.config, self.pygm)
        conversation.handleForever()
Ejemplo n.º 11
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Hoe kan ik je helpen, %s?"
                          % self.config["first_name"])
        else:
            salutation = "Hoe kan ik je helpen?"
        self.mic.say(salutation)

        conversation = Conversation("SASCHA", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 12
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("%s , das System ist wieder online. " %
                          self.config["first_name"])
        else:
            salutation = "Wie kann ich Ihnen behilflich sein?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 13
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Como posso ajudar, %s?"
                          % self.config["first_name"])
        else:
            salutation = "Como posso ajudar?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 14
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Was kann ich für dich tun?, %s?"
                          % self.config["first_name"])
        else:
            salutation = "Was kann ich für dich tun?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 15
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Hi, I am Bibli robot, my name is Lucky!") # %s?"
                         # % self.config["first_name"])
        else:
            salutation = "Hi, I am Bibli robot, my name is Lucky"
        self.mic.say(salutation)

        conversation = Conversation("LUCKY", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 16
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Hi 很高兴为你服务,我是小爱,聪明活泼的可可小爱,是你的语音小助手。我可以提供天气预报,时间查询,简单的数学计算,读唐诗,讲笑话,回答百科知识,根据和你的对话,还可以管理家中的网络设备。你可以通过,你好,可可小爱,来跟我打招呼。")
        else:
            salutation = "Hello 我是可可小爱,随时为你服务。"
        # print " ".join(jieba.cut("hello可可小爱"))
        self.mic.say(salutation)

        conversation = Conversation(u"hello|可可|小爱|你好|您好|咳咳|小艾|哈喽|可爱", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 17
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Hi, I am Bibli robot, my name is Lucky!")  # %s?"
            # % self.config["first_name"])
        else:
            salutation = "Hi, I am Bibli robot, my name is Lucky"
        self.mic.say(salutation)

        conversation = Conversation("LUCKY", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 18
0
    def run(self):
        #if 'first_name' in self.config:
        #    salutation = ("How can I be of service, %s?"
        #                  % self.config["first_name"])
        #else:
        #    salutation = "How can I be of service?"
	salutation = "Welcome to Biri!  What would you like?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 19
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Bonjour Monsieur, Comment puis-je vous aider?"
                          )  #("How can I be of service, %s?"
            #% self.config["first_name"])
        else:
            salutation = "Bonjour Monsieur, Comment puis-je vous aider?"
        self.mic.say(salutation)

        conversation = Conversation("ALFRED", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 20
0
    def run(self):
	first_name = client.jasperprofile.profile.get('first_name','')
        if first_name:
            salutation = (_("How can I be of service, %s?") % first_name)
        else:
            salutation = _("How can I be of service?")

        self.mic.say(salutation)

        conversation = Conversation("MACSEN", self.mic, client.jasperprofile.profile.get_yml())
        conversation.handleForever()
Ejemplo n.º 21
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        persona_name = self.config.get('persona_name', 'RALPH')
        conversation = Conversation(persona_name, self.mic, self.config)
        signal.signal(signal.SIGINT, self.get_sigint_handler(conversation))
        conversation.handleForever()
Ejemplo n.º 22
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        persona_name = self.config.get('persona_name', 'RALPH')
        conversation = Conversation(persona_name, self.mic, self.config)
        signal.signal(signal.SIGINT, self.get_sigint_handler(conversation))
        conversation.handleForever()
Ejemplo n.º 23
0
    def run(self):
        first_name = client.jasperprofile.profile.get('first_name', '')
        if first_name:
            salutation = (_("How can I be of service, %s?") % first_name)
        else:
            salutation = _("How can I be of service?")

        self.mic.say(salutation)

        conversation = Conversation("MACSEN", self.mic,
                                    client.jasperprofile.profile.get_yml())
        conversation.handleForever()
Ejemplo n.º 24
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("TOM", self.mic, self.config)
        #Activating the lights here
        LightCommands.command(3)
        conversation.handleForever()
Ejemplo n.º 25
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("%s 很高兴为你服务"
                          % self.config["first_name"])
        else:
            salutation = "很高兴为你服务"
        if os.path.exists(jasperpath.tjbot('shakehand.servo.js')):
            os.system("node " + jasperpath.tjbot('shakehand.servo.js'))
        self.mic.say(salutation)

        conversation = Conversation("OKEY TOMMY", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 26
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.speaker.clean_and_say(salutation)

        print("A moment of silence, please...")
        self.mic.adjust_for_ambient_noise()

        conversation = Conversation(self.requester, self.brain)
        conversation.handleForever()
Ejemplo n.º 27
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        # self.mic.say(salutation)

        # conversation = Conversation("JASPER", self.mic, self.config)
        # conversation = Conversation("GREW", self.mic, self.config)
        conversation = Conversation("GREW", self.mic, self.config,
                                    self.stt_engine_class)
        conversation.handleForever()
Ejemplo n.º 28
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Bonjour %s, que puis-je faire pour vous ?" %
                          self.config["first_name"])
        else:
            salutation = "Bonjour, que puis-je faire pour vous ?"
        self.mic.say(salutation)

        if 'name' in self.config:
            name = self.config['name'].upper()
        else:
            name = "LOLA"
        conversation = Conversation(name, self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 29
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("Bonjour %s, que puis-je faire pour vous ?"
                          % self.config["first_name"])
        else:
            salutation = "Bonjour, que puis-je faire pour vous ?"
        self.mic.say(salutation)

	if 'name' in self.config:
	    name = self.config['name'].upper()
	else:
	    name = "LOLA"	
        conversation = Conversation(name, self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 30
0
    def run(self):
	hour = int(time.strftime("%H"))
        
	if hour > 6 and hour < 11:
	    salutation = "Good morning"
        elif hour >= 11 and hour < 16:
	    salutation = "Good afternoon"
        elif hour >= 16 and hour < 23:
            salutation = "Good evening"
        else:
            salutation = "Hi there"

        self.mic.say(salutation)

        conversation = Conversation(self.config['persona'], self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 31
0
    def run(self):
        # Random welcome message
        welcomes = ["What do you need",
                    "How can I help"]

        salutation = random.choice(welcomes)
        if 'first_name' in self.config:
            salutation = ("%s, %s?"
                          % (salutation, self.config["first_name"]))
        else:
            salutation = ("%s?" % salutation)

        self.mic.say(salutation)

        conversation = Conversation("SAGE", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 32
0
    def run(self):
        if 'first_name' in self.config:
            if datetime.datetime.now().hour < 12:
                dayTime = "morning"
            elif datetime.datetime.now().hour < 6:
                dayTime = "afternoon"
            else:
                dayTime = "evening"
                
            salutation = ("Good %s %s I am the mighty Artificial Intelligence 9000. You can call me Mal"  % (dayTime, self.config["first_name"]))
        else:
            salutation += "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("MAL", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 33
0
    def run(self):
        salutation = (u"%s,我能为您做什么?" % config.get("first_name", u'主人'))

        persona = config.get("robot_name", 'DINGDANG')
        conversation = Conversation(persona, self.mic)

        # create wechat robot
        if config.get('wechat', False):
            self.wxBot = WechatBot.WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        self.mic.say(salutation, cache=True)
        conversation.handleForever()
Ejemplo n.º 34
0
    def run(self):
        salutation = (u"%s,我能为您做什么?" % config.get("first_name", u'主人'))

        persona = config.get("robot_name", 'HUIMEIJINGLING')
        conversation = Conversation(persona, self.mic)

        # create wechat robot
        if config.get('wechat', False):
            self.wxBot = WechatBot.WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        self.mic.say(salutation, cache=True)
        conversation.handleForever()
Ejemplo n.º 35
0
    def run(self):
        salutation = (u"%s,我能为您做什么?" % config.get("first_name", u'主人'))

        persona = config.get("robot_name", 'DINGDANG')
        conversation = Conversation(persona, self.mic)

        # create wechat robot
        if config.get('wechat', False):
            self.wxBot = WechatBot.WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        #self.mic.say(salutation, cache=True)
        self.mic.say(u"叮咚叮咚,我能为你做什么", cache=True)
        #self.mic.music_play('/home/pi/123.mp3')
        conversation.handleForever()
Ejemplo n.º 36
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        try:
            passiveEnabled = self.config['passive_enabled']
        except KeyError:
            passiveEnabled = "false"
            logger.warning("passive_enabled not specified in profile, " +
                           "defaulting to '%s'", passiveEnabled)

        passiveEnabled = passiveEnabled == "true"

        conversation = Conversation("JASPER", self.mic, self.config,
                                    passiveEnabled)
        conversation.handleForever()
Ejemplo n.º 37
0
    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        try:
            passiveEnabled = self.config['passive_enabled']
        except KeyError:
            passiveEnabled = "false"
            logger.warning(
                "passive_enabled not specified in profile, " +
                "defaulting to '%s'", passiveEnabled)

        passiveEnabled = passiveEnabled == "true"

        conversation = Conversation("JASPER", self.mic, self.config,
                                    passiveEnabled)
        conversation.handleForever()
Ejemplo n.º 38
0
    def run(self):

        if args.simon:
            return simon.run(self.mic)

        if args.daniel:
            return daniel.run(self.mic)

        if args.nostalgie:
            return nostalgie.run()

        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("COMPANION", self.mic, self.config)
        conversation.handleForever(args.rank, args.zeljko, args.kataUndBen,
                                   args.matt)
Ejemplo n.º 39
0
    def run(self):
        if 'first_name' in self.config:
            if 'keyword' in self.config:
                salutation = (
                    "Hi %s, my name is %s. what is your command" %
                    (self.config["first_name"], self.config["keyword"]))
            else:
                salutation = (
                    "Hi %s, my name is Jasper. what is your command" %
                    self.config["first_name"])

        else:
            if 'keyword' in self.config:
                salutation = ("%s is ready to take commands" %
                              self.confi["keyword"])
            else:
                salutation = ("Jasper is ready to take commands")

        self.mic.say(salutation)

        # Setting the engine to detect "keyword" otherwise, default to "JASPER"
        if 'keyword' in self.config:
            conversation = Conversation(self.config["keyword"], self.mic,
                                        self.config)
        else:
            conversation = Conversation("JASPER", self.mic, self.config)

        conversation.handleForever()
Ejemplo n.º 40
0
    def run(self):
        if 'first_name' in self.config:
            salutation = (u"%s 我能为您做什么?" % self.config["first_name"])
        else:
            salutation = "主人,我能为您做什么?"

        persona = 'DINGDANG'
        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        conversation = Conversation(persona, self.mic, self.config)

        # create wechat robot
        if self.config['wechat']:
            self.wxBot = WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        self.mic.say(salutation)
        conversation.handleForever()
Ejemplo n.º 41
0
    def run(self):
        persona = '小安'
        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        master = "主人"
        if 'master_name' in self.config:
            master = self.config["master_name"]

        salutation = random.choice([
            "%s,%s 竭诚为您服务!" % (master, persona),
            "%s,%s能为你做什么?" % (master, persona)
        ])

        self.conversation = Conversation(persona, self.mic, self.config)
        self.start_wxbot()
        self.mic.say(salutation)
        if (db.get_instance().is_need_update()):
            t = self.mic.asyncSay("正在更新股票基本信息数据库")
            db.get_instance().updata_stock_basics()
            t.join()
            self.mic.say("更新完成")

        self.conversation.handleForever()
Ejemplo n.º 42
0
    def run(self):
        if 'first_name' in self.config:
            salutation = (u"%s 我能为您做什么?"
                          % self.config["first_name"])
        else:
            salutation = "主人,我能为您做什么?"

        persona = 'DINGDANG'
        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        conversation = Conversation(persona, self.mic, self.config)

        # create wechat robot
        if self.config['wechat']:
            self.wxBot = WechatBot.WechatBot(conversation.brain)
            self.wxBot.DEBUG = True
            self.wxBot.conf['qr'] = 'tty'
            conversation.wxbot = self.wxBot
            t = threading.Thread(target=self.start_wxbot)
            t.start()

        self.mic.say(salutation, cache=True)
        conversation.handleForever()
Ejemplo n.º 43
0
    def run(self):
        self.kill_legacy_process()
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?" %
                          self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        #self.mic.say(salutation)

        if 'slackbot' in self.config:
            if 'slackbot_webhook_url' in self.config["slackbot"]:
                bot = Slackbot(self.config["slackbot"]["slackbot_webhook_url"])
            else:
                bot = Slackbot()
        #bot.startBot()

        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        else:
            self.mic.say("Please set robot name")
            return

        conversation = Conversation(persona, self.mic, self.config, bot)
        conversation.handleForever()
Ejemplo n.º 44
0
    def run(self):
        salutation = "I am now, fully online"
        self.mic.say(salutation)

        conversation = Conversation("FRIDAY", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 45
0
    def start(self):

        def testConnection():
            if Diagnostics.check_network_connection():
                print "CONNECTED TO INTERNET"
            else:
                print "COULD NOT CONNECT TO NETWORK"
                self.speaker.say(
                    "Warning: I was unable to connect to a network. Parts of the system may not work correctly, depending on your setup.")


        def fail(message):
            traceback.print_exc()
            self.speaker.say(message)
            sys.exit(1)


        def configure():
            try:
                print "COMPILING DICTIONARY FOR MODULES"
                vocabcompiler.compile(
                    "sentences.txt", "dictionary.dic", "languagemodel.lm")

                print "COMPILING DICTIONARY OF LOCATIONS OPTIONS"
                vocabcompiler.compileLocations(
                    "sentences_locations.txt", "dictionary_locations.dic", "languagemodel_locations.lm");

                print "STARTING CLIENT PROGRAM"

            except OSError:
                print "BOOT FAILURE: OSERROR"
                fail(
                    "There was a problem starting EasyNav. You may be missing the language model and associated files. Please read the documentation to configure your Raspberry Pi.")

            except IOError:
                print "BOOT FAILURE: IOERROR"
                fail(
                    "There was a problem starting EasyNav. You may have set permissions incorrectly on some part of the filesystem. Please read the documentation to configure your Raspberry Pi.")

            except:
                print "BOOT FAILURE"
                fail(
                    "There was a problem starting EasyNav.")

        old_client = os.path.abspath(os.path.join(os.pardir, "old_client"))
        if os.path.exists(old_client):
            shutil.rmtree(old_client)


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

        self.speaker.say("Hello.... I am EASYNAV... Please wait one moment while I configure.")

        configure()
        
        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(self.speaker, stt.PocketSphinxSTT(),
                  stt.newSTTEngine(stt_engine_type, api_key=api_key))

        mic.say("Hi...i'm EasyNav.....your friendly navigation assistant....")
        mic.say("To invoke me, please say my Name......and i will beep....then proceed with your command")
        mic.say("To find out about commands...please say help......")

        self.dispatcherClient.start()

        #GetLocations.getLoc()
        conversation = Conversation("EASYNAV", mic, profile, self.dispatcherClient)
        conversation.handleForever()
Ejemplo n.º 46
0
    def run(self):
        self.mic.say("Bonjour")

        conversation = Conversation("ALEXA", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 47
0
    def run(self):
        salutation = "How can I be of service?"
        self.mic.say(salutation)

        conversation = Conversation("JASPER", self.mic, self.config)
        conversation.handleForever()
Ejemplo n.º 48
0
        # Initialize Mic
        self.mic = Mic(tts_engine_class.get_instance(),
                       stt_engine_class.get_passive_instance(),
                       stt_engine_class.get_active_instance())

    def run(self):
        if 'first_name' in self.config:
            salutation = ("How can I be of service, %s?"
                          % self.config["first_name"])
        else:
            salutation = "How can I be of service?"
        self.mic.say(salutation)

<<<<<<< HEAD
        conversation = Conversation("HEY", self.mic, self.config)
=======
        conversation = Conversation("JASPER", self.mic, self.config)
>>>>>>> 144f2d0f8aca3d2d93f00ce5cde30c8e665fd3c8
        conversation.handleForever()

if __name__ == "__main__":

    print("*******************************************************")
<<<<<<< HEAD
    print("*                 Commence speech.                    *")
=======
    print("*             JASPER - THE TALKING COMPUTER           *")
    print("* (c) 2015 Shubhro Saha, Charlie Marsh & Jan Holthuis *")
>>>>>>> 144f2d0f8aca3d2d93f00ce5cde30c8e665fd3c8
    print("*******************************************************")
Ejemplo n.º 49
0
#!/usr/bin/env python2
Ejemplo n.º 50
0
    print " Copyright 2013 Shubhro Saha & Charlie Marsh               "
    print "==========================================================="

    speaker.say("Hello.... I am Jasper... Please wait one moment.")
    testConnection()
    configure()

    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, 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()
Ejemplo n.º 51
0
 def run(self):
     self.mic.say("Wakeup Message")
     converstation = Conversation("AssistantName", self.mic, self.config)
     converstation.handleForever()
Ejemplo n.º 52
0
    print " Copyright 2013 Shubhro Saha & Charlie Marsh               "
    print "==========================================================="

    speaker.say("Hello.... I am Jasper... Please wait one moment.")
    testConnection()
    configure()

    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, 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()
Ejemplo n.º 53
0
class Dingdang(object):
    def __init__(self):
        self._logger = logging.getLogger(__name__)
        self.config = config.profile

        try:
            stt_engine_slug = self.config['stt_engine']
        except KeyError:
            stt_engine_slug = 'snowboy-stt'
            logger.warning(
                "stt_engine not specified in profile, defaulting " + "to '%s'",
                stt_engine_slug)
        stt_engine_class = stt.get_engine_by_slug(stt_engine_slug)

        try:
            slug = self.config['stt_passive_engine']
            stt_passive_engine_class = stt.get_engine_by_slug(slug)
        except KeyError:
            stt_passive_engine_class = stt_engine_class

        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(self.config, tts_engine_class.get_instance(),
                       stt_passive_engine_class.get_passive_instance(),
                       stt_engine_class.get_active_instance())

        # config.set_uni_obj('mic', mic)
        # self.mic = config.get_uni_obj('mic')

    def start_wxbot(self):
        # create wechat robot
        if self.config['wechat']:
            logger.info("wxbot obj init")
            wb = config.get_uni_obj('wxbot')
            config.set_uni_obj('wxbot', None)
            if wb:
                wb.is_alive = False
            wxBot = WechatBot(self.conversation.brain)
            config.set_uni_obj('wxbot', wxBot)
            wxBot.DEBUG = True
            wxBot.conf['qr'] = 'tty'
            t = threading.Thread(target=self.wxbot_run, args=(wxBot, ))
            t.setDaemon(True)
            t.start()
            return wxBot

    def wxbot_run(self, wb):
        logger.info("wxbot thread running")
        try:
            wb.run(self.mic)
        except Exception:
            logger.error("wxbot Error occured!", exc_info=True)
        finally:
            logger.info("wxbot  thread finished!")

    def run(self):
        persona = '小安'
        if 'robot_name' in self.config:
            persona = self.config["robot_name"]
        master = "主人"
        if 'master_name' in self.config:
            master = self.config["master_name"]

        salutation = random.choice([
            "%s,%s 竭诚为您服务!" % (master, persona),
            "%s,%s能为你做什么?" % (master, persona)
        ])

        self.conversation = Conversation(persona, self.mic, self.config)
        self.start_wxbot()
        self.mic.say(salutation)
        if (db.get_instance().is_need_update()):
            t = self.mic.asyncSay("正在更新股票基本信息数据库")
            db.get_instance().updata_stock_basics()
            t.join()
            self.mic.say("更新完成")

        self.conversation.handleForever()