Uses 13052K of libraries. Click here for Pure Java version (506L/4K/15K).
1 | !752 |
2 | |
3 | // speech libraries! |
4 | lib 1000722 |
5 | lib 1000723 |
6 | lib 1000724 |
7 | lib 1000730 |
8 | lib 1000731 |
9 | lib 1000732 |
10 | lib 1000726 |
11 | lib 1000727 |
12 | |
13 | import javax.speech.*; |
14 | import javax.speech.synthesis.*; |
15 | |
16 | p { |
17 | mbrola_debug = true; |
18 | mbrola("hello"); |
19 | } |
20 | |
21 | sbool mbrola_debug; |
22 | static Synthesizer mbrola_synth; |
23 | public static void mbrola(String text) ctex { |
24 | if (mbrola_synth != null && empty(trim(text))) return; |
25 | |
26 | if (mbrola_synth == null) { |
27 | String voiceName = "mbrola_us1"; |
28 | |
29 | System.setProperty("FreeTTSSynthEngineCentral", "com.sun.speech.freetts.jsapi.FreeTTSEngineCentral"); |
30 | System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); |
31 | Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral"); |
32 | |
33 | SynthesizerModeDesc desc = new SynthesizerModeDesc(null, "general", Locale.US, null, null); |
34 | |
35 | if (mbrola_debug) print("Creating synth"); |
36 | Synthesizer synth = mbrola_synth = Central.createSynthesizer(desc); |
37 | synth.allocate(); |
38 | desc = (SynthesizerModeDesc) synth.getEngineModeDesc(); |
39 | Voice[] voices = desc.getVoices(); |
40 | Voice voice = null; |
41 | for (Voice entry : voices) { |
42 | if(entry.getName().equals(voiceName)) { |
43 | voice = entry; |
44 | break; |
45 | } |
46 | } |
47 | if (mbrola_debug) print("Voice: " + voice); |
48 | synth.getSynthesizerProperties().setVoice(voice); |
49 | synth.resume(); |
50 | } |
51 | |
52 | if (mbrola_debug) print("Speaking..."); |
53 | mbrola_synth.speakPlainText(text, null); |
54 | if (mbrola_debug) print("Waiting"); |
55 | long state; |
56 | int n = 0; |
57 | while (((state = mbrola_synth.getEngineState()) & Synthesizer.QUEUE_EMPTY) != 0) { |
58 | sleep(50); |
59 | if (++n >= 10000/50) { |
60 | print("Engine state: " + state + ", aborting"); |
61 | break; |
62 | } |
63 | } |
64 | |
65 | //mbrola_synth.waitEngineState(Synthesizer.QUEUE_EMPTY); |
66 | if (mbrola_debug) print("Done"); |
67 | |
68 | // keep synth for next time |
69 | //mbrola_synth.deallocate(); |
70 | } |
Began life as a copy of #1000737
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004756 |
Snippet name: | Test MBrola Voice (mbrola_us1) |
Eternal ID of this version: | #1004756/1 |
Text MD5: | a9d29687b3a2ac6cf0bb387bab13ad57 |
Transpilation MD5: | 025fb1d0c271ef16f7eaa88e42e9b581 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-09 02:15:55 |
Source code size: | 1977 bytes / 70 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 559 / 685 |
Referenced in: | [show references] |