@capacitor-community/text-to-speech 6.0.0 → 6.1.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/Package.swift +28 -0
- package/android/src/main/java/com/getcapacitor/community/tts/TextToSpeech.java +14 -25
- package/ios/{Plugin → Sources/TextToSpeechPlugin}/TextToSpeechPlugin.swift +11 -1
- package/ios/Tests/TextToSpeechPluginTests/TextToSpeechPluginTests.swift +16 -0
- package/package.json +5 -3
- package/ios/Plugin/Info.plist +0 -24
- package/ios/Plugin/TextToSpeechPlugin.h +0 -10
- package/ios/Plugin/TextToSpeechPlugin.m +0 -13
- /package/ios/{Plugin → Sources/TextToSpeechPlugin}/TextToSpeech.swift +0 -0
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.homepage = package['repository']['url']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
-
s.source_files = 'ios/
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapacitorCommunityTextToSpeech",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapacitorCommunityTextToSpeech",
|
|
10
|
+
targets: ["TextToSpeechPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "TextToSpeechPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/TextToSpeechPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "TextToSpeechPluginTests",
|
|
25
|
+
dependencies: ["TextToSpeechPlugin"],
|
|
26
|
+
path: "ios/Tests/TextToSpeechPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
|
@@ -105,33 +105,22 @@ public class TextToSpeech implements android.speech.tts.TextToSpeech.OnInitListe
|
|
|
105
105
|
|
|
106
106
|
Locale locale = Locale.forLanguageTag(lang);
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
int resultCode = tts.setVoice(newVoice);
|
|
122
|
-
}
|
|
108
|
+
Bundle ttsParams = new Bundle();
|
|
109
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
110
|
+
ttsParams.putSerializable(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, volume);
|
|
111
|
+
|
|
112
|
+
tts.setLanguage(locale);
|
|
113
|
+
tts.setSpeechRate(rate);
|
|
114
|
+
tts.setPitch(pitch);
|
|
115
|
+
|
|
116
|
+
if (voice >= 0) {
|
|
117
|
+
ArrayList<Voice> supportedVoices = getSupportedVoicesOrdered();
|
|
118
|
+
if (voice < supportedVoices.size()) {
|
|
119
|
+
Voice newVoice = supportedVoices.get(voice);
|
|
120
|
+
int resultCode = tts.setVoice(newVoice);
|
|
123
121
|
}
|
|
124
|
-
tts.speak(text, queueStrategy, ttsParams, callbackId);
|
|
125
|
-
} else {
|
|
126
|
-
HashMap<String, String> ttsParams = new HashMap<>();
|
|
127
|
-
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackId);
|
|
128
|
-
ttsParams.put(android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME, Float.toString(volume));
|
|
129
|
-
|
|
130
|
-
tts.setLanguage(locale);
|
|
131
|
-
tts.setSpeechRate(rate);
|
|
132
|
-
tts.setPitch(pitch);
|
|
133
|
-
tts.speak(text, queueStrategy, ttsParams);
|
|
134
122
|
}
|
|
123
|
+
tts.speak(text, queueStrategy, ttsParams, callbackId);
|
|
135
124
|
}
|
|
136
125
|
|
|
137
126
|
public void stop() {
|
|
@@ -7,7 +7,17 @@ import AVFoundation
|
|
|
7
7
|
* here: https://capacitorjs.com/docs/plugins/ios
|
|
8
8
|
*/
|
|
9
9
|
@objc(TextToSpeechPlugin)
|
|
10
|
-
public class TextToSpeechPlugin: CAPPlugin {
|
|
10
|
+
public class TextToSpeechPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
11
|
+
public let identifier = "TextToSpeechPlugin"
|
|
12
|
+
public let jsName = "TextToSpeech"
|
|
13
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
14
|
+
CAPPluginMethod(name: "speak", returnType: CAPPluginReturnPromise),
|
|
15
|
+
CAPPluginMethod(name: "stop", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "openInstall", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "getSupportedLanguages", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "getSupportedVoices", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "isLanguageSupported", returnType: CAPPluginReturnPromise),
|
|
20
|
+
]
|
|
11
21
|
private static let errorUnsupportedLanguage = "This language is not supported."
|
|
12
22
|
|
|
13
23
|
private let implementation = TextToSpeech()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import Plugin
|
|
3
|
+
|
|
4
|
+
class TextToSpeechTests: XCTestCase {
|
|
5
|
+
|
|
6
|
+
func testEcho() {
|
|
7
|
+
// This is an example of a functional test case for a plugin.
|
|
8
|
+
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
9
|
+
|
|
10
|
+
let implementation = TextToSpeech()
|
|
11
|
+
let value = "Hello, World!"
|
|
12
|
+
let result = implementation.echo(value)
|
|
13
|
+
|
|
14
|
+
XCTAssertEqual(value, result)
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/text-to-speech",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"unpkg": "dist/plugin.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
11
|
-
"verify:ios": "
|
|
11
|
+
"verify:ios": "xcodebuild -scheme CapacitorCommunityTextToSpeech -destination generic/platform=iOS",
|
|
12
12
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
13
13
|
"verify:web": "npm run build",
|
|
14
14
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
@@ -50,7 +50,9 @@
|
|
|
50
50
|
"android/src/main/",
|
|
51
51
|
"android/build.gradle",
|
|
52
52
|
"dist/",
|
|
53
|
-
"ios/
|
|
53
|
+
"ios/Sources",
|
|
54
|
+
"ios/Tests",
|
|
55
|
+
"Package.swift",
|
|
54
56
|
"CapacitorCommunityTextToSpeech.podspec"
|
|
55
57
|
],
|
|
56
58
|
"repository": {
|
package/ios/Plugin/Info.plist
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
//! Project version number for Plugin.
|
|
4
|
-
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
-
|
|
6
|
-
//! Project version string for Plugin.
|
|
7
|
-
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
-
|
|
9
|
-
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <Capacitor/Capacitor.h>
|
|
3
|
-
|
|
4
|
-
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
-
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
-
CAP_PLUGIN(TextToSpeechPlugin, "TextToSpeech",
|
|
7
|
-
CAP_PLUGIN_METHOD(speak, CAPPluginReturnPromise);
|
|
8
|
-
CAP_PLUGIN_METHOD(stop, CAPPluginReturnPromise);
|
|
9
|
-
CAP_PLUGIN_METHOD(openInstall, CAPPluginReturnPromise);
|
|
10
|
-
CAP_PLUGIN_METHOD(getSupportedLanguages, CAPPluginReturnPromise);
|
|
11
|
-
CAP_PLUGIN_METHOD(getSupportedVoices, CAPPluginReturnPromise);
|
|
12
|
-
CAP_PLUGIN_METHOD(isLanguageSupported, CAPPluginReturnPromise);
|
|
13
|
-
)
|
|
File without changes
|