!7 sclass VoiceOutput > DynTextArea { S voice; float volume = 1f; transient JComboBox cbAnswerMode; start { if (empty(voice)) setField(voice := first(cereprocVoices())); set cereproc_printPageLoads; } visualize { //bindComboBoxToLiveValue_debug.set(true); JComponent ta = super.visualize(); enableWordWrapForTextArea(textArea); //jPreemptEnterKey(textArea, rThread sayIt); onCtrlEnter(textArea, rThread sayIt); ret centerAndSouthWithMargins(ta, jvstackWithSpacing( centerAndEastWithMarginInbetween(withLabel("Voice:", jLiveValueComboBox(cereprocPlusLocalVoices(), dm_fieldLiveValue('voice))), jbutton("Say", rThread sayIt)), withLabel("Volume (Kevin only):", jLiveValueSlider(dm_fieldLiveValue('volume))), jrightAlignedLine(jlabel("AI should answer (not really used yet):"), jComboBoxOnTrimmedFileContents(ll("Always", "Sometimes", "Never"), ai_answerModeFile(), ai_answerModeDefault())))); } // API void say(S s) { temp enter(); { lock lock; setText(s); } sayIt(); } void sayIt { temp enter(); S s = trim(getText()); if (empty(s) || empty(voice)) ret; for (fS line : tlft(s)) { vmBus_send('talking, line, voice); afterwards { vmBus_send('doneTalking, line, voice); } if (isCereprocVoice(voice)) cereproc(voice, line); else if (eq(voice, 'Kevin)) { kevin_volume = volume; kevin(line); } else print("Missing voice: " + voice); } } void clear() { setText(""); } void setVoice(S voice) { setField(+voice); } void preload(S s) { temp enter(); if (isCereprocVoice(voice)) cereproc_preload(voice, s); } }