@capacitor-community/text-to-speech 5.1.0 → 6.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 +1 -1
- package/README.md +2 -2
- package/android/build.gradle +8 -8
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -4
- package/dist/plugin.js.map +1 -1
- package/package.json +18 -18
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
9
|
+
<img src="https://img.shields.io/maintenance/yes/2025?style=flat-square" />
|
|
10
10
|
<a href="https://github.com/capacitor-community/text-to-speech/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/actions/workflow/status/capacitor-community/text-to-speech/ci.yml?branch=master&style=flat-square" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@capacitor-community/text-to-speech"><img src="https://img.shields.io/npm/l/@capacitor-community/text-to-speech?style=flat-square" /></a>
|
|
12
12
|
<br>
|
|
@@ -82,7 +82,7 @@ const isLanguageSupported = async (lang: string) => {
|
|
|
82
82
|
* [`getSupportedVoices()`](#getsupportedvoices)
|
|
83
83
|
* [`isLanguageSupported(...)`](#islanguagesupported)
|
|
84
84
|
* [`openInstall()`](#openinstall)
|
|
85
|
-
* [`addListener('onRangeStart', ...)`](#addlisteneronrangestart)
|
|
85
|
+
* [`addListener('onRangeStart', ...)`](#addlisteneronrangestart-)
|
|
86
86
|
* [Interfaces](#interfaces)
|
|
87
87
|
* [Enums](#enums)
|
|
88
88
|
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
@@ -19,10 +19,10 @@ apply plugin: 'com.android.library'
|
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
21
|
namespace "com.getcapacitor.community.tts"
|
|
22
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
23
|
defaultConfig {
|
|
24
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
26
|
versionCode 1
|
|
27
27
|
versionName "1.0"
|
|
28
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -37,8 +37,8 @@ android {
|
|
|
37
37
|
abortOnError false
|
|
38
38
|
}
|
|
39
39
|
compileOptions {
|
|
40
|
-
sourceCompatibility JavaVersion.
|
|
41
|
-
targetCompatibility JavaVersion.
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
package/dist/docs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB;;OAEG;IACH,mDAAS,CAAA;IACT;;OAEG;IACH,+CAAO,CAAA;AACT,CAAC,EATW,aAAa,KAAb,aAAa,QASxB","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface TextToSpeechPlugin {\n /**\n * Starts the TTS engine and plays the desired text.\n */\n speak(options: TTSOptions): Promise<void>;\n /**\n * Stops the TTS engine.\n */\n stop(): Promise<void>;\n /**\n * Returns a list of supported BCP 47 language tags.\n */\n getSupportedLanguages(): Promise<{ languages: string[] }>;\n /**\n * Returns a list of supported voices.\n */\n getSupportedVoices(): Promise<{ voices: SpeechSynthesisVoice[] }>;\n /**\n * Checks if a specific BCP 47 language tag is supported.\n */\n isLanguageSupported(options: { lang: string }): Promise<{ supported: boolean }>;\n /**\n * Verifies proper installation and availability of resource files on the system.\n *\n * Only available for Android.\n */\n openInstall(): Promise<void>;\n\n addListener(\n eventName: 'onRangeStart',\n listenerFunc: (info: { start: number; end: number; spokenWord: string }) => void,\n ): Promise<PluginListenerHandle>;\n}\n\nexport enum QueueStrategy {\n /**\n * Use `Flush` to stop the current request when a new request is sent.\n */\n Flush = 0,\n /**\n * Use `Add` to buffer the speech request. The request will be executed when all previous requests have been completed.\n */\n Add = 1,\n}\n\nexport interface TTSOptions {\n /**\n * The text that will be synthesised when the utterance is spoken.\n *\n * @example \"Hello world\"\n */\n text: string;\n /**\n * The language of the utterance.\n * Possible languages can be queried using `getSupportedLanguages`.\n *\n * @default \"en-US\"\n */\n lang?: string;\n /**\n * The speed at which the utterance will be spoken at.\n *\n * @default 1.0\n */\n rate?: number;\n /**\n * The pitch at which the utterance will be spoken at.\n *\n * @default 1.0\n */\n pitch?: number;\n /**\n * The volume that the utterance will be spoken at.\n *\n * @default 1.0\n */\n volume?: number;\n /**\n * The index of the selected voice that will be used to speak the utterance.\n * Possible voices can be queried using `getSupportedVoices`.\n */\n voice?: number;\n /**\n * Select the iOS Audio session category.\n * Possible values: `ambient` and `playback`.\n * Use `playback` to play audio even when the app is in the background.\n *\n * Only available for iOS.\n *\n * @default \"ambient\"\n */\n category?: string;\n /**\n * Select the strategy to adopt when several requests to speak overlap.\n *\n * @since 5.1.0\n * @default QueueStrategy.Flush\n */\n queueStrategy?: QueueStrategy;\n}\n\n/**\n * The SpeechSynthesisVoice interface represents a voice that the system supports.\n */\nexport interface SpeechSynthesisVoice {\n /**\n * Specifies whether the voice is the default voice for the current app (`true`) or not (`false`).\n *\n * @example false\n */\n default: boolean;\n /**\n * BCP 47 language tag indicating the language of the voice.\n *\n * @example \"en-US\"\n */\n lang: string;\n /**\n * Specifies whether the voice is supplied by a local (`true`) or remote (`false`) speech synthesizer service.\n *\n * @example true\n */\n localService: boolean;\n /**\n * Human-readable name that represents the voice.\n *\n * @example \"Microsoft Zira Desktop - English (United States)\"\n */\n name: string;\n /**\n * Type of URI and location of the speech synthesis service for this voice.\n *\n * @example \"urn:moz-tts:sapi:Microsoft Zira Desktop - English (United States)?en-US\"\n */\n voiceURI: string;\n}\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerPlugin } from '@capacitor/core';
|
|
2
2
|
const TextToSpeech = registerPlugin('TextToSpeech', {
|
|
3
|
-
web: () => import('./web').then(m => new m.TextToSpeechWeb()),
|
|
3
|
+
web: () => import('./web').then((m) => new m.TextToSpeechWeb()),
|
|
4
4
|
});
|
|
5
5
|
// Warm up
|
|
6
6
|
if ('speechSynthesis' in window) {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,UAAU;AACV,IAAI,iBAAiB,IAAI,MAAM,EAAE;IAC/B,MAAM,CAAC,eAAe,CAAC;CACxB;AAED,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { TextToSpeechPlugin } from './definitions';\n\nconst TextToSpeech = registerPlugin<TextToSpeechPlugin>('TextToSpeech', {\n web: () => import('./web').then((m) => new m.TextToSpeechWeb()),\n});\n\n// Warm up\nif ('speechSynthesis' in window) {\n window.speechSynthesis;\n}\n\nexport * from './definitions';\nexport { TextToSpeech };\n"]}
|
package/dist/esm/web.js
CHANGED
|
@@ -35,7 +35,7 @@ export class TextToSpeechWeb extends WebPlugin {
|
|
|
35
35
|
}
|
|
36
36
|
async getSupportedLanguages() {
|
|
37
37
|
const voices = this.getSpeechSynthesisVoices();
|
|
38
|
-
const languages = voices.map(voice => voice.lang);
|
|
38
|
+
const languages = voices.map((voice) => voice.lang);
|
|
39
39
|
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
|
|
40
40
|
return { languages: filteredLanguages };
|
|
41
41
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAI5C;QACE,KAAK,EAAE,CAAC;QAJF,oBAAe,GAA2B,IAAI,CAAC;QAKrD,IAAI,iBAAiB,IAAI,MAAM,EAAE;YAC/B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;YAC9C,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,GAAG,EAAE;gBAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,OAAmB;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AK,EAAE;YACT,SAAS,CAAC,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,IAAI,EAAE;YACR,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;SACvB;QACD,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,wBAAwB;QAC9B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,qBAAqB,EAAE,CAAC;SAC9B;QACD,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;SACzD;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAEO,qBAAqB;QAC3B,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC,CAAC;IAC/E,CAAC;IAEO,uBAAuB;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { TextToSpeechPlugin, TTSOptions } from './definitions';\n\nexport class TextToSpeechWeb extends WebPlugin implements TextToSpeechPlugin {\n private speechSynthesis: SpeechSynthesis | null = null;\n private supportedVoices: SpeechSynthesisVoice[] | undefined;\n\n constructor() {\n super();\n if ('speechSynthesis' in window) {\n this.speechSynthesis = window.speechSynthesis;\n window.addEventListener('beforeunload', () => {\n this.stop();\n });\n }\n }\n\n public async speak(options: TTSOptions): Promise<void> {\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: any) => {\n reject(event);\n };\n speechSynthesis.speak(utterance);\n });\n }\n\n public async stop(): Promise<void> {\n if (!this.speechSynthesis) {\n this.throwUnsupportedError();\n }\n this.speechSynthesis.cancel();\n }\n\n public async getSupportedLanguages(): Promise<{ languages: string[] }> {\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\n public async getSupportedVoices(): Promise<{\n voices: SpeechSynthesisVoice[];\n }> {\n const voices = this.getSpeechSynthesisVoices();\n return { voices };\n }\n\n public async isLanguageSupported(options: { lang: string }): Promise<{ supported: boolean }> {\n const result = await this.getSupportedLanguages();\n const isLanguageSupported = result.languages.includes(options.lang);\n return { supported: isLanguageSupported };\n }\n\n public async openInstall(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n private createSpeechSynthesisUtterance(options: TTSOptions): SpeechSynthesisUtterance {\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\n private getSpeechSynthesisVoices(): SpeechSynthesisVoice[] {\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\n private throwUnsupportedError(): never {\n throw this.unavailable('SpeechSynthesis API not available in this browser.');\n }\n\n private throwUnimplementedError(): never {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@capacitor/core');
|
|
6
4
|
|
|
7
5
|
exports.QueueStrategy = void 0;
|
|
@@ -17,7 +15,7 @@ exports.QueueStrategy = void 0;
|
|
|
17
15
|
})(exports.QueueStrategy || (exports.QueueStrategy = {}));
|
|
18
16
|
|
|
19
17
|
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
20
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
18
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextToSpeechWeb()),
|
|
21
19
|
});
|
|
22
20
|
|
|
23
21
|
class TextToSpeechWeb extends core.WebPlugin {
|
|
@@ -56,7 +54,7 @@ class TextToSpeechWeb extends core.WebPlugin {
|
|
|
56
54
|
}
|
|
57
55
|
async getSupportedLanguages() {
|
|
58
56
|
const voices = this.getSpeechSynthesisVoices();
|
|
59
|
-
const languages = voices.map(voice => voice.lang);
|
|
57
|
+
const languages = voices.map((voice) => voice.lang);
|
|
60
58
|
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
|
|
61
59
|
return { languages: filteredLanguages };
|
|
62
60
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var QueueStrategy;\n(function (QueueStrategy) {\n /**\n * Use `Flush` to stop the current request when a new request is sent.\n */\n QueueStrategy[QueueStrategy[\"Flush\"] = 0] = \"Flush\";\n /**\n * Use `Add` to buffer the speech request. The request will be executed when all previous requests have been completed.\n */\n QueueStrategy[QueueStrategy[\"Add\"] = 1] = \"Add\";\n})(QueueStrategy || (QueueStrategy = {}));\n//# sourceMappingURL=definitions.js.map","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 window.addEventListener('beforeunload', () => {\n this.stop();\n });\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":["QueueStrategy","registerPlugin","WebPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var QueueStrategy;\n(function (QueueStrategy) {\n /**\n * Use `Flush` to stop the current request when a new request is sent.\n */\n QueueStrategy[QueueStrategy[\"Flush\"] = 0] = \"Flush\";\n /**\n * Use `Add` to buffer the speech request. The request will be executed when all previous requests have been completed.\n */\n QueueStrategy[QueueStrategy[\"Add\"] = 1] = \"Add\";\n})(QueueStrategy || (QueueStrategy = {}));\n//# sourceMappingURL=definitions.js.map","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 window.addEventListener('beforeunload', () => {\n this.stop();\n });\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":["QueueStrategy","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AAC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ACA,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC;AACpF;AACA,IAAI,uBAAuB,GAAG;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ var capacitorTextToSpeech = (function (exports, core) {
|
|
|
14
14
|
})(exports.QueueStrategy || (exports.QueueStrategy = {}));
|
|
15
15
|
|
|
16
16
|
const TextToSpeech = core.registerPlugin('TextToSpeech', {
|
|
17
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.TextToSpeechWeb()),
|
|
17
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextToSpeechWeb()),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
class TextToSpeechWeb extends core.WebPlugin {
|
|
@@ -53,7 +53,7 @@ var capacitorTextToSpeech = (function (exports, core) {
|
|
|
53
53
|
}
|
|
54
54
|
async getSupportedLanguages() {
|
|
55
55
|
const voices = this.getSpeechSynthesisVoices();
|
|
56
|
-
const languages = voices.map(voice => voice.lang);
|
|
56
|
+
const languages = voices.map((voice) => voice.lang);
|
|
57
57
|
const filteredLanguages = languages.filter((v, i, a) => a.indexOf(v) == i);
|
|
58
58
|
return { languages: filteredLanguages };
|
|
59
59
|
}
|
|
@@ -115,8 +115,6 @@ var capacitorTextToSpeech = (function (exports, core) {
|
|
|
115
115
|
|
|
116
116
|
exports.TextToSpeech = TextToSpeech;
|
|
117
117
|
|
|
118
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
119
|
-
|
|
120
118
|
return exports;
|
|
121
119
|
|
|
122
120
|
})({}, capacitorExports);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var QueueStrategy;\n(function (QueueStrategy) {\n /**\n * Use `Flush` to stop the current request when a new request is sent.\n */\n QueueStrategy[QueueStrategy[\"Flush\"] = 0] = \"Flush\";\n /**\n * Use `Add` to buffer the speech request. The request will be executed when all previous requests have been completed.\n */\n QueueStrategy[QueueStrategy[\"Add\"] = 1] = \"Add\";\n})(QueueStrategy || (QueueStrategy = {}));\n//# sourceMappingURL=definitions.js.map","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 window.addEventListener('beforeunload', () => {\n this.stop();\n });\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":["QueueStrategy","registerPlugin","WebPlugin"],"mappings":";;;AAAWA
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var QueueStrategy;\n(function (QueueStrategy) {\n /**\n * Use `Flush` to stop the current request when a new request is sent.\n */\n QueueStrategy[QueueStrategy[\"Flush\"] = 0] = \"Flush\";\n /**\n * Use `Add` to buffer the speech request. The request will be executed when all previous requests have been completed.\n */\n QueueStrategy[QueueStrategy[\"Add\"] = 1] = \"Add\";\n})(QueueStrategy || (QueueStrategy = {}));\n//# sourceMappingURL=definitions.js.map","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 window.addEventListener('beforeunload', () => {\n this.stop();\n });\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":["QueueStrategy","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA,IAAI,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO;IACvD;IACA;IACA;IACA,IAAI,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;IACnD,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;;ACTpC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,EAAE;IACf,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI;IACnC,QAAQ,IAAI,iBAAiB,IAAI,MAAM,EAAE;IACzC,YAAY,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe;IACzD,YAAY,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAC1D,gBAAgB,IAAI,CAAC,IAAI,EAAE;IAC3B,aAAa,CAAC;IACd;IACA;IACA,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;IACnC,YAAY,IAAI,CAAC,qBAAqB,EAAE;IACxC;IACA,QAAQ,MAAM,IAAI,CAAC,IAAI,EAAE;IACzB,QAAQ,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe;IACpD,QAAQ,MAAM,S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;IACA,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;IACtE,YAAY,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;IACnE;IACA,QAAQ,OAAO,IAAI,CAAC,eAAe;IACnC;IACA,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,oDAAoD,CAAC;IACpF;IACA,IAAI,uBAAuB,GAAG;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/text-to-speech",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Capacitor plugin for synthesizing speech from text.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
15
15
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
16
16
|
"eslint": "eslint . --ext ts",
|
|
17
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
17
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
18
18
|
"swiftlint": "node-swiftlint",
|
|
19
19
|
"docgen": "docgen --api TextToSpeechPlugin --output-readme README.md --output-json dist/docs.json",
|
|
20
|
-
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.
|
|
20
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
21
21
|
"clean": "rimraf ./dist",
|
|
22
22
|
"watch": "tsc --watch",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"author": "Robin Genz <mail@robingenz.dev>",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@capacitor/android": "
|
|
30
|
-
"@capacitor/cli": "
|
|
31
|
-
"@capacitor/core": "
|
|
32
|
-
"@capacitor/docgen": "0.
|
|
33
|
-
"@capacitor/ios": "
|
|
34
|
-
"@ionic/eslint-config": "
|
|
35
|
-
"@ionic/prettier-config": "
|
|
36
|
-
"@ionic/swiftlint-config": "
|
|
37
|
-
"eslint": "
|
|
38
|
-
"prettier": "
|
|
39
|
-
"prettier-plugin-java": "
|
|
40
|
-
"rimraf": "
|
|
41
|
-
"rollup": "
|
|
29
|
+
"@capacitor/android": "7.0.0",
|
|
30
|
+
"@capacitor/cli": "7.0.0",
|
|
31
|
+
"@capacitor/core": "7.0.0",
|
|
32
|
+
"@capacitor/docgen": "0.3.0",
|
|
33
|
+
"@capacitor/ios": "7.0.0",
|
|
34
|
+
"@ionic/eslint-config": "0.4.0",
|
|
35
|
+
"@ionic/prettier-config": "4.0.0",
|
|
36
|
+
"@ionic/swiftlint-config": "2.0.0",
|
|
37
|
+
"eslint": "8.57.0",
|
|
38
|
+
"prettier": "3.4.2",
|
|
39
|
+
"prettier-plugin-java": "2.6.6",
|
|
40
|
+
"rimraf": "6.0.1",
|
|
41
|
+
"rollup": "4.30.1",
|
|
42
42
|
"standard-version": "9.5.0",
|
|
43
|
-
"swiftlint": "
|
|
43
|
+
"swiftlint": "2.0.0",
|
|
44
44
|
"typescript": "4.1.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@capacitor/core": "
|
|
47
|
+
"@capacitor/core": ">=7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"android/src/main/",
|