From 2d6087ccc19db25c2b285389fb9e23ecbc14d815 Mon Sep 17 00:00:00 2001 From: Pablo Romeu Date: Sat, 19 Feb 2022 09:38:48 +0100 Subject: [PATCH 1/2] feature: added volume to iOS --- index.d.ts | 5 +- index.js | 8 + ios/Podfile | 26 ++ ios/Podfile.lock | 369 +++++++++++++++++++++ ios/TextToSpeech.xcodeproj/project.pbxproj | 53 +++ ios/TextToSpeech/TextToSpeech.h | 1 + ios/TextToSpeech/TextToSpeech.m | 24 ++ package.json | 6 +- 8 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 ios/Podfile create mode 100644 ios/Podfile.lock diff --git a/index.d.ts b/index.d.ts index 558f64b..9850da4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -37,7 +37,8 @@ export type TtsError = { | "Android AudioManager error" | "not_available" | "not_found" - | "bad_rate"; + | "bad_rate" + | "bad_volume"; message: string; }; @@ -82,6 +83,7 @@ export type Options = | { iosVoiceId: string; rate: number; + volume: number; androidParams: AndroidOptions; }; @@ -93,6 +95,7 @@ export class ReactNativeTts extends RN.NativeEventEmitter { setDefaultEngine: (engineName: string) => Promise; setDefaultVoice: (voiceId: string) => Promise<"success">; setDefaultRate: (rate: number, skipTransform?: boolean) => Promise<"success">; + setDefaultVolume: (volume: number) => Promise<"success">; setDefaultPitch: (pitch: number) => Promise<"success">; setDefaultLanguage: (language: string) => Promise<"success">; setIgnoreSilentSwitch: (ignoreSilentSwitch: IOSSilentSwitchBehavior) => Promise; diff --git a/index.js b/index.js index 6da7573..683719b 100644 --- a/index.js +++ b/index.js @@ -49,6 +49,14 @@ class Tts extends NativeEventEmitter { setDefaultRate(rate, skipTransform) { return TextToSpeech.setDefaultRate(rate, !!skipTransform); } + setDefaultVolume(volume) { + if (Platform.OS === 'ios') { + return TextToSpeech.setDefaultVolume(volume); + } + else { + return Promise.resolve() + } + } setDefaultPitch(pitch) { return TextToSpeech.setDefaultPitch(pitch); diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..b9c676b --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,26 @@ +# Uncomment the next line to define a global platform for your project +require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' +require_relative '../node_modules/react-native/scripts/react_native_pods' +platform :ios, '11.0' + +# ignore all warnings from all pods +inhibit_all_warnings! + +target 'TextToSpeech' do + + config = use_native_modules! + + use_react_native!(:path => config["reactNativePath"]) + + + # Enables Flipper. + # + # Note that if you have use_frameworks! enabled, Flipper will not work and + # you should disable these next few lines. + + #use_flipper! + #post_install do |installer| + # flipper_post_install(installer) + #end + +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..485c7ce --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,369 @@ +PODS: + - boost-for-react-native (1.63.0) + - DoubleConversion (1.1.6) + - FBLazyVector (0.63.4) + - FBReactNativeSpec (0.63.4): + - Folly (= 2020.01.13.00) + - RCTRequired (= 0.63.4) + - RCTTypeSafety (= 0.63.4) + - React-Core (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - Folly (2020.01.13.00): + - boost-for-react-native + - DoubleConversion + - Folly/Default (= 2020.01.13.00) + - glog + - Folly/Default (2020.01.13.00): + - boost-for-react-native + - DoubleConversion + - glog + - glog (0.3.5) + - RCTRequired (0.63.4) + - RCTTypeSafety (0.63.4): + - FBLazyVector (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTRequired (= 0.63.4) + - React-Core (= 0.63.4) + - React (0.63.4): + - React-Core (= 0.63.4) + - React-Core/DevSupport (= 0.63.4) + - React-Core/RCTWebSocket (= 0.63.4) + - React-RCTActionSheet (= 0.63.4) + - React-RCTAnimation (= 0.63.4) + - React-RCTBlob (= 0.63.4) + - React-RCTImage (= 0.63.4) + - React-RCTLinking (= 0.63.4) + - React-RCTNetwork (= 0.63.4) + - React-RCTSettings (= 0.63.4) + - React-RCTText (= 0.63.4) + - React-RCTVibration (= 0.63.4) + - React-callinvoker (0.63.4) + - React-Core (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default (= 0.63.4) + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/CoreModulesHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/Default (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/DevSupport (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default (= 0.63.4) + - React-Core/RCTWebSocket (= 0.63.4) + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - React-jsinspector (= 0.63.4) + - Yoga + - React-Core/RCTActionSheetHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTAnimationHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTBlobHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTImageHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTLinkingHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTNetworkHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTSettingsHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTTextHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTVibrationHeaders (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-Core/RCTWebSocket (0.63.4): + - Folly (= 2020.01.13.00) + - glog + - React-Core/Default (= 0.63.4) + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsiexecutor (= 0.63.4) + - Yoga + - React-CoreModules (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTTypeSafety (= 0.63.4) + - React-Core/CoreModulesHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - React-RCTImage (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-cxxreact (0.63.4): + - boost-for-react-native (= 1.63.0) + - DoubleConversion + - Folly (= 2020.01.13.00) + - glog + - React-callinvoker (= 0.63.4) + - React-jsinspector (= 0.63.4) + - React-jsi (0.63.4): + - boost-for-react-native (= 1.63.0) + - DoubleConversion + - Folly (= 2020.01.13.00) + - glog + - React-jsi/Default (= 0.63.4) + - React-jsi/Default (0.63.4): + - boost-for-react-native (= 1.63.0) + - DoubleConversion + - Folly (= 2020.01.13.00) + - glog + - React-jsiexecutor (0.63.4): + - DoubleConversion + - Folly (= 2020.01.13.00) + - glog + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - React-jsinspector (0.63.4) + - React-RCTActionSheet (0.63.4): + - React-Core/RCTActionSheetHeaders (= 0.63.4) + - React-RCTAnimation (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTTypeSafety (= 0.63.4) + - React-Core/RCTAnimationHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTBlob (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - React-Core/RCTBlobHeaders (= 0.63.4) + - React-Core/RCTWebSocket (= 0.63.4) + - React-jsi (= 0.63.4) + - React-RCTNetwork (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTImage (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTTypeSafety (= 0.63.4) + - React-Core/RCTImageHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - React-RCTNetwork (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTLinking (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - React-Core/RCTLinkingHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTNetwork (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTTypeSafety (= 0.63.4) + - React-Core/RCTNetworkHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTSettings (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - RCTTypeSafety (= 0.63.4) + - React-Core/RCTSettingsHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - React-RCTText (0.63.4): + - React-Core/RCTTextHeaders (= 0.63.4) + - React-RCTVibration (0.63.4): + - FBReactNativeSpec (= 0.63.4) + - Folly (= 2020.01.13.00) + - React-Core/RCTVibrationHeaders (= 0.63.4) + - React-jsi (= 0.63.4) + - ReactCommon/turbomodule/core (= 0.63.4) + - ReactCommon/turbomodule/core (0.63.4): + - DoubleConversion + - Folly (= 2020.01.13.00) + - glog + - React-callinvoker (= 0.63.4) + - React-Core (= 0.63.4) + - React-cxxreact (= 0.63.4) + - React-jsi (= 0.63.4) + - Yoga (1.14.0) + +DEPENDENCIES: + - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) + - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) + - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`) + - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) + - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) + - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) + - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) + - React (from `../node_modules/react-native/`) + - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) + - React-Core (from `../node_modules/react-native/`) + - React-Core/DevSupport (from `../node_modules/react-native/`) + - React-Core/RCTWebSocket (from `../node_modules/react-native/`) + - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) + - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) + - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) + - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) + - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) + - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) + - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) + - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) + - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) + - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) + - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) + - React-RCTText (from `../node_modules/react-native/Libraries/Text`) + - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) + - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) + +SPEC REPOS: + trunk: + - boost-for-react-native + +EXTERNAL SOURCES: + DoubleConversion: + :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" + FBLazyVector: + :path: "../node_modules/react-native/Libraries/FBLazyVector" + FBReactNativeSpec: + :path: "../node_modules/react-native/Libraries/FBReactNativeSpec" + Folly: + :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" + glog: + :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" + RCTRequired: + :path: "../node_modules/react-native/Libraries/RCTRequired" + RCTTypeSafety: + :path: "../node_modules/react-native/Libraries/TypeSafety" + React: + :path: "../node_modules/react-native/" + React-callinvoker: + :path: "../node_modules/react-native/ReactCommon/callinvoker" + React-Core: + :path: "../node_modules/react-native/" + React-CoreModules: + :path: "../node_modules/react-native/React/CoreModules" + React-cxxreact: + :path: "../node_modules/react-native/ReactCommon/cxxreact" + React-jsi: + :path: "../node_modules/react-native/ReactCommon/jsi" + React-jsiexecutor: + :path: "../node_modules/react-native/ReactCommon/jsiexecutor" + React-jsinspector: + :path: "../node_modules/react-native/ReactCommon/jsinspector" + React-RCTActionSheet: + :path: "../node_modules/react-native/Libraries/ActionSheetIOS" + React-RCTAnimation: + :path: "../node_modules/react-native/Libraries/NativeAnimation" + React-RCTBlob: + :path: "../node_modules/react-native/Libraries/Blob" + React-RCTImage: + :path: "../node_modules/react-native/Libraries/Image" + React-RCTLinking: + :path: "../node_modules/react-native/Libraries/LinkingIOS" + React-RCTNetwork: + :path: "../node_modules/react-native/Libraries/Network" + React-RCTSettings: + :path: "../node_modules/react-native/Libraries/Settings" + React-RCTText: + :path: "../node_modules/react-native/Libraries/Text" + React-RCTVibration: + :path: "../node_modules/react-native/Libraries/Vibration" + ReactCommon: + :path: "../node_modules/react-native/ReactCommon" + Yoga: + :path: "../node_modules/react-native/ReactCommon/yoga" + +SPEC CHECKSUMS: + boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c + DoubleConversion: cde416483dac037923206447da6e1454df403714 + FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e + FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e + Folly: b73c3869541e86821df3c387eb0af5f65addfab4 + glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 + RCTRequired: 082f10cd3f905d6c124597fd1c14f6f2655ff65e + RCTTypeSafety: 8c9c544ecbf20337d069e4ae7fd9a377aadf504b + React: b0a957a2c44da4113b0c4c9853d8387f8e64e615 + React-callinvoker: c3f44dd3cb195b6aa46621fff95ded79d59043fe + React-Core: d3b2a1ac9a2c13c3bcde712d9281fc1c8a5b315b + React-CoreModules: 0581ff36cb797da0943d424f69e7098e43e9be60 + React-cxxreact: c1480d4fda5720086c90df537ee7d285d4c57ac3 + React-jsi: a0418934cf48f25b485631deb27c64dc40fb4c31 + React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949 + React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a + React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336 + React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b + React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0 + React-RCTImage: c1b1f2d3f43a4a528c8946d6092384b5c880d2f0 + React-RCTLinking: 35ae4ab9dc0410d1fcbdce4d7623194a27214fb2 + React-RCTNetwork: 29ec2696f8d8cfff7331fac83d3e893c95ef43ae + React-RCTSettings: 60f0691bba2074ef394f95d4c2265ec284e0a46a + React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c + React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d + ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b + Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6 + +PODFILE CHECKSUM: 13eeac42073304f4f12a21a7055a7e0bef8a63be + +COCOAPODS: 1.11.2 diff --git a/ios/TextToSpeech.xcodeproj/project.pbxproj b/ios/TextToSpeech.xcodeproj/project.pbxproj index fd035af..4aec7b1 100644 --- a/ios/TextToSpeech.xcodeproj/project.pbxproj +++ b/ios/TextToSpeech.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 3A6FB20D1D99E12200593599 /* TextToSpeech.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A6FB20C1D99E12200593599 /* TextToSpeech.m */; }; 3A6FB20E1D99E12200593599 /* TextToSpeech.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3A6FB20B1D99E12200593599 /* TextToSpeech.h */; }; + 624AB8EBA8B6353387FD2929 /* libPods-TextToSpeech.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1579008D29467247321F5733 /* libPods-TextToSpeech.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -25,9 +26,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1579008D29467247321F5733 /* libPods-TextToSpeech.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TextToSpeech.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3A6FB2081D99E12200593599 /* libTextToSpeech.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTextToSpeech.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3A6FB20B1D99E12200593599 /* TextToSpeech.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextToSpeech.h; sourceTree = ""; }; 3A6FB20C1D99E12200593599 /* TextToSpeech.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TextToSpeech.m; sourceTree = ""; }; + 5ABC6C03028F06FC9B41B8C0 /* Pods-TextToSpeech.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TextToSpeech.release.xcconfig"; path = "Target Support Files/Pods-TextToSpeech/Pods-TextToSpeech.release.xcconfig"; sourceTree = ""; }; + 897FD749AAD8936FE9F04125 /* Pods-TextToSpeech.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TextToSpeech.debug.xcconfig"; path = "Target Support Files/Pods-TextToSpeech/Pods-TextToSpeech.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,17 +39,30 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 624AB8EBA8B6353387FD2929 /* libPods-TextToSpeech.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 19FED172E31613803521C7F8 /* Pods */ = { + isa = PBXGroup; + children = ( + 897FD749AAD8936FE9F04125 /* Pods-TextToSpeech.debug.xcconfig */, + 5ABC6C03028F06FC9B41B8C0 /* Pods-TextToSpeech.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 3A6FB1FF1D99E12200593599 = { isa = PBXGroup; children = ( 3A6FB20A1D99E12200593599 /* TextToSpeech */, 3A6FB2091D99E12200593599 /* Products */, + 19FED172E31613803521C7F8 /* Pods */, + B4332D6155AE7B7F0CE4E26D /* Frameworks */, ); sourceTree = ""; }; @@ -66,6 +83,14 @@ path = TextToSpeech; sourceTree = ""; }; + B4332D6155AE7B7F0CE4E26D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1579008D29467247321F5733 /* libPods-TextToSpeech.a */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -73,6 +98,7 @@ isa = PBXNativeTarget; buildConfigurationList = 3A6FB2111D99E12200593599 /* Build configuration list for PBXNativeTarget "TextToSpeech" */; buildPhases = ( + 2A13360D73A79CE60353C273 /* [CP] Check Pods Manifest.lock */, 3A6FB2041D99E12200593599 /* Sources */, 3A6FB2051D99E12200593599 /* Frameworks */, 3A6FB2061D99E12200593599 /* CopyFiles */, @@ -119,6 +145,31 @@ }; /* End PBXProject section */ +/* Begin PBXShellScriptBuildPhase section */ + 2A13360D73A79CE60353C273 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-TextToSpeech-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 3A6FB2041D99E12200593599 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -221,6 +272,7 @@ }; 3A6FB2121D99E12200593599 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 897FD749AAD8936FE9F04125 /* Pods-TextToSpeech.debug.xcconfig */; buildSettings = { DEVELOPMENT_TEAM = ""; HEADER_SEARCH_PATHS = ( @@ -236,6 +288,7 @@ }; 3A6FB2131D99E12200593599 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5ABC6C03028F06FC9B41B8C0 /* Pods-TextToSpeech.release.xcconfig */; buildSettings = { DEVELOPMENT_TEAM = ""; HEADER_SEARCH_PATHS = ( diff --git a/ios/TextToSpeech/TextToSpeech.h b/ios/TextToSpeech/TextToSpeech.h index 25bd220..d5ff243 100644 --- a/ios/TextToSpeech/TextToSpeech.h +++ b/ios/TextToSpeech/TextToSpeech.h @@ -15,6 +15,7 @@ @property (nonatomic, strong) AVSpeechSynthesizer *synthesizer; @property (nonatomic, strong) AVSpeechSynthesisVoice *defaultVoice; @property (nonatomic) float defaultRate; +@property (nonatomic) float defaultVolume; @property (nonatomic) float defaultPitch; @property (nonatomic) bool ducking; @end diff --git a/ios/TextToSpeech/TextToSpeech.m b/ios/TextToSpeech/TextToSpeech.m index a258146..e8ea937 100644 --- a/ios/TextToSpeech/TextToSpeech.m +++ b/ios/TextToSpeech/TextToSpeech.m @@ -61,6 +61,18 @@ + (BOOL)requiresMainQueueSetup } else if (_defaultVoice) { utterance.voice = _defaultVoice; } + + float volume = [[params valueForKey:@"volume"] floatValue]; + if (volume) { + if(volume >= 0 && volume <= 1) { + utterance.volume = volume; + } else { + reject(@"bad_volume", @"Wrong volume value", nil); + return; + } + } else if (_defaultVolume) { + utterance.volume = _defaultVolume; + } float rate = [[params valueForKey:@"rate"] floatValue]; if (rate) { @@ -184,6 +196,18 @@ + (BOOL)requiresMainQueueSetup } } +RCT_EXPORT_METHOD(setDefaultVolume:(float)volume + resolve:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) +{ + if(volume >= 0 && volume <= 1) { + _defaultVolume = volume; + resolve(@"success"); + } else { + reject(@"bad_volume", @"Wrong volume value", nil); + } +} + RCT_EXPORT_METHOD(setDefaultPitch:(float)pitch resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) diff --git a/package.json b/package.json index 240c3cc..6f344e8 100644 --- a/package.json +++ b/package.json @@ -22,5 +22,9 @@ "bugs": { "url": "https://github.com/ak1394/react-native-tts/issues" }, - "homepage": "https://github.com/ak1394/react-native-tts#readme" + "homepage": "https://github.com/ak1394/react-native-tts#readme", + "devDependencies": { + "react": "16.13.1", + "react-native": "0.63.4" + } } From 375ee06f5cf3b296b33ad0ee5d2a67d73d0513db Mon Sep 17 00:00:00 2001 From: Pablo Romeu Date: Sat, 19 Feb 2022 09:42:20 +0100 Subject: [PATCH 2/2] fix: modified readme --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 972f516..b4dde63 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,8 @@ Additionally, speak() allows to pass platform-specific options. // IOS Tts.speak('Hello, world!', { iosVoiceId: 'com.apple.ttsbundle.Moira-compact', - rate: 0.5, + rate: 0.5, + volume: 1.0 }); // Android Tts.speak('Hello, world!', { @@ -79,6 +80,7 @@ The supported options for IOS are: - `iosVoiceId` which voice to use, check [voices()](#list-voices) for available values - `rate` which speech rate this line should be spoken with. Will override [default rate](#set-default-speech-rate) if set for this utterance. +- `volume` sets the volume for the speech. Stop speaking and flush the TTS queue. @@ -151,6 +153,16 @@ Sets default voice, pass one of the voiceId as reported by a call to Tts.voices( Tts.setDefaultVoice('com.apple.ttsbundle.Moira-compact'); ``` +### Set default Volume + +*(only for iOS)* + +Sets default volume for the speech. This should be between 0.0 and 1.0 + +```js +Tts.setDefaultVolume(0.8); +``` + ### Set default Speech Rate Sets default speech rate. The rate parameter is a float where where 0.01 is a slowest rate and 0.99 is the fastest rate.