def insert_speak(whatToSay, voiceToUse, ttsEngine): model = get_current_model() action_set = ActionSet() shouldBlock = main_window.blockingSpeechCheckbox.isChecked() try: action = Pr2SpeakAction( Toolbox.getInstance(), whatToSay, voice=voiceToUse, ttsEngine=ttsEngine, waitForSpeechDone=shouldBlock ) except ValueError as e: self.dialogService.showErrorMsg(str(e)) return action_set.add_action(action) model.add_action(action_set)
def __init__(self, toolbox=None, utterance='!None!', voice='voice_kal_diphone', ttsEngine='festival', waitForSpeechDone=True): super(Pr2SpeakAction, self).__init__(); # Toolbox is None if this instance is created from # deserialization. if toolbox is None: self.toolbox = Toolbox.getInstance(); else: self.toolbox = toolbox; self.utterance = utterance; self.voice = voice; self.ttsEngine = ttsEngine; self._timer = None; self.waitForSpeechDone = waitForSpeechDone; # In the following, the term '_settings' would make more # sense, but other parts of the code rely on _joints as # the name: self._joints = [{'label': 'speak', 'checkboxLabel': 'Stop till speech done', 'text': utterance, 'waitForSpeechDone': waitForSpeechDone}] self.initLocalOperation(); Pr2SpeakAction.registerSpeechAct(self);
def setUp(self): self.toolbox = Toolbox.getInstance();