react-native-voice-ts 1.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.
Files changed (51) hide show
  1. package/.nvmrc +1 -0
  2. package/.prettierrc +5 -0
  3. package/.releaserc +15 -0
  4. package/CONTRIBUTING.md +293 -0
  5. package/LICENSE +21 -0
  6. package/MIGRATION_SUMMARY.md +510 -0
  7. package/README.md +576 -0
  8. package/android/build.gradle +126 -0
  9. package/android/gradle.properties +5 -0
  10. package/android/src/main/AndroidManifest.xml +8 -0
  11. package/android/src/main/VoiceSpec.kt +55 -0
  12. package/android/src/main/java/com/wenkesj/voice/Voice.kt +343 -0
  13. package/android/src/main/java/com/wenkesj/voice/VoiceModule.kt +63 -0
  14. package/android/src/main/java/com/wenkesj/voice/VoicePackage.kt +35 -0
  15. package/android/src/newarch/VoiceSpec.kt +55 -0
  16. package/android/src/oldarch/VoiceSpec.kt +30 -0
  17. package/app.plugin.js +1 -0
  18. package/dist/NativeVoiceAndroid.d.ts +22 -0
  19. package/dist/NativeVoiceAndroid.d.ts.map +1 -0
  20. package/dist/NativeVoiceAndroid.js +3 -0
  21. package/dist/NativeVoiceAndroid.js.map +1 -0
  22. package/dist/NativeVoiceIOS.d.ts +18 -0
  23. package/dist/NativeVoiceIOS.d.ts.map +1 -0
  24. package/dist/NativeVoiceIOS.js +3 -0
  25. package/dist/NativeVoiceIOS.js.map +1 -0
  26. package/dist/VoiceModuleTypes.d.ts +54 -0
  27. package/dist/VoiceModuleTypes.d.ts.map +1 -0
  28. package/dist/VoiceModuleTypes.js +2 -0
  29. package/dist/VoiceModuleTypes.js.map +1 -0
  30. package/dist/VoiceUtilTypes.d.ts +43 -0
  31. package/dist/VoiceUtilTypes.d.ts.map +1 -0
  32. package/dist/VoiceUtilTypes.js +8 -0
  33. package/dist/VoiceUtilTypes.js.map +1 -0
  34. package/dist/index.d.ts +72 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +395 -0
  37. package/dist/index.js.map +1 -0
  38. package/ios/Voice/Voice.h +14 -0
  39. package/ios/Voice/Voice.mm +672 -0
  40. package/ios/Voice.xcodeproj/project.pbxproj +272 -0
  41. package/ios/Voice.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  42. package/package.json +101 -0
  43. package/plugin/build/withVoice.d.ts +13 -0
  44. package/plugin/build/withVoice.js +47 -0
  45. package/plugin/tsconfig.tsbuildinfo +1 -0
  46. package/react-native-voice.podspec +46 -0
  47. package/src/NativeVoiceAndroid.ts +28 -0
  48. package/src/NativeVoiceIOS.ts +24 -0
  49. package/src/VoiceModuleTypes.ts +64 -0
  50. package/src/VoiceUtilTypes.ts +46 -0
  51. package/src/index.ts +500 -0
