// speech libraries! lib 1000722 lib 1000723 lib 1000724 lib 1000730 lib 1000731 lib 1000732 lib 1000726 lib 1000727 import javax.speech.*; import javax.speech.synthesis.*; static Lock kevin_lock = fairLock(); sbool kevin_debug, kevin_disable, kevin_verbose; static Synthesizer kevin_synth; static float kevin_volume = 1f; static Float kevin_pitch, kevin_pitchRange, kevin_speakingRate; public static S kevin(String text) ctex { kevin_lock.lock(); if (kevin_verbose) print("Kevin: " + text); try { if (kevin_disable || kevin_synth != null && empty(trim(text))) return text; if (kevin_synth == null) { String voiceName = "kevin16"; System.setProperty("FreeTTSSynthEngineCentral", "com.sun.speech.freetts.jsapi.FreeTTSEngineCentral"); System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral"); SynthesizerModeDesc desc = new SynthesizerModeDesc(null, "general", Locale.US, null, null); if (kevin_debug) print("Creating synth"); Synthesizer synth = kevin_synth = Central.createSynthesizer(desc); synth.allocate(); desc = (SynthesizerModeDesc) synth.getEngineModeDesc(); Voice[] voices = desc.getVoices(); Voice voice = null; for (Voice entry : voices) { if(entry.getName().equals(voiceName)) { voice = entry; break; } } if (kevin_debug) print("Voice: " + voice); synth.getSynthesizerProperties().setVoice(voice); synth.resume(); } SynthesizerProperties props = kevin_synth.getSynthesizerProperties(); props.setVolume(kevin_volume); if (kevin_pitch != null) props.setPitch(kevin_pitch); if (kevin_pitchRange != null) props.setPitchRange(kevin_pitchRange); if (kevin_speakingRate != null) props.setSpeakingRate(kevin_speakingRate); if (kevin_debug) print("Speaking..."); logStructureWithDate(cereprocLog(), litorderedmap(action := "Begin talking", voice := "Kevin", +text)); kevin_synth.speakPlainText(text, null); if (kevin_debug) print("Waiting"); // TODO: We wait later anyway long state; int n = 0; while (((state = kevin_synth.getEngineState()) & Synthesizer.QUEUE_EMPTY) != 0) { sleep(50); if (++n >= 10000/50) { print("Engine state: " + state + ", aborting"); break; } } //kevin_synth.waitEngineState(Synthesizer.QUEUE_EMPTY); if (kevin_debug) print("Done"); logStructureWithDate(cereprocLog(), litorderedmap(action := "End talking", voice := "Kevin", +text)); // keep synth for next time //kevin_synth.deallocate(); ret text; } finally { kevin_lock.unlock(); } } static void kevin_init() { kevin(""); }
Began life as a copy of #1000721
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000737 |
Snippet name: | "kevin" function (talk as Kevin with FreeTTS) |
Eternal ID of this version: | #1000737/10 |
Text MD5: | eabe18dee4a8caf723f8f30d422111da |
Author: | stefan |
Category: | javax / speech |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-19 17:12:21 |
Source code size: | 2953 bytes / 90 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 945 / 1120 |
Version history: | 9 change(s) |
Referenced in: | #1002427 - Accellerating 629 (SPIKE) #1004756 - Test MBrola Voice (mbrola_us1) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1017444 - Try MBrola "us1" voice with FreeTTS [dev.] #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |