@capacitor-community/text-to-speech 1.1.2 → 2.0.0
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 +102 -102
- package/android/build.gradle +57 -58
- package/android/src/main/AndroidManifest.xml +3 -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 +162 -162
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeechPlugin.java +130 -130
- package/dist/docs.json +10 -10
- package/dist/esm/definitions.d.ts +112 -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 -88
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +91 -88
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +92 -89
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/TextToSpeech.swift +81 -81
- package/ios/Plugin/TextToSpeechPlugin.h +10 -10
- package/ios/Plugin/TextToSpeechPlugin.m +13 -13
- package/ios/Plugin/TextToSpeechPlugin.swift +64 -64
- package/package.json +81 -81
package/dist/plugin.cjs.js
CHANGED
|
@@ -4,96 +4,99 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@capacitor/core');
|
|
6
6
|
|
|
7
|
-
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
8
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
7
|
+
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
class TextToSpeechWeb extends core.WebPlugin {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.speechSynthesis = null;
|
|
15
|
-
if ('speechSynthesis' in window) {
|
|
16
|
-
this.speechSynthesis = window.speechSynthesis;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
utterance.
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.speechSynthesis
|
|
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
|
-
if (
|
|
68
|
-
utterance.
|
|
69
|
-
}
|
|
70
|
-
if (
|
|
71
|
-
utterance.
|
|
72
|
-
}
|
|
73
|
-
if (
|
|
74
|
-
utterance.
|
|
75
|
-
}
|
|
76
|
-
if (
|
|
77
|
-
utterance.
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (!this.
|
|
87
|
-
this.
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
throw this.
|
|
96
|
-
}
|
|
11
|
+
class TextToSpeechWeb extends core.WebPlugin {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.speechSynthesis = null;
|
|
15
|
+
if ('speechSynthesis' in window) {
|
|
16
|
+
this.speechSynthesis = window.speechSynthesis;
|
|
17
|
+
window.addEventListener('beforeunload', () => {
|
|
18
|
+
this.stop();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async speak(options) {
|
|
23
|
+
if (!this.speechSynthesis) {
|
|
24
|
+
this.throwUnsupportedError();
|
|
25
|
+
}
|
|
26
|
+
await this.stop();
|
|
27
|
+
const speechSynthesis = this.speechSynthesis;
|
|
28
|
+
const utterance = this.createSpeechSynthesisUtterance(options);
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
utterance.onend = () => {
|
|
31
|
+
resolve();
|
|
32
|
+
};
|
|
33
|
+
utterance.onerror = (event) => {
|
|
34
|
+
reject(event);
|
|
35
|
+
};
|
|
36
|
+
speechSynthesis.speak(utterance);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async stop() {
|
|
40
|
+
if (!this.speechSynthesis) {
|
|
41
|
+
this.throwUnsupportedError();
|
|
42
|
+
}
|
|
43
|
+
this.speechSynthesis.cancel();
|
|
44
|
+
}
|
|
45
|
+
async getSupportedLanguages() {
|
|
46
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
47
|
+
const languages = voices.map(voice => voice.lang);
|
|
48
|
+
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
|
|
49
|
+
return { languages: filteredLanguages };
|
|
50
|
+
}
|
|
51
|
+
async getSupportedVoices() {
|
|
52
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
53
|
+
return { voices };
|
|
54
|
+
}
|
|
55
|
+
async isLanguageSupported(options) {
|
|
56
|
+
const result = await this.getSupportedLanguages();
|
|
57
|
+
const isLanguageSupported = result.languages.includes(options.lang);
|
|
58
|
+
return { supported: isLanguageSupported };
|
|
59
|
+
}
|
|
60
|
+
async openInstall() {
|
|
61
|
+
this.throwUnimplementedError();
|
|
62
|
+
}
|
|
63
|
+
createSpeechSynthesisUtterance(options) {
|
|
64
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
65
|
+
const utterance = new SpeechSynthesisUtterance();
|
|
66
|
+
const { text, lang, rate, pitch, volume, voice } = options;
|
|
67
|
+
if (voice) {
|
|
68
|
+
utterance.voice = voices[voice];
|
|
69
|
+
}
|
|
70
|
+
if (volume) {
|
|
71
|
+
utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
|
|
72
|
+
}
|
|
73
|
+
if (rate) {
|
|
74
|
+
utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;
|
|
75
|
+
}
|
|
76
|
+
if (pitch) {
|
|
77
|
+
utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;
|
|
78
|
+
}
|
|
79
|
+
if (lang) {
|
|
80
|
+
utterance.lang = lang;
|
|
81
|
+
}
|
|
82
|
+
utterance.text = text;
|
|
83
|
+
return utterance;
|
|
84
|
+
}
|
|
85
|
+
getSpeechSynthesisVoices() {
|
|
86
|
+
if (!this.speechSynthesis) {
|
|
87
|
+
this.throwUnsupportedError();
|
|
88
|
+
}
|
|
89
|
+
if (!this.supportedVoices || this.supportedVoices.length < 1) {
|
|
90
|
+
this.supportedVoices = this.speechSynthesis.getVoices();
|
|
91
|
+
}
|
|
92
|
+
return this.supportedVoices;
|
|
93
|
+
}
|
|
94
|
+
throwUnsupportedError() {
|
|
95
|
+
throw this.unavailable('SpeechSynthesis API not available in this browser.');
|
|
96
|
+
}
|
|
97
|
+
throwUnimplementedError() {
|
|
98
|
+
throw this.unimplemented('Not implemented on web.');
|
|
99
|
+
}
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextToSpeech = registerPlugin('TextToSpeech', {\n web: () => import('./web').then(m => new m.TextToSpeechWeb()),\n});\n// Warm up\nif ('speechSynthesis' in window) {\n window.speechSynthesis;\n}\nexport * from './definitions';\nexport { TextToSpeech };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class TextToSpeechWeb extends WebPlugin {\n constructor() {\n super();\n this.speechSynthesis = null;\n if ('speechSynthesis' in window) {\n this.speechSynthesis = window.speechSynthesis;\n }\n }\n async speak(options) {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n await this.stop();\n const speechSynthesis = this.speechSynthesis;\n const utterance = this.createSpeechSynthesisUtterance(options);\n return new Promise((resolve, reject) => {\n utterance.onend = () => {\n resolve();\n };\n utterance.onerror = (event) => {\n reject(event);\n };\n speechSynthesis.speak(utterance);\n });\n }\n async stop() {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n this.speechSynthesis.cancel();\n }\n async getSupportedLanguages() {\n const voices = this.getSpeechSynthesisVoices();\n const languages = voices.map(voice => voice.lang);\n const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);\n return { languages: filteredLanguages };\n }\n async getSupportedVoices() {\n const voices = this.getSpeechSynthesisVoices();\n return { voices };\n }\n async isLanguageSupported(options) {\n const result = await this.getSupportedLanguages();\n const isLanguageSupported = result.languages.includes(options.lang);\n return { supported: isLanguageSupported };\n }\n async openInstall() {\n this.throwUnimplementedError();\n }\n createSpeechSynthesisUtterance(options) {\n const voices = this.getSpeechSynthesisVoices();\n const utterance = new SpeechSynthesisUtterance();\n const { text, lang, rate, pitch, volume, voice } = options;\n if (voice) {\n utterance.voice = voices[voice];\n }\n if (volume) {\n utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;\n }\n if (rate) {\n utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;\n }\n if (pitch) {\n utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;\n }\n if (lang) {\n utterance.lang = lang;\n }\n utterance.text = text;\n return utterance;\n }\n getSpeechSynthesisVoices() {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n if (!this.supportedVoices || this.supportedVoices.length < 1) {\n this.supportedVoices = this.speechSynthesis.getVoices();\n }\n return this.supportedVoices;\n }\n throwUnsupportedError() {\n throw this.unavailable('SpeechSynthesis API not available in this browser.');\n }\n throwUnimplementedError() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,EAAE,CAAC;AAChB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;AACpC,QAAQ,IAAI,iBAAiB,IAAI,MAAM,EAAE;AACzC,YAAY,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AAC1D,SAAS;AACT,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;AACnC,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;AACzC,SAAS;AACT,QAAQ,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAC1B,QAAQ,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACrD,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACvE,QAAQ,OAAO,IAAI,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AAC;AAC9B,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,wBAAwB,GAAG;AAC/B,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;AACnC,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;AACzC,SAAS;AACT,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;AACtE,YAAY,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;AACpE,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC;AACpC,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC,CAAC;AACrF,KAAK;AACL,IAAI,uBAAuB,GAAG;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst TextToSpeech = registerPlugin('TextToSpeech', {\r\n web: () => import('./web').then(m => new m.TextToSpeechWeb()),\r\n});\r\n// Warm up\r\nif ('speechSynthesis' in window) {\r\n window.speechSynthesis;\r\n}\r\nexport * from './definitions';\r\nexport { TextToSpeech };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nexport class TextToSpeechWeb extends WebPlugin {\r\n constructor() {\r\n super();\r\n this.speechSynthesis = null;\r\n if ('speechSynthesis' in window) {\r\n this.speechSynthesis = window.speechSynthesis;\r\n window.addEventListener('beforeunload', () => {\r\n this.stop();\r\n });\r\n }\r\n }\r\n async speak(options) {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n await this.stop();\r\n const speechSynthesis = this.speechSynthesis;\r\n const utterance = this.createSpeechSynthesisUtterance(options);\r\n return new Promise((resolve, reject) => {\r\n utterance.onend = () => {\r\n resolve();\r\n };\r\n utterance.onerror = (event) => {\r\n reject(event);\r\n };\r\n speechSynthesis.speak(utterance);\r\n });\r\n }\r\n async stop() {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n this.speechSynthesis.cancel();\r\n }\r\n async getSupportedLanguages() {\r\n const voices = this.getSpeechSynthesisVoices();\r\n const languages = voices.map(voice => voice.lang);\r\n const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);\r\n return { languages: filteredLanguages };\r\n }\r\n async getSupportedVoices() {\r\n const voices = this.getSpeechSynthesisVoices();\r\n return { voices };\r\n }\r\n async isLanguageSupported(options) {\r\n const result = await this.getSupportedLanguages();\r\n const isLanguageSupported = result.languages.includes(options.lang);\r\n return { supported: isLanguageSupported };\r\n }\r\n async openInstall() {\r\n this.throwUnimplementedError();\r\n }\r\n createSpeechSynthesisUtterance(options) {\r\n const voices = this.getSpeechSynthesisVoices();\r\n const utterance = new SpeechSynthesisUtterance();\r\n const { text, lang, rate, pitch, volume, voice } = options;\r\n if (voice) {\r\n utterance.voice = voices[voice];\r\n }\r\n if (volume) {\r\n utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;\r\n }\r\n if (rate) {\r\n utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;\r\n }\r\n if (pitch) {\r\n utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;\r\n }\r\n if (lang) {\r\n utterance.lang = lang;\r\n }\r\n utterance.text = text;\r\n return utterance;\r\n }\r\n getSpeechSynthesisVoices() {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n if (!this.supportedVoices || this.supportedVoices.length < 1) {\r\n this.supportedVoices = this.speechSynthesis.getVoices();\r\n }\r\n return this.supportedVoices;\r\n }\r\n throwUnsupportedError() {\r\n throw this.unavailable('SpeechSynthesis API not available in this browser.');\r\n }\r\n throwUnimplementedError() {\r\n throw this.unimplemented('Not implemented on web.');\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,EAAE,CAAC;AAChB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;AACpC,QAAQ,IAAI,iBAAiB,IAAI,MAAM,EAAE;AACzC,YAAY,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AAC1D,YAAY,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM;AAC1D,gBAAgB,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,aAAa,CAAC,CAAC;AACf,SAAS;AACT,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;AACnC,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;AACzC,SAAS;AACT,QAAQ,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAC1B,QAAQ,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACrD,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACvE,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,SAAS,CAAC,KAAK,GAAG,MAAM;AACpC,gBAAgB,OAAO,EAAE,CAAC;AAC1B,aAAa,CAAC;AACd,YAAY,SAAS,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK;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AQ,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;AACtE,YAAY,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;AACpE,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC;AACpC,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC,CAAC;AACrF,KAAK;AACL,IAAI,uBAAuB,GAAG;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,96 +1,99 @@
|
|
|
1
1
|
var capacitorTextToSpeech = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
5
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
4
|
+
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
class TextToSpeechWeb extends core.WebPlugin {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this.speechSynthesis = null;
|
|
12
|
-
if ('speechSynthesis' in window) {
|
|
13
|
-
this.speechSynthesis = window.speechSynthesis;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
utterance.
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.speechSynthesis
|
|
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
|
-
if (
|
|
65
|
-
utterance.
|
|
66
|
-
}
|
|
67
|
-
if (
|
|
68
|
-
utterance.
|
|
69
|
-
}
|
|
70
|
-
if (
|
|
71
|
-
utterance.
|
|
72
|
-
}
|
|
73
|
-
if (
|
|
74
|
-
utterance.
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!this.
|
|
84
|
-
this.
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
throw this.
|
|
93
|
-
}
|
|
8
|
+
class TextToSpeechWeb extends core.WebPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.speechSynthesis = null;
|
|
12
|
+
if ('speechSynthesis' in window) {
|
|
13
|
+
this.speechSynthesis = window.speechSynthesis;
|
|
14
|
+
window.addEventListener('beforeunload', () => {
|
|
15
|
+
this.stop();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async speak(options) {
|
|
20
|
+
if (!this.speechSynthesis) {
|
|
21
|
+
this.throwUnsupportedError();
|
|
22
|
+
}
|
|
23
|
+
await this.stop();
|
|
24
|
+
const speechSynthesis = this.speechSynthesis;
|
|
25
|
+
const utterance = this.createSpeechSynthesisUtterance(options);
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
utterance.onend = () => {
|
|
28
|
+
resolve();
|
|
29
|
+
};
|
|
30
|
+
utterance.onerror = (event) => {
|
|
31
|
+
reject(event);
|
|
32
|
+
};
|
|
33
|
+
speechSynthesis.speak(utterance);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async stop() {
|
|
37
|
+
if (!this.speechSynthesis) {
|
|
38
|
+
this.throwUnsupportedError();
|
|
39
|
+
}
|
|
40
|
+
this.speechSynthesis.cancel();
|
|
41
|
+
}
|
|
42
|
+
async getSupportedLanguages() {
|
|
43
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
44
|
+
const languages = voices.map(voice => voice.lang);
|
|
45
|
+
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
|
|
46
|
+
return { languages: filteredLanguages };
|
|
47
|
+
}
|
|
48
|
+
async getSupportedVoices() {
|
|
49
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
50
|
+
return { voices };
|
|
51
|
+
}
|
|
52
|
+
async isLanguageSupported(options) {
|
|
53
|
+
const result = await this.getSupportedLanguages();
|
|
54
|
+
const isLanguageSupported = result.languages.includes(options.lang);
|
|
55
|
+
return { supported: isLanguageSupported };
|
|
56
|
+
}
|
|
57
|
+
async openInstall() {
|
|
58
|
+
this.throwUnimplementedError();
|
|
59
|
+
}
|
|
60
|
+
createSpeechSynthesisUtterance(options) {
|
|
61
|
+
const voices = this.getSpeechSynthesisVoices();
|
|
62
|
+
const utterance = new SpeechSynthesisUtterance();
|
|
63
|
+
const { text, lang, rate, pitch, volume, voice } = options;
|
|
64
|
+
if (voice) {
|
|
65
|
+
utterance.voice = voices[voice];
|
|
66
|
+
}
|
|
67
|
+
if (volume) {
|
|
68
|
+
utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;
|
|
69
|
+
}
|
|
70
|
+
if (rate) {
|
|
71
|
+
utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;
|
|
72
|
+
}
|
|
73
|
+
if (pitch) {
|
|
74
|
+
utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;
|
|
75
|
+
}
|
|
76
|
+
if (lang) {
|
|
77
|
+
utterance.lang = lang;
|
|
78
|
+
}
|
|
79
|
+
utterance.text = text;
|
|
80
|
+
return utterance;
|
|
81
|
+
}
|
|
82
|
+
getSpeechSynthesisVoices() {
|
|
83
|
+
if (!this.speechSynthesis) {
|
|
84
|
+
this.throwUnsupportedError();
|
|
85
|
+
}
|
|
86
|
+
if (!this.supportedVoices || this.supportedVoices.length < 1) {
|
|
87
|
+
this.supportedVoices = this.speechSynthesis.getVoices();
|
|
88
|
+
}
|
|
89
|
+
return this.supportedVoices;
|
|
90
|
+
}
|
|
91
|
+
throwUnsupportedError() {
|
|
92
|
+
throw this.unavailable('SpeechSynthesis API not available in this browser.');
|
|
93
|
+
}
|
|
94
|
+
throwUnimplementedError() {
|
|
95
|
+
throw this.unimplemented('Not implemented on web.');
|
|
96
|
+
}
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
var web = /*#__PURE__*/Object.freeze({
|
|
@@ -104,5 +107,5 @@ var capacitorTextToSpeech = (function (exports, core) {
|
|
|
104
107
|
|
|
105
108
|
return exports;
|
|
106
109
|
|
|
107
|
-
}({}, capacitorExports)
|
|
110
|
+
})({}, capacitorExports);
|
|
108
111
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextToSpeech = registerPlugin('TextToSpeech', {\n web: () => import('./web').then(m => new m.TextToSpeechWeb()),\n});\n// Warm up\nif ('speechSynthesis' in window) {\n window.speechSynthesis;\n}\nexport * from './definitions';\nexport { TextToSpeech };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class TextToSpeechWeb extends WebPlugin {\n constructor() {\n super();\n this.speechSynthesis = null;\n if ('speechSynthesis' in window) {\n this.speechSynthesis = window.speechSynthesis;\n }\n }\n async speak(options) {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n await this.stop();\n const speechSynthesis = this.speechSynthesis;\n const utterance = this.createSpeechSynthesisUtterance(options);\n return new Promise((resolve, reject) => {\n utterance.onend = () => {\n resolve();\n };\n utterance.onerror = (event) => {\n reject(event);\n };\n speechSynthesis.speak(utterance);\n });\n }\n async stop() {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n this.speechSynthesis.cancel();\n }\n async getSupportedLanguages() {\n const voices = this.getSpeechSynthesisVoices();\n const languages = voices.map(voice => voice.lang);\n const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);\n return { languages: filteredLanguages };\n }\n async getSupportedVoices() {\n const voices = this.getSpeechSynthesisVoices();\n return { voices };\n }\n async isLanguageSupported(options) {\n const result = await this.getSupportedLanguages();\n const isLanguageSupported = result.languages.includes(options.lang);\n return { supported: isLanguageSupported };\n }\n async openInstall() {\n this.throwUnimplementedError();\n }\n createSpeechSynthesisUtterance(options) {\n const voices = this.getSpeechSynthesisVoices();\n const utterance = new SpeechSynthesisUtterance();\n const { text, lang, rate, pitch, volume, voice } = options;\n if (voice) {\n utterance.voice = voices[voice];\n }\n if (volume) {\n utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;\n }\n if (rate) {\n utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;\n }\n if (pitch) {\n utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;\n }\n if (lang) {\n utterance.lang = lang;\n }\n utterance.text = text;\n return utterance;\n }\n getSpeechSynthesisVoices() {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n if (!this.supportedVoices || this.supportedVoices.length < 1) {\n this.supportedVoices = this.speechSynthesis.getVoices();\n }\n return this.supportedVoices;\n }\n throwUnsupportedError() {\n throw this.unavailable('SpeechSynthesis API not available in this browser.');\n }\n throwUnimplementedError() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,EAAE,CAAC;IAChB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IACpC,QAAQ,IAAI,iBAAiB,IAAI,MAAM,EAAE;IACzC,YAAY,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IAC1D,SAAS;IACT,KAAK;IACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;IACnC,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACzC,SAAS;IACT,QAAQ,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,QAAQ,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IACrD,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;IACvE,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;IAChD,YAAY,SAAS,CAAC,KAAK,GAAG,MAAM;IACpC,gBAAgB,OAAO,EAAE,CAAC;IAC1B,aAAa,CAAC;IACd,YAAY,SAAS,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK;IAC3C,gBAAgB,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,aAAa,CAAC;IACd,YAAY,eAAe,CAAC,KAAK,CAAC,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,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;IACpE,SAAS;IACT,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC;IACpC,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC,CAAC;IACrF,KAAK;IACL,IAAI,uBAAuB,GAAG;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst TextToSpeech = registerPlugin('TextToSpeech', {\r\n web: () => import('./web').then(m => new m.TextToSpeechWeb()),\r\n});\r\n// Warm up\r\nif ('speechSynthesis' in window) {\r\n window.speechSynthesis;\r\n}\r\nexport * from './definitions';\r\nexport { TextToSpeech };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nexport class TextToSpeechWeb extends WebPlugin {\r\n constructor() {\r\n super();\r\n this.speechSynthesis = null;\r\n if ('speechSynthesis' in window) {\r\n this.speechSynthesis = window.speechSynthesis;\r\n window.addEventListener('beforeunload', () => {\r\n this.stop();\r\n });\r\n }\r\n }\r\n async speak(options) {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n await this.stop();\r\n const speechSynthesis = this.speechSynthesis;\r\n const utterance = this.createSpeechSynthesisUtterance(options);\r\n return new Promise((resolve, reject) => {\r\n utterance.onend = () => {\r\n resolve();\r\n };\r\n utterance.onerror = (event) => {\r\n reject(event);\r\n };\r\n speechSynthesis.speak(utterance);\r\n });\r\n }\r\n async stop() {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n this.speechSynthesis.cancel();\r\n }\r\n async getSupportedLanguages() {\r\n const voices = this.getSpeechSynthesisVoices();\r\n const languages = voices.map(voice => voice.lang);\r\n const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);\r\n return { languages: filteredLanguages };\r\n }\r\n async getSupportedVoices() {\r\n const voices = this.getSpeechSynthesisVoices();\r\n return { voices };\r\n }\r\n async isLanguageSupported(options) {\r\n const result = await this.getSupportedLanguages();\r\n const isLanguageSupported = result.languages.includes(options.lang);\r\n return { supported: isLanguageSupported };\r\n }\r\n async openInstall() {\r\n this.throwUnimplementedError();\r\n }\r\n createSpeechSynthesisUtterance(options) {\r\n const voices = this.getSpeechSynthesisVoices();\r\n const utterance = new SpeechSynthesisUtterance();\r\n const { text, lang, rate, pitch, volume, voice } = options;\r\n if (voice) {\r\n utterance.voice = voices[voice];\r\n }\r\n if (volume) {\r\n utterance.volume = volume >= 0 && volume <= 1 ? volume : 1;\r\n }\r\n if (rate) {\r\n utterance.rate = rate >= 0.1 && rate <= 10 ? rate : 1;\r\n }\r\n if (pitch) {\r\n utterance.pitch = pitch >= 0 && pitch <= 2 ? pitch : 2;\r\n }\r\n if (lang) {\r\n utterance.lang = lang;\r\n }\r\n utterance.text = text;\r\n return utterance;\r\n }\r\n getSpeechSynthesisVoices() {\r\n if (!this.speechSynthesis) {\r\n this.throwUnsupportedError();\r\n }\r\n if (!this.supportedVoices || this.supportedVoices.length < 1) {\r\n this.supportedVoices = this.speechSynthesis.getVoices();\r\n }\r\n return this.supportedVoices;\r\n }\r\n throwUnsupportedError() {\r\n throw this.unavailable('SpeechSynthesis API not available in this browser.');\r\n }\r\n throwUnimplementedError() {\r\n throw this.unimplemented('Not implemented on web.');\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CA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AC,WAAW,CAAC,oDAAoD,CAAC,CAAC;IACrF,KAAK;IACL,IAAI,uBAAuB,GAAG;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
package/ios/Plugin/Info.plist
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
-
<key>NSPrincipalClass</key>
|
|
22
|
-
<string></string>
|
|
23
|
-
</dict>
|
|
24
|
-
</plist>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|