@@ -0,0 +1,272 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ DC0729BA1EF78E41004EBC83 /* Voice.m in Sources */ = {isa = PBXBuildFile; fileRef = DC0729B91EF78E41004EBC83 /* Voice.m */; };
11
+ DC0729BB1EF78E41004EBC83 /* Voice.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DC0729B81EF78E41004EBC83 /* Voice.h */; };
12
+ /* End PBXBuildFile section */
13
+
14
+ /* Begin PBXCopyFilesBuildPhase section */
15
+ DC0729B31EF78E41004EBC83 /* CopyFiles */ = {
16
+ isa = PBXCopyFilesBuildPhase;
17
+ buildActionMask = 2147483647;
18
+ dstPath = "include/$(PRODUCT_NAME)";
19
+ dstSubfolderSpec = 16;
20
+ files = (
21
+ DC0729BB1EF78E41004EBC83 /* Voice.h in CopyFiles */,
22
+ );
23
+ runOnlyForDeploymentPostprocessing = 0;
24
+ };
25
+ /* End PBXCopyFilesBuildPhase section */
26
+
27
+ /* Begin PBXFileReference section */
28
+ DC0729B51EF78E41004EBC83 /* libVoice.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libVoice.a; sourceTree = BUILT_PRODUCTS_DIR; };
29
+ DC0729B81EF78E41004EBC83 /* Voice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Voice.h; sourceTree = "<group>"; };
30
+ DC0729B91EF78E41004EBC83 /* Voice.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Voice.m; sourceTree = "<group>"; };
31
+ /* End PBXFileReference section */
32
+
33
+ /* Begin PBXFrameworksBuildPhase section */
34
+ DC0729B21EF78E41004EBC83 /* Frameworks */ = {
35
+ isa = PBXFrameworksBuildPhase;
36
+ buildActionMask = 2147483647;
37
+ files = (
38
+ );
39
+ runOnlyForDeploymentPostprocessing = 0;
40
+ };
41
+ /* End PBXFrameworksBuildPhase section */
42
+
43
+ /* Begin PBXGroup section */
44
+ DC0729AC1EF78E41004EBC83 = {
45
+ isa = PBXGroup;
46
+ children = (
47
+ DC0729B71EF78E41004EBC83 /* Voice */,
48
+ DC0729B61EF78E41004EBC83 /* Products */,
49
+ );
50
+ sourceTree = "<group>";
51
+ };
52
+ DC0729B61EF78E41004EBC83 /* Products */ = {
53
+ isa = PBXGroup;
54
+ children = (
55
+ DC0729B51EF78E41004EBC83 /* libVoice.a */,
56
+ );
57
+ name = Products;
58
+ sourceTree = "<group>";
59
+ };
60
+ DC0729B71EF78E41004EBC83 /* Voice */ = {
61
+ isa = PBXGroup;
62
+ children = (
63
+ DC0729B81EF78E41004EBC83 /* Voice.h */,
64
+ DC0729B91EF78E41004EBC83 /* Voice.m */,
65
+ );
66
+ path = Voice;
67
+ sourceTree = "<group>";
68
+ };
69
+ /* End PBXGroup section */
70
+
71
+ /* Begin PBXNativeTarget section */
72
+ DC0729B41EF78E41004EBC83 /* Voice */ = {
73
+ isa = PBXNativeTarget;
74
+ buildConfigurationList = DC0729BE1EF78E41004EBC83 /* Build configuration list for PBXNativeTarget "Voice" */;
75
+ buildPhases = (
76
+ DC0729B11EF78E41004EBC83 /* Sources */,
77
+ DC0729B21EF78E41004EBC83 /* Frameworks */,
78
+ DC0729B31EF78E41004EBC83 /* CopyFiles */,
79
+ );
80
+ buildRules = (
81
+ );
82
+ dependencies = (
83
+ );
84
+ name = Voice;
85
+ productName = Voice;
86
+ productReference = DC0729B51EF78E41004EBC83 /* libVoice.a */;
87
+ productType = "com.apple.product-type.library.static";
88
+ };
89
+ /* End PBXNativeTarget section */
90
+
91
+ /* Begin PBXProject section */
92
+ DC0729AD1EF78E41004EBC83 /* Project object */ = {
93
+ isa = PBXProject;
94
+ attributes = {
95
+ LastUpgradeCheck = 0830;
96
+ ORGANIZATIONNAME = Rudie_Shahinian;
97
+ TargetAttributes = {
98
+ DC0729B41EF78E41004EBC83 = {
99
+ CreatedOnToolsVersion = 8.3.2;
100
+ DevelopmentTeam = BQE8UXP5LX;
101
+ ProvisioningStyle = Automatic;
102
+ };
103
+ };
104
+ };
105
+ buildConfigurationList = DC0729B01EF78E41004EBC83 /* Build configuration list for PBXProject "Voice" */;
106
+ compatibilityVersion = "Xcode 3.2";
107
+ developmentRegion = English;
108
+ hasScannedForEncodings = 0;
109
+ knownRegions = (
110
+ en,
111
+ );
112
+ mainGroup = DC0729AC1EF78E41004EBC83;
113
+ productRefGroup = DC0729B61EF78E41004EBC83 /* Products */;
114
+ projectDirPath = "";
115
+ projectRoot = "";
116
+ targets = (
117
+ DC0729B41EF78E41004EBC83 /* Voice */,
118
+ );
119
+ };
120
+ /* End PBXProject section */
121
+
122
+ /* Begin PBXSourcesBuildPhase section */
123
+ DC0729B11EF78E41004EBC83 /* Sources */ = {
124
+ isa = PBXSourcesBuildPhase;
125
+ buildActionMask = 2147483647;
126
+ files = (
127
+ DC0729BA1EF78E41004EBC83 /* Voice.m in Sources */,
128
+ );
129
+ runOnlyForDeploymentPostprocessing = 0;
130
+ };
131
+ /* End PBXSourcesBuildPhase section */
132
+
133
+ /* Begin XCBuildConfiguration section */
134
+ DC0729BC1EF78E41004EBC83 /* Debug */ = {
135
+ isa = XCBuildConfiguration;
136
+ buildSettings = {
137
+ ALWAYS_SEARCH_USER_PATHS = NO;
138
+ CLANG_ANALYZER_NONNULL = YES;
139
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
140
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
141
+ CLANG_CXX_LIBRARY = "libc++";
142
+ CLANG_ENABLE_MODULES = YES;
143
+ CLANG_ENABLE_OBJC_ARC = YES;
144
+ CLANG_WARN_BOOL_CONVERSION = YES;
145
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
146
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
147
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
148
+ CLANG_WARN_EMPTY_BODY = YES;
149
+ CLANG_WARN_ENUM_CONVERSION = YES;
150
+ CLANG_WARN_INFINITE_RECURSION = YES;
151
+ CLANG_WARN_INT_CONVERSION = YES;
152
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
153
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
154
+ CLANG_WARN_UNREACHABLE_CODE = YES;
155
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
156
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
157
+ COPY_PHASE_STRIP = NO;
158
+ DEBUG_INFORMATION_FORMAT = dwarf;
159
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
160
+ ENABLE_TESTABILITY = YES;
161
+ GCC_C_LANGUAGE_STANDARD = gnu99;
162
+ GCC_DYNAMIC_NO_PIC = NO;
163
+ GCC_NO_COMMON_BLOCKS = YES;
164
+ GCC_OPTIMIZATION_LEVEL = 0;
165
+ GCC_PREPROCESSOR_DEFINITIONS = (
166
+ "DEBUG=1",
167
+ "$(inherited)",
168
+ );
169
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
170
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
171
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
172
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
173
+ GCC_WARN_UNUSED_FUNCTION = YES;
174
+ GCC_WARN_UNUSED_VARIABLE = YES;
175
+ HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/Headers/Private/React";
176
+ IPHONEOS_DEPLOYMENT_TARGET = 10.3;
177
+ MTL_ENABLE_DEBUG_INFO = YES;
178
+ ONLY_ACTIVE_ARCH = YES;
179
+ SDKROOT = iphoneos;
180
+ };
181
+ name = Debug;
182
+ };
183
+ DC0729BD1EF78E41004EBC83 /* Release */ = {
184
+ isa = XCBuildConfiguration;
185
+ buildSettings = {
186
+ ALWAYS_SEARCH_USER_PATHS = NO;
187
+ CLANG_ANALYZER_NONNULL = YES;
188
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
189
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
190
+ CLANG_CXX_LIBRARY = "libc++";
191
+ CLANG_ENABLE_MODULES = YES;
192
+ CLANG_ENABLE_OBJC_ARC = YES;
193
+ CLANG_WARN_BOOL_CONVERSION = YES;
194
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
195
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
196
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
197
+ CLANG_WARN_EMPTY_BODY = YES;
198
+ CLANG_WARN_ENUM_CONVERSION = YES;
199
+ CLANG_WARN_INFINITE_RECURSION = YES;
200
+ CLANG_WARN_INT_CONVERSION = YES;
201
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
202
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
203
+ CLANG_WARN_UNREACHABLE_CODE = YES;
204
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
205
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
206
+ COPY_PHASE_STRIP = NO;
207
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
208
+ ENABLE_NS_ASSERTIONS = NO;
209
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
210
+ GCC_C_LANGUAGE_STANDARD = gnu99;
211
+ GCC_NO_COMMON_BLOCKS = YES;
212
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
213
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
214
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
215
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
216
+ GCC_WARN_UNUSED_FUNCTION = YES;
217
+ GCC_WARN_UNUSED_VARIABLE = YES;
218
+ HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/Headers/Private/React";
219
+ IPHONEOS_DEPLOYMENT_TARGET = 10.3;
220
+ MTL_ENABLE_DEBUG_INFO = NO;
221
+ SDKROOT = iphoneos;
222
+ VALIDATE_PRODUCT = YES;
223
+ };
224
+ name = Release;
225
+ };
226
+ DC0729BF1EF78E41004EBC83 /* Debug */ = {
227
+ isa = XCBuildConfiguration;
228
+ buildSettings = {
229
+ DEVELOPMENT_TEAM = BQE8UXP5LX;
230
+ OTHER_LDFLAGS = "-ObjC";
231
+ PRODUCT_NAME = "$(TARGET_NAME)";
232
+ SKIP_INSTALL = YES;
233
+ SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/React/Base $(SRCROOT)/../node_modules/react-native/Libraries";
234
+ };
235
+ name = Debug;
236
+ };
237
+ DC0729C01EF78E41004EBC83 /* Release */ = {
238
+ isa = XCBuildConfiguration;
239
+ buildSettings = {
240
+ DEVELOPMENT_TEAM = BQE8UXP5LX;
241
+ OTHER_LDFLAGS = "-ObjC";
242
+ PRODUCT_NAME = "$(TARGET_NAME)";
243
+ SKIP_INSTALL = YES;
244
+ SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/React/Base $(SRCROOT)/../node_modules/react-native/Libraries";
245
+ };
246
+ name = Release;
247
+ };
248
+ /* End XCBuildConfiguration section */
249
+
250
+ /* Begin XCConfigurationList section */
251
+ DC0729B01EF78E41004EBC83 /* Build configuration list for PBXProject "Voice" */ = {
252
+ isa = XCConfigurationList;
253
+ buildConfigurations = (
254
+ DC0729BC1EF78E41004EBC83 /* Debug */,
255
+ DC0729BD1EF78E41004EBC83 /* Release */,
256
+ );
257
+ defaultConfigurationIsVisible = 0;
258
+ defaultConfigurationName = Release;
259
+ };
260
+ DC0729BE1EF78E41004EBC83 /* Build configuration list for PBXNativeTarget "Voice" */ = {
261
+ isa = XCConfigurationList;
262
+ buildConfigurations = (
263
+ DC0729BF1EF78E41004EBC83 /* Debug */,
264
+ DC0729C01EF78E41004EBC83 /* Release */,
265
+ );
266
+ defaultConfigurationIsVisible = 0;
267
+ defaultConfigurationName = Release;
268
+ };
269
+ /* End XCConfigurationList section */
270
+ };
271
+ rootObject = DC0729AD1EF78E41004EBC83 /* Project object */;
272
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:Voice.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "react-native-voice-ts",
3
+ "description": "React Native Native Voice library for iOS and Android",
4
+ "version": "1.0.0",
5
+ "author": "Noor Mohammad <noor.jsdivs@gmail.com>",
6
+ "private": false,
7
+ "homepage": "https://github.com/noorjsdivs/react-native-voice-ts",
8
+ "devDependencies": {
9
+ "@react-native-community/eslint-config": "^3.2.0",
10
+ "@semantic-release/git": "^10.0.1",
11
+ "@types/invariant": "^2.2.37",
12
+ "@types/node": "^25.0.3",
13
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
14
+ "@typescript-eslint/parser": "^8.50.1",
15
+ "eslint": "9.39.2",
16
+ "eslint-plugin-react": "^7.37.5",
17
+ "eslint-plugin-react-hooks": "^7.0.1",
18
+ "eslint-plugin-react-native": "^5.0.0",
19
+ "expo-module-scripts": "^5.0.8",
20
+ "lint-staged": "^16.2.7",
21
+ "prettier": "^3.7.4",
22
+ "react": "^19.2.1",
23
+ "react-native": "^0.83.0",
24
+ "semantic-release": "^25.0.2",
25
+ "typescript": "5.9.3"
26
+ },
27
+ "keywords": [
28
+ "react-native",
29
+ "voice",
30
+ "speech",
31
+ "speech-to-text",
32
+ "voice-recognition",
33
+ "speech-recognition",
34
+ "stt",
35
+ "android",
36
+ "ios",
37
+ "typescript",
38
+ "microphone",
39
+ "audio",
40
+ "transcription"
41
+ ],
42
+ "license": "MIT",
43
+ "source": "src/index.ts",
44
+ "main": "dist/index.js",
45
+ "types": "dist/index.d.ts",
46
+ "peerDependencies": {
47
+ "expo": ">=48.0.0",
48
+ "react": ">=18.0.0",
49
+ "react-native": ">=0.71.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "expo": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/noorjsdivs/react-native-voice-ts.git"
59
+ },
60
+ "bugs": {
61
+ "url": "https://github.com/noorjsdivs/react-native-voice-ts/issues"
62
+ },
63
+
64
+ "scripts": {
65
+ "lint": "eslint src/* --fix",
66
+ "lint:check": "eslint src/*",
67
+ "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
68
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\"",
69
+ "semantic-release": "semantic-release",
70
+ "start": "yarn --cwd example start",
71
+ "ios": "yarn --cwd example ios",
72
+ "android": "yarn --cwd example android",
73
+ "prepare": "yarn build && yarn build:plugin",
74
+ "build": "tsc",
75
+ "build:watch": "tsc --watch",
76
+ "dev-sync": "cp -r ./dist example/node_modules/react-native-voice-ts",
77
+ "type-check": "tsc --noEmit",
78
+ "type-check:watch": "tsc --noEmit --watch",
79
+ "build:plugin": "tsc --build plugin",
80
+ "lint:plugin": "eslint plugin/src/* --fix",
81
+ "clean": "rm -rf dist && rm -rf plugin/build",
82
+ "prepack": "yarn clean && yarn build && yarn build:plugin",
83
+ "test": "jest",
84
+ "validate": "yarn type-check && yarn lint:check && yarn format:check"
85
+ },
86
+ "dependencies": {
87
+ "invariant": "^2.2.4"
88
+ },
89
+ "codegenConfig": {
90
+ "name": "RNVoiceSpec",
91
+ "type": "all",
92
+ "jsSrcsDir": "src",
93
+ "outputDir": {
94
+ "ios": "ios/generated",
95
+ "android": "android/generated"
96
+ },
97
+ "android": {
98
+ "javaPackageName": "com.wenkesj.voice"
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,13 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ export type Props = {
3
+ /**
4
+ * `NSSpeechRecognitionUsageDescription` message.
5
+ */
6
+ speechRecognitionPermission?: string | false;
7
+ /**
8
+ * `NSMicrophoneUsageDescription` message.
9
+ */
10
+ microphonePermission?: string | false;
11
+ };
12
+ declare const _default: ConfigPlugin<void | Props>;
13
+ export default _default;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("@expo/config-plugins");
4
+ const pkg = require('react-native-voice-ts/package.json');
5
+ const MICROPHONE = 'Allow $(PRODUCT_NAME) to access the microphone';
6
+ const SPEECH_RECOGNITION = 'Allow $(PRODUCT_NAME) to securely recognize user speech';
7
+ /**
8
+ * Adds `NSMicrophoneUsageDescription` and `NSSpeechRecognitionUsageDescription` to the `Info.plist`.
9
+ *
10
+ * @param props.speechRecognitionPermission speech recognition message
11
+ * @param props.microphonePermission microphone permission message
12
+ * @returns
13
+ */
14
+ const withIosPermissions = (c, { microphonePermission, speechRecognitionPermission } = {}) => {
15
+ return (0, config_plugins_1.withInfoPlist)(c, (config) => {
16
+ if (microphonePermission !== false) {
17
+ config.modResults.NSMicrophoneUsageDescription =
18
+ microphonePermission ||
19
+ config.modResults.NSMicrophoneUsageDescription ||
20
+ MICROPHONE;
21
+ }
22
+ if (speechRecognitionPermission !== false) {
23
+ config.modResults.NSSpeechRecognitionUsageDescription =
24
+ speechRecognitionPermission ||
25
+ config.modResults.NSSpeechRecognitionUsageDescription ||
26
+ SPEECH_RECOGNITION;
27
+ }
28
+ return config;
29
+ });
30
+ };
31
+ /**
32
+ * Adds the following to the `AndroidManifest.xml`: `<uses-permission android:name="android.permission.RECORD_AUDIO" />`
33
+ */
34
+ const withAndroidPermissions = (config) => {
35
+ return config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
36
+ 'android.permission.RECORD_AUDIO',
37
+ ]);
38
+ };
39
+ const withVoice = (config, props = {}) => {
40
+ const _props = props ? props : {};
41
+ config = withIosPermissions(config, _props);
42
+ if (_props.microphonePermission !== false) {
43
+ config = withAndroidPermissions(config);
44
+ }
45
+ return config;
46
+ };
47
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withVoice, pkg.name, pkg.version);
@@ -0,0 +1 @@
1
+ {"root":["./src/withvoice.ts"],"version":"5.9.3"}
@@ -0,0 +1,46 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-voice"
8
+ s.version = package['version']
9
+ s.summary = package['description']
10
+ s.license = package['license']
11
+
12
+ s.authors = package['author']
13
+ s.homepage = package['homepage']
14
+ s.platform = :ios, "9.0"
15
+
16
+ # Link with Speech framework
17
+ s.frameworks = ['Speech']
18
+
19
+ s.source = { :git => "https://github.com/noorjsdivs/react-native-voice-ts.git" }
20
+ s.source_files = "ios/**/*.{h,m,mm,cpp}"
21
+
22
+
23
+
24
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
25
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
26
+ if respond_to?(:install_modules_dependencies, true)
27
+ install_modules_dependencies(s)
28
+ else
29
+ s.dependency "React-Core"
30
+
31
+ # Don't install the dependencies when we run `pod install` in the old architecture.
32
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
33
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
34
+ s.pod_target_xcconfig = {
35
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
36
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
37
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
38
+ }
39
+ s.dependency "React-Codegen"
40
+ s.dependency "RCT-Folly"
41
+ s.dependency "RCTRequired"
42
+ s.dependency "RCTTypeSafety"
43
+ s.dependency "ReactCommon/turbomodule/core"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,28 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+ type SpeechType = {
4
+ EXTRA_LANGUAGE_MODEL: string;
5
+ EXTRA_MAX_RESULTS: string;
6
+ EXTRA_PARTIAL_RESULTS: string;
7
+ REQUEST_PERMISSIONS_AUTO: string;
8
+ RECOGNIZER_ENGINE: string;
9
+ };
10
+ export interface Spec extends TurboModule {
11
+ destroySpeech: (callback: (error: string) => void) => void;
12
+ startSpeech: (
13
+ locale: string,
14
+ opts: SpeechType,
15
+ callback: (error: string) => void,
16
+ ) => void;
17
+ stopSpeech: (callback: (error: string) => void) => void;
18
+ cancelSpeech: (callback: (error: string) => void) => void;
19
+ isSpeechAvailable: (
20
+ callback: (isAvailable: boolean, error: string) => void,
21
+ ) => void;
22
+ getSpeechRecognitionServices(): Promise<string[]>;
23
+ isRecognizing: (callback: (Recognizing: boolean) => void) => void;
24
+ addListener: (eventType: string) => void;
25
+ removeListeners: (count: number) => void;
26
+ }
27
+
28
+ export default TurboModuleRegistry.getEnforcing<Spec>('Voice');
@@ -0,0 +1,24 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ destroySpeech: (callback: (error: string) => void) => void;
6
+ startSpeech: (locale: string, callback: (error: string) => void) => void;
7
+ startTranscription: (
8
+ locale: string,
9
+ callback: (error: string) => void,
10
+ ) => void;
11
+ stopSpeech: (callback: (error: string) => void) => void;
12
+ stopTranscription: (callback: (error: string) => void) => void;
13
+ cancelSpeech: (callback: (error: string) => void) => void;
14
+ cancelTranscription: (callback: (error: string) => void) => void;
15
+ isSpeechAvailable: (
16
+ callback: (isAvailable: boolean, error: string) => void,
17
+ ) => void;
18
+ isRecognizing: (callback: (Recognizing: boolean) => void) => void;
19
+ addListener: (eventType: string) => void;
20
+ removeListeners: (count: number) => void;
21
+ destroyTranscription: (callback: (error: string) => void) => void;
22
+ }
23
+
24
+ export default TurboModuleRegistry.getEnforcing<Spec>('Voice');
@@ -0,0 +1,64 @@
1
+ export type SpeechEvents = {
2
+ onSpeechStart?: (e: SpeechStartEvent) => void;
3
+ onSpeechRecognized?: (e: SpeechRecognizedEvent) => void;
4
+ onSpeechEnd?: (e: SpeechEndEvent) => void;
5
+ onSpeechError?: (e: SpeechErrorEvent) => void;
6
+ onSpeechResults?: (e: SpeechResultsEvent) => void;
7
+ onSpeechPartialResults?: (e: SpeechResultsEvent) => void;
8
+ onSpeechVolumeChanged?: (e: SpeechVolumeChangeEvent) => void;
9
+ };
10
+
11
+ export type TranscriptionEvents = {
12
+ onTranscriptionStart?: (e: TranscriptionStartEvent) => void;
13
+ onTranscriptionEnd?: (e: TranscriptionEndEvent) => void;
14
+ onTranscriptionError?: (e: TranscriptionErrorEvent) => void;
15
+ onTranscriptionResults?: (e: TranscriptionResultsEvent) => void;
16
+ };
17
+
18
+ export type SpeechStartEvent = {
19
+ error?: boolean;
20
+ };
21
+
22
+ export type TranscriptionStartEvent = {
23
+ error?: boolean;
24
+ };
25
+
26
+ export type SpeechRecognizedEvent = {
27
+ isFinal?: boolean;
28
+ };
29
+
30
+ export type SpeechResultsEvent = {
31
+ value?: string[];
32
+ };
33
+
34
+ export type TranscriptionResultsEvent = {
35
+ segments?: string[];
36
+ transcription?: string;
37
+ isFinal?: boolean;
38
+ };
39
+
40
+ export type SpeechErrorEvent = {
41
+ error?: {
42
+ code?: string;
43
+ message?: string;
44
+ };
45
+ };
46
+
47
+ export type TranscriptionErrorEvent = {
48
+ error?: {
49
+ code?: string;
50
+ message?: string;
51
+ };
52
+ };
53
+
54
+ export type SpeechEndEvent = {
55
+ error?: boolean;
56
+ };
57
+
58
+ export type TranscriptionEndEvent = {
59
+ error?: boolean;
60
+ };
61
+
62
+ export type SpeechVolumeChangeEvent = {
63
+ value?: number;
64
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * React Native Voice - Speech Recognition Utility Types
3
+ *
4
+ * This file contains helper types and interfaces for working with
5
+ * speech recognition functionality.
6
+ */
7
+
8
+ export interface VoiceOptions {
9
+ /** Android: Language model type (LANGUAGE_MODEL_FREE_FORM or LANGUAGE_MODEL_WEB_SEARCH) */
10
+ EXTRA_LANGUAGE_MODEL?: string;
11
+ /** Android: Maximum number of results */
12
+ EXTRA_MAX_RESULTS?: number;
13
+ /** Android: Enable partial results */
14
+ EXTRA_PARTIAL_RESULTS?: boolean;
15
+ /** Android: Auto request permissions */
16
+ REQUEST_PERMISSIONS_AUTO?: boolean;
17
+ /** iOS: Detection mode (automatic, manual) */
18
+ iosCategory?: string;
19
+ }
20
+
21
+ export interface RecognitionStats {
22
+ /** Duration of recognition in milliseconds */
23
+ duration: number;
24
+ /** Whether recognition is currently active */
25
+ isActive: boolean;
26
+ /** Last recognized results */
27
+ lastResults: string[];
28
+ /** Start timestamp */
29
+ startTime: number;
30
+ }
31
+
32
+ export interface PermissionResult {
33
+ /** Whether permission was granted */
34
+ granted: boolean;
35
+ /** Error message if permission check failed */
36
+ error?: string;
37
+ }
38
+
39
+ export interface Language {
40
+ /** Language code (e.g., 'en-US') */
41
+ code: string;
42
+ /** Display name */
43
+ name: string;
44
+ /** Whether language is available */
45
+ available: boolean;
46
+ }