@capacitor-community/text-to-speech 2.0.1 → 2.1.0-dev.d5032fb.1680890069
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 +17 -17
- package/LICENSE +21 -21
- package/README.md +119 -119
- package/android/build.gradle +58 -57
- package/android/src/main/AndroidManifest.xml +2 -3
- package/android/src/main/java/com/getcapacitor/community/tts/SpeakResultCallback.java +6 -6
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeech.java +186 -162
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeechPlugin.java +131 -130
- package/dist/docs.json +76 -21
- package/dist/esm/definitions.d.ts +119 -112
- package/dist/esm/definitions.js +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +10 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +25 -25
- package/dist/esm/web.js +91 -91
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +91 -91
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +91 -91
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/TextToSpeech.swift +91 -81
- package/ios/Plugin/TextToSpeechPlugin.h +10 -10
- package/ios/Plugin/TextToSpeechPlugin.m +13 -13
- package/ios/Plugin/TextToSpeechPlugin.swift +80 -64
- package/package.json +81 -81
|
@@ -1,162 +1,186 @@
|
|
|
1
|
-
package com.getcapacitor.community.tts;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.content.Intent;
|
|
5
|
-
import android.content.pm.PackageManager;
|
|
6
|
-
import android.content.pm.ResolveInfo;
|
|
7
|
-
import android.os.Build;
|
|
8
|
-
import android.os.Bundle;
|
|
9
|
-
import android.speech.tts.UtteranceProgressListener;
|
|
10
|
-
import android.speech.tts.Voice;
|
|
11
|
-
import android.util.Log;
|
|
12
|
-
import com.getcapacitor.JSArray;
|
|
13
|
-
import com.getcapacitor.JSObject;
|
|
14
|
-
import java.util.ArrayList;
|
|
15
|
-
import java.util.
|
|
16
|
-
import java.util.
|
|
17
|
-
import java.util.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
String
|
|
45
|
-
|
|
46
|
-
float
|
|
47
|
-
float
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ttsParams
|
|
75
|
-
|
|
76
|
-
tts.
|
|
77
|
-
|
|
78
|
-
tts.
|
|
79
|
-
tts.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public JSArray
|
|
108
|
-
ArrayList<
|
|
109
|
-
Set<
|
|
110
|
-
for (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
JSArray result = JSArray.from(
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
1
|
+
package com.getcapacitor.community.tts;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
import android.content.pm.ResolveInfo;
|
|
7
|
+
import android.os.Build;
|
|
8
|
+
import android.os.Bundle;
|
|
9
|
+
import android.speech.tts.UtteranceProgressListener;
|
|
10
|
+
import android.speech.tts.Voice;
|
|
11
|
+
import android.util.Log;
|
|
12
|
+
import com.getcapacitor.JSArray;
|
|
13
|
+
import com.getcapacitor.JSObject;
|
|
14
|
+
import java.util.ArrayList;
|
|
15
|
+
import java.util.Comparator;
|
|
16
|
+
import java.util.HashMap;
|
|
17
|
+
import java.util.Locale;
|
|
18
|
+
import java.util.Set;
|
|
19
|
+
|
|
20
|
+
public class TextToSpeech implements android.speech.tts.TextToSpeech.OnInitListener {
|
|
21
|
+
|
|
22
|
+
public static final String LOG_TAG = "TextToSpeech";
|
|
23
|
+
|
|
24
|
+
private Context context;
|
|
25
|
+
private android.speech.tts.TextToSpeech tts = null;
|
|
26
|
+
private int initializationStatus;
|
|
27
|
+
private JSObject[] supportedVoices = null;
|
|
28
|
+
|
|
29
|
+
TextToSpeech(Context context) {
|
|
30
|
+
this.context = context;
|
|
31
|
+
try {
|
|
32
|
+
tts = new android.speech.tts.TextToSpeech(context, this);
|
|
33
|
+
} catch (Exception ex) {
|
|
34
|
+
Log.d(LOG_TAG, ex.getLocalizedMessage());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public void onInit(int status) {
|
|
40
|
+
this.initializationStatus = status;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public void speak(
|
|
44
|
+
String text,
|
|
45
|
+
String lang,
|
|
46
|
+
float rate,
|
|
47
|
+
float pitch,
|
|
48
|
+
float volume,
|
|
49
|
+
int voice,
|
|
50
|
+
String callbackId,
|
|
51
|
+
SpeakResultCallback resultCallback
|
|
52
|
+
) {
|
|
53
|
+
tts.stop();
|
|
54
|
+
tts.setOnUtteranceProgressListener(
|
|
55
|
+
new UtteranceProgressListener() {
|
|
56
|
+
@Override
|
|
57
|
+
public void onStart(String utteranceId) {}
|
|
58
|
+
|
|
59
|
+
@Override
|
|
60
|
+
public void onDone(String utteranceId) {
|
|
61
|
+
resultCallback.onDone();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public void onError(String utteranceId) {
|
|
66
|
+
resultCallback.onError();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
Locale locale = Locale.forLanguageTag(lang);
|
|
72
|
+
|
|
73
|
+
if (Build.VERSION.SDK_INT >= 21) {
|
|
74
|
+
Bundle ttsParams = new Bundle();
|
|
75
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
76
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, volume);
|
|
77
|
+
|
|
78
|
+
tts.setLanguage(locale);
|
|
79
|
+
tts.setSpeechRate(rate);
|
|
80
|
+
tts.setPitch(pitch);
|
|
81
|
+
|
|
82
|
+
if (voice >= 0) {
|
|
83
|
+
ArrayList<Voice> supportedVoices = getSupportedVoicesOrdered();
|
|
84
|
+
if (voice < supportedVoices.size()) {
|
|
85
|
+
Voice newVoice = supportedVoices.get(voice);
|
|
86
|
+
int resultCode = tts.setVoice(newVoice);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams, callbackId);
|
|
91
|
+
} else {
|
|
92
|
+
HashMap<String, String> ttsParams = new HashMap<>();
|
|
93
|
+
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
94
|
+
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, Float.toString(volume));
|
|
95
|
+
|
|
96
|
+
tts.setLanguage(locale);
|
|
97
|
+
tts.setSpeechRate(rate);
|
|
98
|
+
tts.setPitch(pitch);
|
|
99
|
+
tts.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH, ttsParams);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public void stop() {
|
|
104
|
+
tts.stop();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public JSArray getSupportedLanguages() {
|
|
108
|
+
ArrayList<String> languages = new ArrayList<>();
|
|
109
|
+
Set<Locale> supportedLocales = tts.getAvailableLanguages();
|
|
110
|
+
for (Locale supportedLocale : supportedLocales) {
|
|
111
|
+
String tag = supportedLocale.toLanguageTag();
|
|
112
|
+
languages.add(tag);
|
|
113
|
+
}
|
|
114
|
+
JSArray result = JSArray.from(languages.toArray());
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public ArrayList<Voice> getSupportedVoicesOrdered() {
|
|
119
|
+
Set<Voice> supportedVoices = tts.getVoices();
|
|
120
|
+
ArrayList<Voice> orderedVoices = new ArrayList<Voice>();
|
|
121
|
+
for (Voice supportedVoice : supportedVoices) {
|
|
122
|
+
orderedVoices.add(supportedVoice);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Comparator<Voice> voiceComparator = Comparator.comparing(v -> v.hashCode());
|
|
126
|
+
orderedVoices.sort(voiceComparator);
|
|
127
|
+
|
|
128
|
+
return orderedVoices;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public JSArray getSupportedVoices() {
|
|
132
|
+
ArrayList<JSObject> voices = new ArrayList<>();
|
|
133
|
+
ArrayList<Voice> supportedVoices = getSupportedVoicesOrdered();
|
|
134
|
+
for (Voice supportedVoice : supportedVoices) {
|
|
135
|
+
JSObject obj = this.convertVoiceToJSObject(supportedVoice);
|
|
136
|
+
voices.add(obj);
|
|
137
|
+
}
|
|
138
|
+
JSArray result = JSArray.from(voices.toArray());
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public void openInstall() {
|
|
143
|
+
PackageManager packageManager = context.getPackageManager();
|
|
144
|
+
Intent installIntent = new Intent();
|
|
145
|
+
installIntent.setAction(android.speech.tts.TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
|
|
146
|
+
|
|
147
|
+
ResolveInfo resolveInfo = packageManager.resolveActivity(installIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
148
|
+
|
|
149
|
+
if (resolveInfo != null) {
|
|
150
|
+
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
151
|
+
context.startActivity(installIntent);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public boolean isAvailable() {
|
|
156
|
+
if (tts != null && initializationStatus == android.speech.tts.TextToSpeech.SUCCESS) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public boolean isLanguageSupported(String lang) {
|
|
163
|
+
Locale locale = Locale.forLanguageTag(lang);
|
|
164
|
+
int result = tts.isLanguageAvailable(locale);
|
|
165
|
+
return result == tts.LANG_AVAILABLE || result == tts.LANG_COUNTRY_AVAILABLE || result == tts.LANG_COUNTRY_VAR_AVAILABLE;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public void onDestroy() {
|
|
169
|
+
if (tts == null) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
tts.stop();
|
|
173
|
+
tts.shutdown();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private JSObject convertVoiceToJSObject(Voice voice) {
|
|
177
|
+
Locale locale = voice.getLocale();
|
|
178
|
+
JSObject obj = new JSObject();
|
|
179
|
+
obj.put("voiceURI", voice.getName());
|
|
180
|
+
obj.put("name", locale.getDisplayLanguage() + " " + locale.getDisplayCountry());
|
|
181
|
+
obj.put("lang", locale.toLanguageTag());
|
|
182
|
+
obj.put("localService", !voice.isNetworkConnectionRequired());
|
|
183
|
+
obj.put("default", false);
|
|
184
|
+
return obj;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -1,130 +1,131 @@
|
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ret
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ret
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
ret
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
int voice = call.getInt("voice", -1);
|
|
39
|
+
|
|
40
|
+
boolean isLanguageSupported = implementation.isLanguageSupported(lang);
|
|
41
|
+
if (!isLanguageSupported) {
|
|
42
|
+
call.reject(ERROR_UNSUPPORTED_LANGUAGE);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
SpeakResultCallback resultCallback = new SpeakResultCallback() {
|
|
47
|
+
@Override
|
|
48
|
+
public void onDone() {
|
|
49
|
+
call.resolve();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public void onError() {
|
|
54
|
+
call.reject(ERROR_UTTERANCE);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
implementation.speak(text, lang, rate, pitch, volume, voice, call.getCallbackId(), resultCallback);
|
|
60
|
+
} catch (Exception ex) {
|
|
61
|
+
call.reject(ex.getLocalizedMessage());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@PluginMethod
|
|
66
|
+
public void stop(PluginCall call) {
|
|
67
|
+
boolean isAvailable = implementation.isAvailable();
|
|
68
|
+
if (!isAvailable) {
|
|
69
|
+
call.unavailable("Not yet initialized or not available on this device.");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
implementation.stop();
|
|
74
|
+
call.resolve();
|
|
75
|
+
} catch (Exception ex) {
|
|
76
|
+
call.reject(ex.getLocalizedMessage());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@PluginMethod
|
|
81
|
+
public void getSupportedLanguages(PluginCall call) {
|
|
82
|
+
try {
|
|
83
|
+
JSArray languages = implementation.getSupportedLanguages();
|
|
84
|
+
JSObject ret = new JSObject();
|
|
85
|
+
ret.put("languages", languages);
|
|
86
|
+
call.resolve(ret);
|
|
87
|
+
} catch (Exception ex) {
|
|
88
|
+
call.reject(ex.getLocalizedMessage());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@PluginMethod
|
|
93
|
+
public void getSupportedVoices(PluginCall call) {
|
|
94
|
+
try {
|
|
95
|
+
JSArray voices = implementation.getSupportedVoices();
|
|
96
|
+
JSObject ret = new JSObject();
|
|
97
|
+
ret.put("voices", voices);
|
|
98
|
+
call.resolve(ret);
|
|
99
|
+
} catch (Exception ex) {
|
|
100
|
+
call.reject(ex.getLocalizedMessage());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@PluginMethod
|
|
105
|
+
public void isLanguageSupported(PluginCall call) {
|
|
106
|
+
String lang = call.getString("lang", "");
|
|
107
|
+
try {
|
|
108
|
+
boolean isLanguageSupported = implementation.isLanguageSupported(lang);
|
|
109
|
+
JSObject ret = new JSObject();
|
|
110
|
+
ret.put("supported", isLanguageSupported);
|
|
111
|
+
call.resolve(ret);
|
|
112
|
+
} catch (Exception ex) {
|
|
113
|
+
call.reject(ex.getLocalizedMessage());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@PluginMethod
|
|
118
|
+
public void openInstall(PluginCall call) {
|
|
119
|
+
try {
|
|
120
|
+
implementation.openInstall();
|
|
121
|
+
call.resolve();
|
|
122
|
+
} catch (Exception ex) {
|
|
123
|
+
call.reject(ex.getLocalizedMessage());
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Override
|
|
128
|
+
protected void handleOnDestroy() {
|
|
129
|
+
implementation.onDestroy();
|
|
130
|
+
}
|
|
131
|
+
}
|