Beispiel #1
0
    def refresh(self, *args):
        '''args: spec, list of lists of strings'''

        # get mapping
        recorded_macros = utilities.load_toml_file(
            settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        if len(args) > 0:
            recorded_macros[args[0]] = args[1]
            utilities.save_toml_file(
                recorded_macros,
                settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        mapping = {}
        for spec in recorded_macros:
            sequences = recorded_macros[spec]
            delay = settings.SETTINGS["miscellaneous"][
                "history_playback_delay_secs"]
            play = Playback([(sequence, delay) for sequence in sequences])
            command = play * Repeat(
                extra="n") if spec.endswith("[times <n>]") else play
            mapping[spec] = R(command, rdescript="Recorded Macro: " + spec)
        mapping["record from history"] = R(Function(self.record_from_history),
                                           rdescript="Record From History")
        mapping["delete recorded macros"] = R(
            Function(self.delete_recorded_macros),
            rdescript="Delete Recorded Macros")
        # reload with new mapping
        self.reset(mapping)
Beispiel #2
0
    def refresh(self, *args):
        '''args: spec, list of lists of strings'''

        # get mapping
        recorded_macros = utilities.load_toml_file(
            settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        if len(args) > 0:
            recorded_macros[args[0]] = args[1]
            utilities.save_toml_file(recorded_macros,
                                     settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
        mapping = {}
        for spec in recorded_macros:
            # Create a copy of the string without Unicode characters.
            ascii_str = str(spec)
            sequences = recorded_macros[spec]
            delay = settings.SETTINGS["miscellaneous"]["history_playback_delay_secs"]
            # It appears that the associative string (ascii_str) must be ascii, but the sequences within Playback must be Unicode.
            mapping[ascii_str] = R(
                Playback([(sequence, delay) for sequence in sequences]),
                rdescript="Recorded Macro: " + ascii_str)
        mapping["record from history"] = R(
            Function(self.record_from_history), rdescript="Record From History")
        mapping["delete recorded macros"] = R(
            Function(self.delete_recorded_macros), rdescript="Delete Recorded Macros")
        # reload with new mapping
        self.reset(mapping)
Beispiel #3
0
 def _deserialize(self):
     mapping = {}
     recorded_macros = self._config.get_copy()
     for spec in recorded_macros:
         sequences = recorded_macros[spec]
         delay = settings.settings(["miscellaneous", "history_playback_delay_secs"])
         # The associative string (ascii_str) must be ascii, but the sequences within Playback must be Unicode.
         mapping[spec] = R(
             Playback([(sequence, delay) for sequence in sequences]),
             rdescript="Recorded Macro: " + spec) * Repeat(extra="n")
     mapping["record from history"] = R(
         Function(lambda: self._record_from_history()), rdescript="Record From History")
     mapping["delete recorded macros"] = R(
         Function(lambda: self._delete_recorded_macros()), rdescript="Delete Recorded Macros")
     self._smr_mapping = mapping
Beispiel #4
0
 def refresh(self, *args):
     '''args: spec, list of lists of strings'''
     
     # get mapping
     recorded_macros = utilities.load_json_file(settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
     if len(args)>0:
         recorded_macros[args[0]] = args[1]
         utilities.save_json_file(recorded_macros, settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
     mapping = {}
     for spec in recorded_macros:
         sequences = recorded_macros[spec]
         mapping[spec] = R(Playback([(sequence, 0.0) for sequence in sequences])*Repeat(extra="n"), rdescript="Recorded Macro: "+spec)
     mapping["record from history"] = R(Function(self.record_from_history), rdescript="Record From History")
     mapping["delete recorded macros"] = R(Function(self.delete_recorded_macros), rdescript="Delete Recorded Macros")
     # reload with new mapping
     self.reset(mapping)
Beispiel #5
0
 def _repeat(self, utterance):
     Playback([(utterance, 0.0)]).execute()
     return False
Beispiel #6
0
def get_playback(commands):
    '''commands is an array of strings'''
    playback_tuples = [(utterance.split(" "), 1.0) for utterance in commands]
    return Playback(playback_tuples)
Beispiel #7
0
 def _repeat(self, utterance):
     print("utterance: ", utterance)
     Playback([(utterance, 0.0)]).execute()
     return False