Skip to content

Commit 9e5633b

Browse files
authored
Final Pull (untouched from some day) (#5)
* Update TiTtsModule.java
1 parent 95f3d6a commit 9e5633b

File tree

3 files changed

+374
-29
lines changed

3 files changed

+374
-29
lines changed

README.md

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,24 @@ Simple tts (text-to-speech) module for Titanium SDK. Allows you to say a sentenc
55
## Methods
66

77
- <b>init()</b>
8-
- <b>speak(string)</b> - There is a character limit of 4000 characters per speak method
9-
- <b>synthesizeToFile(string)</b>
8+
- <b>init( engine: string )</b> - Init specific TTS Engine if available
9+
- <b>speak({ text: string, uid: string, volume: float, pan: float, flush: boolean })</b> - There is a character limit (of 4000 characters) per speak method. The exact maximum allowed length can be read from the bufferlen property.
10+
- <b>synthesizeToFile({ text: string, filename: string, uid: string, volume: float, pan: float, blob: boolean })</b>
11+
- <b>stop()</b>
12+
- <b>shutdown()</b>
13+
- <b>setup({ voice: string, language: string, volume: float, pan: float, speed: float, pitch: float, flush: boolean, uid: boolean, filename: string, blob: boolean})</b> - Default configuration for Speaker
14+
- <b>getVoices( filter: string )</b> - Returns a string with voices separated by a `|`. Optionally you can pass in a string to filter on voices names, for example `de-de` to only get German voices.
15+
- <b>getVoiceList( filter: string )</b>
16+
- <b>getEngines()</b>
17+
- <b>getEngineList()</b>
18+
- <b>getEnginePackageList()</b> - The Engines' Package Name for init(engine) and setEngine(engine).
19+
- <b>getLanguages()</b>
20+
- <b>getLanguageList()</b>
21+
- <b>getVoiceFeatures( voice: string )</b>
22+
- <b>initSilent()</b> - Init without events emitter (except for the init event once).
23+
- <b>emitEvents()</b> - Start events emitter.
24+
- <b>separateSpeaker()</b> - Return a new Instance of TTS ( Experimental feature, marked as Deprecated to notify it).
25+
- <b>setEngine( engine: string )</b> - Deprecated, because do not emit the init event when the engine is ready. Use init(engine) instead.
1026

1127
## Properties
1228

@@ -15,35 +31,84 @@ Simple tts (text-to-speech) module for Titanium SDK. Allows you to say a sentenc
1531
- <b>voices</b> (getter): string. Returns a string with voices separated by a `|`. Optional you can pass in `de-de` to only get German voices.
1632
- <b>voice</b> (setter): string
1733
- <b>language</b> (setter): string. e.g. `de` or `en`
34+
- <b>speaking</b> (getter): boolean. (DO NOT RELY ON THIS ON INIT! You could need to start flushing the queque after init. )
35+
- <b>bufferlen</b> (getter): int. Maximum length of the text string to read (Usually 4000 character)
1836

1937
## Events
2038

21-
- <b>init()</b>: when TTS is ready
22-
- <b>done()</b>: returns `blob` with the sound file
39+
- <b>init</b>: when TTS is ready - CallBack({ status: int })
40+
- <b>stop</b>: when TTS stops - CallBack({ uid: string, interrupted: boolean })
41+
- <b>error</b>: when TTS fails - CallBack({ uid: string, code: int })
42+
- <b>done</b>: when TTS has done (Could include a Blob for synthesizeToFile)- CallBack({ uid: string, blob: Blob })
2343

44+
## Voices' names
45+
46+
Voices' names are in the format:
47+
48+
<lang>-<region>-x-<flags>-<type>
49+
50+
Where:
51+
- &lt;lang&gt; and &lt;region&gt; are 2 char ISO codes (i.e. `it`, `de`, `en`)
52+
- &lt;flags&gt; is a usually 3 char voice description
53+
- &lt;type&gt; can be `local` (on device voice), `network` (on cloud voice) or `language` (not specified)
54+
55+
## Engines' names
56+
57+
Engines' names from getEngines and getEngineList are in the format:
58+
59+
<name> @<package>
60+
61+
Where:
62+
- &lt;name&gt; is the engine label name
63+
- &lt;package&gt; is the engine pakage name for setEngine(engine) and init(engine)
64+
65+
Engines' Package Names List can be retrived from getEnginePackageList().
66+
67+
## Setup Attributes
68+
69+
- volume: Float, Range [ 0 , 1 ], Default 1.
70+
- pan: Float, Range [ -1 , 1 ], Default 0.
71+
- pitch: Float, Default 1, lower for lower voice tone, greater to increase.
72+
- speed: Float, Default 1, 2 double speed, 0.5 half speed.
73+
- flush: Boolean, FLUSH the speak queque or ADD the text to speak to the queue (only for speak method).
74+
- blob: Retrive Blob to done event (only for synthesizeToFile method).
75+
- filename: File name (only for synthesizeToFile method).
76+
- uid: Utterance ID.
77+
78+
## Notes
79+
80+
- There is a limit of bufferlen (4000) characters for each call to speak and synthesizeToFile.
81+
- Sometimes after the init event a queque FLUSH could be needed to start speaking (especially if speaking is true).
82+
2483
## Example
2584

2685
```js
2786
const tts = require("ti.tts");
2887
const win = Ti.UI.createWindow();
2988

30-
win.open();
89+
tts.addEventListener("init", function(e) {
90+
91+
tts.speak({text:"Hello World!", flush:true});
92+
});
3193

3294
win.addEventListener("open", function() {
3395
tts.init();
3496
});
35-
tts.addEventListener("init", function(e) {
36-
tts.speak("Hello");
97+
win.addEventListener("close", function() {
98+
tts.shutdown();
3799
});
100+
101+
win.open();
38102
```
39103

40104
## Note
41105

42106
Needs Android 21 or higher.
43107

44108

45-
## Author
109+
## Authors
46110

47111
* Michael Gangolf (<a href="https://github.com/m1ga">@MichaelGangolf</a> / <a href="https://www.migaweb.de">Web</a>)
112+
* T. A. (<a href="https://github.com/informate">@TA</a> / <a href="https://www.informate.it">Web</a>)
48113

49114
<span class="badge-buymeacoffee"><a href="https://www.buymeacoffee.com/miga" title="donate"><img src="https://img.shields.io/badge/buy%20me%20a%20coke-donate-orange.svg" alt="Buy Me A Coke donate button" /></a></span>

0 commit comments

Comments
 (0)