@capacitor-community/text-to-speech 2.1.0 → 3.0.1
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/android/build.gradle +9 -8
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeech.java +9 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/TextToSpeech.swift +5 -5
- package/ios/Plugin/TextToSpeechPlugin.swift +2 -2
- package/package.json +6 -6
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.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
@@ -11,17 +11,18 @@ buildscript {
|
|
|
11
11
|
mavenCentral()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.0.0'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
|
|
21
|
+
namespace "com.getcapacitor.community.tts"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
|
|
22
23
|
defaultConfig {
|
|
23
24
|
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
|
|
25
26
|
versionCode 1
|
|
26
27
|
versionName "1.0"
|
|
27
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -36,8 +37,8 @@ android {
|
|
|
36
37
|
abortOnError false
|
|
37
38
|
}
|
|
38
39
|
compileOptions {
|
|
39
|
-
sourceCompatibility JavaVersion.
|
|
40
|
-
targetCompatibility JavaVersion.
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -12,6 +12,7 @@ import android.util.Log;
|
|
|
12
12
|
import com.getcapacitor.JSArray;
|
|
13
13
|
import com.getcapacitor.JSObject;
|
|
14
14
|
import java.util.ArrayList;
|
|
15
|
+
import java.util.Collections;
|
|
15
16
|
import java.util.Comparator;
|
|
16
17
|
import java.util.HashMap;
|
|
17
18
|
import java.util.Locale;
|
|
@@ -122,8 +123,14 @@ public class TextToSpeech implements android.speech.tts.TextToSpeech.OnInitListe
|
|
|
122
123
|
orderedVoices.add(supportedVoice);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
Collections.sort(
|
|
127
|
+
orderedVoices,
|
|
128
|
+
new Comparator<Voice>() {
|
|
129
|
+
public int compare(Voice v1, Voice v2) {
|
|
130
|
+
return v1.hashCode() - v2.hashCode();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
);
|
|
127
134
|
|
|
128
135
|
return orderedVoices;
|
|
129
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export 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: {\n lang: string;\n }): 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\nexport interface TTSOptions {\n /**\n * The text that will be synthesised when the utterance is spoken.\n
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export 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: {\n lang: string;\n }): 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\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\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"]}
|
|
@@ -18,7 +18,7 @@ import Capacitor
|
|
|
18
18
|
self.resolveCurrentCall()
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
@objc public func speak(_ text: String, _ lang: String, _ rate: Float, _ pitch: Float, _ category: String, _ volume: Float, _ voice
|
|
21
|
+
@objc public func speak(_ text: String, _ lang: String, _ rate: Float, _ pitch: Float, _ category: String, _ volume: Float, _ voice: Int, _ call: CAPPluginCall) throws {
|
|
22
22
|
self.synthesizer.stopSpeaking(at: .immediate)
|
|
23
23
|
|
|
24
24
|
var avAudioSessionCategory = AVAudioSession.Category.ambient
|
|
@@ -37,11 +37,11 @@ import Capacitor
|
|
|
37
37
|
utterance.pitchMultiplier = pitch
|
|
38
38
|
utterance.volume = volume
|
|
39
39
|
|
|
40
|
-
//Find the voice associated with the voice parameter if a voice specified.
|
|
41
|
-
//If the specified voice is not available we will fall back to default voice rather than raising an error.
|
|
42
|
-
if
|
|
40
|
+
// Find the voice associated with the voice parameter if a voice specified.
|
|
41
|
+
// If the specified voice is not available we will fall back to default voice rather than raising an error.
|
|
42
|
+
if voice >= 0 {
|
|
43
43
|
let allVoices = AVSpeechSynthesisVoice.speechVoices()
|
|
44
|
-
if
|
|
44
|
+
if voice < allVoices.count {
|
|
45
45
|
utterance.voice = allVoices[voice]
|
|
46
46
|
}
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/text-to-speech",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Capacitor plugin for synthesizing speech from text.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"author": "Robin Genz <mail@robingenz.dev>",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@capacitor/android": "
|
|
30
|
-
"@capacitor/cli": "
|
|
31
|
-
"@capacitor/core": "
|
|
29
|
+
"@capacitor/android": "5.0.0",
|
|
30
|
+
"@capacitor/cli": "5.0.0",
|
|
31
|
+
"@capacitor/core": "5.0.0",
|
|
32
32
|
"@capacitor/docgen": "0.2.0",
|
|
33
|
-
"@capacitor/ios": "
|
|
33
|
+
"@capacitor/ios": "5.0.0",
|
|
34
34
|
"@ionic/eslint-config": "0.3.0",
|
|
35
35
|
"@ionic/prettier-config": "1.0.1",
|
|
36
36
|
"@ionic/swiftlint-config": "1.1.2",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "4.1.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@capacitor/core": "^
|
|
47
|
+
"@capacitor/core": "^5.0.0"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"android/src/main/",
|