@capacitor-community/text-to-speech 0.2.3 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorCommunityTextToSpeech.podspec +1 -1
- package/LICENSE +1 -1
- package/README.md +169 -113
- package/android/build.gradle +14 -8
- package/android/src/main/AndroidManifest.xml +3 -5
- package/android/src/main/java/com/getcapacitor/community/tts/SpeakResultCallback.java +6 -0
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeech.java +98 -180
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeechPlugin.java +130 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +194 -0
- package/dist/esm/definitions.d.ts +70 -17
- package/dist/esm/definitions.js +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +9 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +7 -9
- package/dist/esm/web.js +48 -76
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +57 -75
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +59 -75
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Info.plist +1 -1
- package/ios/Plugin/TextToSpeech.swift +81 -0
- package/ios/Plugin/{Plugin.h → TextToSpeechPlugin.h} +0 -0
- package/ios/Plugin/{Plugin.m → TextToSpeechPlugin.m} +2 -3
- package/ios/Plugin/TextToSpeechPlugin.swift +64 -0
- package/package.json +36 -21
- package/CHANGELOG.md +0 -46
- package/android/src/main/java/com/getcapacitor/community/tts/Constant.java +0 -8
- package/android/src/main/res/layout/bridge_layout_main.xml +0 -15
- package/android/src/main/res/values/colors.xml +0 -3
- package/android/src/main/res/values/strings.xml +0 -3
- package/android/src/main/res/values/styles.xml +0 -3
- package/ios/Plugin/Plugin.swift +0 -119
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
package com.getcapacitor.community.tts;
|
|
2
2
|
|
|
3
|
-
import static com.getcapacitor.community.tts.Constant.ERROR_TTS_NOT_INITIALIZED;
|
|
4
|
-
import static com.getcapacitor.community.tts.Constant.ERROR_UNSUPPORTED_LOCALE;
|
|
5
|
-
import static com.getcapacitor.community.tts.Constant.ERROR_UTTERANCE;
|
|
6
|
-
|
|
7
3
|
import android.content.Context;
|
|
8
4
|
import android.content.Intent;
|
|
9
5
|
import android.content.pm.PackageManager;
|
|
@@ -15,220 +11,142 @@ import android.speech.tts.Voice;
|
|
|
15
11
|
import android.util.Log;
|
|
16
12
|
import com.getcapacitor.JSArray;
|
|
17
13
|
import com.getcapacitor.JSObject;
|
|
18
|
-
import com.getcapacitor.NativePlugin;
|
|
19
|
-
import com.getcapacitor.Plugin;
|
|
20
|
-
import com.getcapacitor.PluginCall;
|
|
21
|
-
import com.getcapacitor.PluginMethod;
|
|
22
14
|
import java.util.ArrayList;
|
|
23
15
|
import java.util.HashMap;
|
|
24
16
|
import java.util.Locale;
|
|
25
17
|
import java.util.Set;
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
public class TextToSpeech extends Plugin implements android.speech.tts.TextToSpeech.OnInitListener {
|
|
19
|
+
public class TextToSpeech implements android.speech.tts.TextToSpeech.OnInitListener {
|
|
29
20
|
|
|
30
|
-
public static final String
|
|
21
|
+
public static final String LOG_TAG = "TextToSpeech";
|
|
31
22
|
|
|
32
|
-
private
|
|
23
|
+
private Context context;
|
|
33
24
|
private android.speech.tts.TextToSpeech tts = null;
|
|
34
|
-
private
|
|
35
|
-
private
|
|
25
|
+
private int initializationStatus;
|
|
26
|
+
private JSObject[] supportedVoices = null;
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
TextToSpeech(Context context) {
|
|
29
|
+
this.context = context;
|
|
39
30
|
try {
|
|
40
|
-
|
|
41
|
-
tts = null;
|
|
42
|
-
ttsInitialized = false;
|
|
43
|
-
} else {
|
|
44
|
-
if (Build.VERSION.SDK_INT >= 21) {
|
|
45
|
-
Bundle ttsParams = new Bundle();
|
|
46
|
-
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "");
|
|
47
|
-
tts.setLanguage(new Locale("en", "US"));
|
|
48
|
-
tts.speak("", android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams, "");
|
|
49
|
-
} else {
|
|
50
|
-
HashMap<String, String> ttsParams = new HashMap<>();
|
|
51
|
-
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "");
|
|
52
|
-
tts.setLanguage(new Locale("en", "US"));
|
|
53
|
-
tts.speak("", android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams);
|
|
54
|
-
}
|
|
55
|
-
Set<Locale> availableLanguages = tts.getAvailableLanguages();
|
|
56
|
-
if (availableLanguages != null) {
|
|
57
|
-
this.supportedLocales.addAll(availableLanguages);
|
|
58
|
-
}
|
|
59
|
-
ttsInitialized = true;
|
|
60
|
-
}
|
|
31
|
+
tts = new android.speech.tts.TextToSpeech(context, this);
|
|
61
32
|
} catch (Exception ex) {
|
|
62
|
-
Log.d(
|
|
63
|
-
|
|
64
|
-
ttsInitialized = false;
|
|
33
|
+
Log.d(LOG_TAG, ex.getLocalizedMessage());
|
|
65
34
|
}
|
|
66
35
|
}
|
|
67
36
|
|
|
68
37
|
@Override
|
|
69
|
-
public void
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
context = getContext();
|
|
74
|
-
tts = new android.speech.tts.TextToSpeech(context, this);
|
|
75
|
-
} catch (Exception ex) {
|
|
76
|
-
Log.d(TAG, "Caught exception on TextToSpeech load(): " + ex.getLocalizedMessage());
|
|
77
|
-
}
|
|
38
|
+
public void onInit(int status) {
|
|
39
|
+
this.initializationStatus = status;
|
|
78
40
|
}
|
|
79
41
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
42
|
+
public void speak(
|
|
43
|
+
String text,
|
|
44
|
+
String lang,
|
|
45
|
+
float rate,
|
|
46
|
+
float pitch,
|
|
47
|
+
float volume,
|
|
48
|
+
String callbackId,
|
|
49
|
+
SpeakResultCallback resultCallback
|
|
50
|
+
) {
|
|
51
|
+
tts.stop();
|
|
52
|
+
tts.setOnUtteranceProgressListener(
|
|
53
|
+
new UtteranceProgressListener() {
|
|
54
|
+
@Override
|
|
55
|
+
public void onStart(String utteranceId) {}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public void onDone(String utteranceId) {
|
|
59
|
+
resultCallback.onDone();
|
|
60
|
+
}
|
|
98
61
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
new UtteranceProgressListener() {
|
|
103
|
-
@Override
|
|
104
|
-
public void onStart(String utteranceId) {}
|
|
105
|
-
|
|
106
|
-
@Override
|
|
107
|
-
public void onDone(String utteranceId) {
|
|
108
|
-
if (!utteranceId.equals("")) {
|
|
109
|
-
call.success();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@Override
|
|
114
|
-
public void onError(String utteranceId) {
|
|
115
|
-
if (!utteranceId.equals("")) {
|
|
116
|
-
call.error(ERROR_UTTERANCE);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
62
|
+
@Override
|
|
63
|
+
public void onError(String utteranceId) {
|
|
64
|
+
resultCallback.onError();
|
|
119
65
|
}
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
if (Build.VERSION.SDK_INT >= 21) {
|
|
123
|
-
Bundle ttsParams = new Bundle();
|
|
124
|
-
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, call.getCallbackId());
|
|
125
|
-
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, volume);
|
|
126
|
-
|
|
127
|
-
tts.setLanguage(new Locale(locale));
|
|
128
|
-
tts.setSpeechRate(speechRate);
|
|
129
|
-
tts.setPitch(pitchRate);
|
|
130
|
-
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams, call.getCallbackId());
|
|
131
|
-
} else {
|
|
132
|
-
HashMap<String, String> ttsParams = new HashMap<>();
|
|
133
|
-
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, call.getCallbackId());
|
|
134
|
-
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, Double.toString(volume));
|
|
135
|
-
|
|
136
|
-
tts.setLanguage(new Locale(locale));
|
|
137
|
-
tts.setPitch(pitchRate);
|
|
138
|
-
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams);
|
|
139
66
|
}
|
|
140
|
-
|
|
141
|
-
Log.d(TAG, "Exception caught while handling speak(): " + ex.getLocalizedMessage());
|
|
142
|
-
call.error(ex.getLocalizedMessage());
|
|
143
|
-
}
|
|
144
|
-
}
|
|
67
|
+
);
|
|
145
68
|
|
|
146
|
-
|
|
147
|
-
public void stop(PluginCall call) {
|
|
148
|
-
try {
|
|
149
|
-
tts.stop();
|
|
150
|
-
call.success();
|
|
151
|
-
} catch (Exception ex) {
|
|
152
|
-
Log.d(TAG, "Exception caught while handling stop(): " + ex.getLocalizedMessage());
|
|
153
|
-
call.error(ex.getLocalizedMessage());
|
|
154
|
-
}
|
|
155
|
-
}
|
|
69
|
+
Locale locale = Locale.forLanguageTag(lang);
|
|
156
70
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
71
|
+
if (Build.VERSION.SDK_INT >= 21) {
|
|
72
|
+
Bundle ttsParams = new Bundle();
|
|
73
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
74
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, volume);
|
|
75
|
+
|
|
76
|
+
tts.setLanguage(locale);
|
|
77
|
+
tts.setSpeechRate(rate);
|
|
78
|
+
tts.setPitch(pitch);
|
|
79
|
+
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams, callbackId);
|
|
80
|
+
} else {
|
|
81
|
+
HashMap<String, String> ttsParams = new HashMap<>();
|
|
82
|
+
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
83
|
+
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, Float.toString(volume));
|
|
84
|
+
|
|
85
|
+
tts.setLanguage(locale);
|
|
86
|
+
tts.setSpeechRate(rate);
|
|
87
|
+
tts.setPitch(pitch);
|
|
88
|
+
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams);
|
|
171
89
|
}
|
|
172
90
|
}
|
|
173
91
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
float pitchRate = call.getFloat("pitchRate", 1.0f);
|
|
177
|
-
tts.setPitch(pitchRate);
|
|
178
|
-
|
|
179
|
-
call.success();
|
|
92
|
+
public void stop() {
|
|
93
|
+
tts.stop();
|
|
180
94
|
}
|
|
181
95
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
} else {
|
|
189
|
-
tts.setSpeechRate((float) speechRate);
|
|
96
|
+
public JSArray getSupportedLanguages() {
|
|
97
|
+
ArrayList<String> languages = new ArrayList<>();
|
|
98
|
+
Set<Locale> supportedLocales = tts.getAvailableLanguages();
|
|
99
|
+
for (Locale supportedLocale : supportedLocales) {
|
|
100
|
+
String tag = supportedLocale.toLanguageTag();
|
|
101
|
+
languages.add(tag);
|
|
190
102
|
}
|
|
191
|
-
|
|
192
|
-
|
|
103
|
+
JSArray result = JSArray.from(languages.toArray());
|
|
104
|
+
return result;
|
|
193
105
|
}
|
|
194
106
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
107
|
+
public JSArray getSupportedVoices() {
|
|
108
|
+
ArrayList<JSObject> voices = new ArrayList<>();
|
|
109
|
+
Set<Voice> supportedVoices = tts.getVoices();
|
|
110
|
+
for (Voice supportedVoice : supportedVoices) {
|
|
111
|
+
JSObject obj = this.convertVoiceToJSObject(supportedVoice);
|
|
112
|
+
voices.add(obj);
|
|
113
|
+
}
|
|
114
|
+
JSArray result = JSArray.from(voices.toArray());
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
201
117
|
|
|
202
|
-
|
|
118
|
+
public void openInstall() {
|
|
119
|
+
PackageManager packageManager = context.getPackageManager();
|
|
120
|
+
Intent installIntent = new Intent();
|
|
121
|
+
installIntent.setAction(android.speech.tts.TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
|
|
203
122
|
|
|
204
|
-
|
|
205
|
-
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
206
|
-
context.startActivity(installIntent);
|
|
207
|
-
}
|
|
123
|
+
ResolveInfo resolveInfo = packageManager.resolveActivity(installIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
208
124
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
125
|
+
if (resolveInfo != null) {
|
|
126
|
+
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
127
|
+
context.startActivity(installIntent);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
212
130
|
|
|
213
|
-
|
|
131
|
+
public boolean isAvailable() {
|
|
132
|
+
if (tts != null && initializationStatus == android.speech.tts.TextToSpeech.SUCCESS) {
|
|
133
|
+
return true;
|
|
214
134
|
}
|
|
135
|
+
return false;
|
|
215
136
|
}
|
|
216
137
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
JSObject ret = new JSObject();
|
|
227
|
-
ret.put("voices", JSArray.from(voices.toArray()));
|
|
228
|
-
call.success(ret);
|
|
229
|
-
} catch (Exception ex) {
|
|
230
|
-
call.error(ex.getLocalizedMessage());
|
|
138
|
+
public boolean isLanguageSupported(String lang) {
|
|
139
|
+
Locale locale = Locale.forLanguageTag(lang);
|
|
140
|
+
int result = tts.isLanguageAvailable(locale);
|
|
141
|
+
return result == tts.LANG_AVAILABLE || result == tts.LANG_COUNTRY_AVAILABLE || result == tts.LANG_COUNTRY_VAR_AVAILABLE;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public void onDestroy() {
|
|
145
|
+
if (tts == null) {
|
|
146
|
+
return;
|
|
231
147
|
}
|
|
148
|
+
tts.stop();
|
|
149
|
+
tts.shutdown();
|
|
232
150
|
}
|
|
233
151
|
|
|
234
152
|
private JSObject convertVoiceToJSObject(Voice voice) {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.getcapacitor.community.tts;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSArray;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
|
|
10
|
+
@CapacitorPlugin(name = "TextToSpeech")
|
|
11
|
+
public class TextToSpeechPlugin extends Plugin {
|
|
12
|
+
|
|
13
|
+
public static final String LOG_TAG = "TextToSpeechPlugin";
|
|
14
|
+
|
|
15
|
+
public static final String ERROR_UTTERANCE = "Failed to read text.";
|
|
16
|
+
public static final String ERROR_UNSUPPORTED_LANGUAGE = "This language is not supported.";
|
|
17
|
+
|
|
18
|
+
private TextToSpeech implementation;
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public void load() {
|
|
22
|
+
implementation = new TextToSpeech(getContext());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@PluginMethod
|
|
26
|
+
public void speak(PluginCall call) {
|
|
27
|
+
boolean isAvailable = implementation.isAvailable();
|
|
28
|
+
if (!isAvailable) {
|
|
29
|
+
call.unavailable("Not yet initialized or not available on this device.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
String text = call.getString("text", "");
|
|
34
|
+
String lang = call.getString("lang", "en-US");
|
|
35
|
+
float rate = call.getFloat("rate", 1.0f);
|
|
36
|
+
float pitch = call.getFloat("pitch", 1.0f);
|
|
37
|
+
float volume = call.getFloat("volume", 1.0f);
|
|
38
|
+
|
|
39
|
+
boolean isLanguageSupported = implementation.isLanguageSupported(lang);
|
|
40
|
+
if (!isLanguageSupported) {
|
|
41
|
+
call.reject(ERROR_UNSUPPORTED_LANGUAGE);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
SpeakResultCallback resultCallback = new SpeakResultCallback() {
|
|
46
|
+
@Override
|
|
47
|
+
public void onDone() {
|
|
48
|
+
call.resolve();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void onError() {
|
|
53
|
+
call.reject(ERROR_UTTERANCE);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
implementation.speak(text, lang, rate, pitch, volume, call.getCallbackId(), resultCallback);
|
|
59
|
+
} catch (Exception ex) {
|
|
60
|
+
call.reject(ex.getLocalizedMessage());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@PluginMethod
|
|
65
|
+
public void stop(PluginCall call) {
|
|
66
|
+
boolean isAvailable = implementation.isAvailable();
|
|
67
|
+
if (!isAvailable) {
|
|
68
|
+
call.unavailable("Not yet initialized or not available on this device.");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
implementation.stop();
|
|
73
|
+
call.resolve();
|
|
74
|
+
} catch (Exception ex) {
|
|
75
|
+
call.reject(ex.getLocalizedMessage());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@PluginMethod
|
|
80
|
+
public void getSupportedLanguages(PluginCall call) {
|
|
81
|
+
try {
|
|
82
|
+
JSArray languages = implementation.getSupportedLanguages();
|
|
83
|
+
JSObject ret = new JSObject();
|
|
84
|
+
ret.put("languages", languages);
|
|
85
|
+
call.resolve(ret);
|
|
86
|
+
} catch (Exception ex) {
|
|
87
|
+
call.reject(ex.getLocalizedMessage());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@PluginMethod
|
|
92
|
+
public void getSupportedVoices(PluginCall call) {
|
|
93
|
+
try {
|
|
94
|
+
JSArray voices = implementation.getSupportedVoices();
|
|
95
|
+
JSObject ret = new JSObject();
|
|
96
|
+
ret.put("voices", voices);
|
|
97
|
+
call.resolve(ret);
|
|
98
|
+
} catch (Exception ex) {
|
|
99
|
+
call.reject(ex.getLocalizedMessage());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@PluginMethod
|
|
104
|
+
public void isLanguageSupported(PluginCall call) {
|
|
105
|
+
String lang = call.getString("lang", "");
|
|
106
|
+
try {
|
|
107
|
+
boolean isLanguageSupported = implementation.isLanguageSupported(lang);
|
|
108
|
+
JSObject ret = new JSObject();
|
|
109
|
+
ret.put("supported", isLanguageSupported);
|
|
110
|
+
call.resolve(ret);
|
|
111
|
+
} catch (Exception ex) {
|
|
112
|
+
call.reject(ex.getLocalizedMessage());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@PluginMethod
|
|
117
|
+
public void openInstall(PluginCall call) {
|
|
118
|
+
try {
|
|
119
|
+
implementation.openInstall();
|
|
120
|
+
call.resolve();
|
|
121
|
+
} catch (Exception ex) {
|
|
122
|
+
call.reject(ex.getLocalizedMessage());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
protected void handleOnDestroy() {
|
|
128
|
+
implementation.onDestroy();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "TextToSpeechPlugin",
|
|
4
|
+
"slug": "texttospeechplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "speak",
|
|
10
|
+
"signature": "(options: TTSOptions) => Promise<void>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "TTSOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<void>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "Starts the TTS engine and plays the desired text.",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"TTSOptions"
|
|
23
|
+
],
|
|
24
|
+
"slug": "speak"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "stop",
|
|
28
|
+
"signature": "() => Promise<void>",
|
|
29
|
+
"parameters": [],
|
|
30
|
+
"returns": "Promise<void>",
|
|
31
|
+
"tags": [],
|
|
32
|
+
"docs": "Stops the TTS engine.",
|
|
33
|
+
"complexTypes": [],
|
|
34
|
+
"slug": "stop"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "getSupportedLanguages",
|
|
38
|
+
"signature": "() => Promise<{ languages: string[]; }>",
|
|
39
|
+
"parameters": [],
|
|
40
|
+
"returns": "Promise<{ languages: string[]; }>",
|
|
41
|
+
"tags": [],
|
|
42
|
+
"docs": "Returns a list of supported BCP 47 language tags.",
|
|
43
|
+
"complexTypes": [],
|
|
44
|
+
"slug": "getsupportedlanguages"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "getSupportedVoices",
|
|
48
|
+
"signature": "() => Promise<{ voices: SpeechSynthesisVoice[]; }>",
|
|
49
|
+
"parameters": [],
|
|
50
|
+
"returns": "Promise<{ voices: SpeechSynthesisVoice[]; }>",
|
|
51
|
+
"tags": [],
|
|
52
|
+
"docs": "Returns a list of supported voices.",
|
|
53
|
+
"complexTypes": [
|
|
54
|
+
"SpeechSynthesisVoice"
|
|
55
|
+
],
|
|
56
|
+
"slug": "getsupportedvoices"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "isLanguageSupported",
|
|
60
|
+
"signature": "(options: { lang: string; }) => Promise<{ supported: boolean; }>",
|
|
61
|
+
"parameters": [
|
|
62
|
+
{
|
|
63
|
+
"name": "options",
|
|
64
|
+
"docs": "",
|
|
65
|
+
"type": "{ lang: string; }"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"returns": "Promise<{ supported: boolean; }>",
|
|
69
|
+
"tags": [],
|
|
70
|
+
"docs": "Checks if a specific BCP 47 language tag is supported.",
|
|
71
|
+
"complexTypes": [],
|
|
72
|
+
"slug": "islanguagesupported"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "openInstall",
|
|
76
|
+
"signature": "() => Promise<void>",
|
|
77
|
+
"parameters": [],
|
|
78
|
+
"returns": "Promise<void>",
|
|
79
|
+
"tags": [],
|
|
80
|
+
"docs": "Verifies proper installation and availability of resource files on the system.\n\nOnly available for Android.",
|
|
81
|
+
"complexTypes": [],
|
|
82
|
+
"slug": "openinstall"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"properties": []
|
|
86
|
+
},
|
|
87
|
+
"interfaces": [
|
|
88
|
+
{
|
|
89
|
+
"name": "TTSOptions",
|
|
90
|
+
"slug": "ttsoptions",
|
|
91
|
+
"docs": "",
|
|
92
|
+
"tags": [],
|
|
93
|
+
"methods": [],
|
|
94
|
+
"properties": [
|
|
95
|
+
{
|
|
96
|
+
"name": "text",
|
|
97
|
+
"tags": [],
|
|
98
|
+
"docs": "The text that will be synthesised when the utterance is spoken.",
|
|
99
|
+
"complexTypes": [],
|
|
100
|
+
"type": "string"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "lang",
|
|
104
|
+
"tags": [],
|
|
105
|
+
"docs": "The language of the utterance.\nPossible languages can be queried using `getSupportedLanguages`.\n\nDefault: `en-US`.",
|
|
106
|
+
"complexTypes": [],
|
|
107
|
+
"type": "string | undefined"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "rate",
|
|
111
|
+
"tags": [],
|
|
112
|
+
"docs": "The speed at which the utterance will be spoken at.\n\nDefault: `1.0`.",
|
|
113
|
+
"complexTypes": [],
|
|
114
|
+
"type": "number | undefined"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "pitch",
|
|
118
|
+
"tags": [],
|
|
119
|
+
"docs": "The pitch at which the utterance will be spoken at.\n\nDefault: `1.0`.",
|
|
120
|
+
"complexTypes": [],
|
|
121
|
+
"type": "number | undefined"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "volume",
|
|
125
|
+
"tags": [],
|
|
126
|
+
"docs": "The volume that the utterance will be spoken at.\n\nDefault: `1.0`.",
|
|
127
|
+
"complexTypes": [],
|
|
128
|
+
"type": "number | undefined"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "voice",
|
|
132
|
+
"tags": [],
|
|
133
|
+
"docs": "The index of the selected voice that will be used to speak the utterance.\nPossible voices can be queried using `getSupportedVoices`.\n\nOnly available for Web.",
|
|
134
|
+
"complexTypes": [],
|
|
135
|
+
"type": "number | undefined"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "category",
|
|
139
|
+
"tags": [],
|
|
140
|
+
"docs": "Select the iOS Audio session category.\nPossible values: `ambient` and `playback`.\nUse `playback` to play audio even when the app is in the background.\n\nOnly available for iOS.\n\nDefault: `ambient`.",
|
|
141
|
+
"complexTypes": [],
|
|
142
|
+
"type": "string | undefined"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "SpeechSynthesisVoice",
|
|
148
|
+
"slug": "speechsynthesisvoice",
|
|
149
|
+
"docs": "The SpeechSynthesisVoice interface represents a voice that the system supports.",
|
|
150
|
+
"tags": [],
|
|
151
|
+
"methods": [],
|
|
152
|
+
"properties": [
|
|
153
|
+
{
|
|
154
|
+
"name": "default",
|
|
155
|
+
"tags": [],
|
|
156
|
+
"docs": "Specifies whether the voice is the default voice for the current app (`true`) or not (`false`).",
|
|
157
|
+
"complexTypes": [],
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "lang",
|
|
162
|
+
"tags": [],
|
|
163
|
+
"docs": "BCP 47 language tag indicating the language of the voice.\nExample: `en-US`.",
|
|
164
|
+
"complexTypes": [],
|
|
165
|
+
"type": "string"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "localService",
|
|
169
|
+
"tags": [],
|
|
170
|
+
"docs": "Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service.",
|
|
171
|
+
"complexTypes": [],
|
|
172
|
+
"type": "boolean"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "name",
|
|
176
|
+
"tags": [],
|
|
177
|
+
"docs": "Human-readable name that represents the voice.\nExample: `Microsoft Zira Desktop - English (United States)`.",
|
|
178
|
+
"complexTypes": [],
|
|
179
|
+
"type": "string"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "voiceURI",
|
|
183
|
+
"tags": [],
|
|
184
|
+
"docs": "Type of URI and location of the speech synthesis service for this voice.\nExample: `urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US`.",
|
|
185
|
+
"complexTypes": [],
|
|
186
|
+
"type": "string"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"enums": [],
|
|
192
|
+
"typeAliases": [],
|
|
193
|
+
"pluginConfigs": []
|
|
194
|
+
}
|