コード例 #1
0
    def handle_face_interaction(self, message):
        name = str(message.data.get('name'))
        print(name)
        self.speak("welcome Mr. " + name + " to confluence 2019")

        answer = self.get_response("how was your travel Mister " + name + "?")

        if 'ok' in answer or 'not' in answer or 'hectic':
            answer = self.get_response(
                "ooh.. in that case can i entertain you with a joke")
            if 'yes' or 'joke' in answer:
                self.speak("okay here goes a joke....")
                self.bus.emit(
                    Message("recognizer_loop:utterance", {
                        'utterances': ["joke"],
                        'lang': 'en-us'
                    }))

            else:
                self.speak("okay here goes a song....")
                self.bus.emit(
                    Message("recognizer_loop:utterance", {
                        'utterances': ["sing a song"],
                        'lang': 'en-us'
                    }))

        time.sleep(6)
        answer = self.get_response("would you also like to see some demo?")
        if 'yes' in answer:
            self.speak("alright here you go: dham dham dham")
コード例 #2
0
    def handle_put_intent(self, message):
        LOG.info("Starting registration")

        # objectname = message.data["utterance"].split()[1]
        objectname = self.get_response("hover.registerobjectname")

        #Handlers
        def yesnovalidation(utternance):
            return "yes" in utternance or "no" in utternance

        def yesnofail(utterance):
            return "Please only say yes or no"

        res = self.get_response("hover.registerconfirm",
                                data={"object": objectname},
                                validator=yesnovalidation,
                                on_fail=yesnofail,
                                num_retries=1)
        if "yes" in res:
            #handleyes
            def infovalidation(utternance):
                return True

            def infofail(utterance):
                testmessage = Message("hover_put",
                                      data={
                                          "status": "fail",
                                          "error": "No in confirmation."
                                      })
                self.bus.emit(testmessage)
                return "Please restart the registration process..."

            objectinformation = self.get_response("hover.requestinfo",
                                                  data={"item": objectname})

            data = self.empty_item.copy()

            data["classname"] = objectname
            data["info"] = objectinformation

            self.db.insert(data)
            self.speak("Registration completed")
            testmessage = Message("hover_put",
                                  data={
                                      "status": "success",
                                      "error": ""
                                  })
            self.bus.emit(testmessage)
        else:
            self.speak("Alright")
            testmessage = Message("hover_put",
                                  data={
                                      "status": "success",
                                      "error": "user cancelled"
                                  })

        LOG.info("Registration finished")
コード例 #3
0
 def infofail(utterance):
     testmessage = Message("hover_put",
                           data={
                               "status": "fail",
                               "error": "No in confirmation."
                           })
     self.bus.emit(testmessage)
     return "Please restart the registration process..."
コード例 #4
0
    def record_wav(self):
        audio_file = resolve_resource_file(
            self.config_core.get('sounds').get('start_listening'))
        if audio_file:
            play_wav(audio_file).wait()

        self.bus.emit(Message('mycroft.mic.mute'))
        try:
            fd, tmp_file = mkstemp('.wav')
            subprocess.Popen([
                "arecord", "-f", "S16_LE", "-r",
                str(16000), "-c",
                str(1), "-d",
                str(10), tmp_file
            ]).wait()
        finally:
            self.bus.emit(Message('mycroft.mic.unmute'))
        return tmp_file
コード例 #5
0
    def handle_get_intent(self, message):
        LOG.info("Doing a get")
        LOG.info(message)
        objectname = message.data["utterance"].split()[1]
        try:
            classinfo = Query()
            res = self.db.search(classinfo.classname == objectname)
            if len(res) == 0:
                self.speak("Sorry, I don't know what that is")
                testmessage = Message("hover_get",
                                      data={
                                          "status": "success",
                                          "error": ""
                                      })
                self.bus.emit(testmessage)
                return
            item = objectname
            information = res[0]["info"]
            additional = ""
            self.speak_dialog("hover.info",
                              data={
                                  "item": item,
                                  "information": information,
                                  "additional": additional
                              })

            testmessage = Message("hover_get",
                                  data={
                                      "status": "success",
                                      "error": ""
                                  })
            self.bus.emit(testmessage)

        except:
            testmessage = Message("hover_get",
                                  data={
                                      "status": "fail",
                                      "error": "No matches"
                                  })
            self.bus.emit(testmessage)
            self.speak("Sorry, I don't know what that is")
コード例 #6
0
    def save_upgrade_permission(self, ver):
        # Build version as float, e.g. [18,8,999] as 18.8
        float_ver = ver[0] + ver[1] / 10  # assumes minor is <= 9
        new_conf_values = {"max_allowed_core_version": float_ver}

        # Save under the user (e.g. ~/.mycroft/mycroft.conf)
        user_config = LocalConf(USER_CONFIG)
        user_config.merge(new_conf_values)
        user_config.store()

        # Notify all processes to update their loaded configs
        self.bus.emit(Message('configuration.updated'))
コード例 #7
0
 def _ask_about_major_upgrade(self):
     # Get user permission for major upgrade
     resp = self.ask_yesno('major.upgrade',
                           data=self.ver_data(self.latest_ver))
     if resp == 'yes':
         # Save consent
         self.save_upgrade_permission(self.latest_ver)
         self.speak_dialog('upgrade.started')
         plat = self.config_core.get('enclosure', {}).get('platform')
         self.bus.emit(
             Message('system.update', {
                 'is_paired': True,
                 'platform': plat
             }))
     else:
         self.speak_dialog('major.upgrade.declined')
コード例 #8
0
    def check_version(self, message):
        # Report the version of mycroft-core software
        self.query_for_latest_ver()
        cur_ver = [CORE_VERSION_MAJOR, CORE_VERSION_MINOR, CORE_VERSION_BUILD]
        new_ver = self.latest_ver
        allowed_ver = self.get_allowed_ver()
        self.log.info("Current version: " + str(cur_ver))
        self.log.info("Latest version: " + str(new_ver))
        self.log.info("Allowed version: " + str(allowed_ver))

        # display the version on the device screen and speak it
        self.enclosure.deactivate_mouth_events()
        self.enclosure.mouth_text(CORE_VERSION_STR + "b")  # b for Beta
        self.speak_dialog('version', self.ver_data(cur_ver))
        mycroft.util.wait_while_speaking()
        self.enclosure.activate_mouth_events()

        if cur_ver == new_ver:
            self.speak_dialog('version.latest')
        elif new_ver > allowed_ver:
            self.inform_user()
        elif cur_ver < new_ver and self.upgrade_possible():
            # Ask user if they want to update immediately
            resp = self.ask_yesno('ask.upgrade', data=self.ver_data(new_ver))
            if resp == 'yes':
                self.speak_dialog('upgrade.started')
                self.save_upgrade_permission(self.latest_ver)
                # TODO: On Github install, should we tell users how to update?
                plat = self.config_core.get('enclosure', {}).get('platform')
                self.bus.emit(
                    Message('system.update', {
                        'is_paired': True,
                        'platform': plat
                    }))
            else:
                self.speak_dialog('upgrade.cancelled')
        else:
            self.speak_dialog('update.available', data=self.ver_data(new_ver))
        self.reschedule_reminder()
コード例 #9
0
 def __api_error(self, e):
     if e.response.status_code == 401:
         from mycroft import Message
         self.bus.emit(Message("mycroft.not.paired"))
コード例 #10
0
 def setup(self):
     self.emitter = ThreadedEventEmitter()
     self.count = 0
     self.msg = Message('testing')
コード例 #11
0
ファイル: __init__.py プロジェクト: marvin-w/respeaker-skill
 def released():
     """Executed when released."""
     self.bus.emit(Message("mycroft.mic.listen"))
コード例 #12
0
 def start_face_interaction_skill(self):
     print("inside face interaction skill")
     self.bus.emit(Message("recognizer_loop:utterance",
                           {'utterances': ["face recognition greet anupam"],
                            'lang': 'en-us'}))