@gmessier/nitro-speech 0.0.6 → 0.0.7

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 (2) hide show
  1. package/README.md +94 -9
  2. package/package.json +21 -5
package/README.md CHANGED
@@ -1,11 +1,31 @@
1
1
  # nitro-speech
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@gmessier/nitro-speech.svg)](https://www.npmjs.com/package/@gmessier/nitro-speech)
4
+ [![license](https://img.shields.io/npm/l/@gmessier/nitro-speech.svg)](https://github.com/NotGeorgeMessier/nitro-speech/blob/main/LICENSE)
5
+ [![npm downloads](https://img.shields.io/npm/dm/@gmessier/nitro-speech.svg)](https://www.npmjs.com/package/@gmessier/nitro-speech)
6
+
7
+ > 🐛 [Report Bug](https://github.com/NotGeorgeMessier/nitro-speech/issues) | 💡 [Request Feature](https://github.com/NotGeorgeMessier/nitro-speech/issues)
8
+
3
9
  > **⚠️ Work in Progress**
4
10
  >
5
- > This library is under active development.
11
+ > This library is under active development. (Last version is stable)
6
12
 
7
13
  Speech recognition for React Native, powered by [Nitro Modules](https://github.com/mrousavy/nitro).
8
14
 
15
+ ## Table of Contents
16
+
17
+ - [Installation](#installation)
18
+ - [Permissions](#permissions)
19
+ - [Features](#features)
20
+ - [Usage](#usage)
21
+ - [Recommended: useRecognizer Hook](#recommended-userecognizer-hook)
22
+ - [Alternative: Static Recognizer](#alternative-static-recognizer-not-safe)
23
+ - [API Reference](#api-reference)
24
+ - [Requirements](#requirements)
25
+ - [Troubleshooting](#troubleshooting)
26
+ - [License](#license)
27
+ - [TODO](#todo)
28
+
9
29
  ## Installation
10
30
 
11
31
  ```bash
@@ -16,6 +36,16 @@ yarn add @gmessier/nitro-speech react-native-nitro-modules
16
36
  bun add @gmessier/nitro-speech react-native-nitro-modules
17
37
  ```
18
38
 
39
+ ### Expo
40
+
41
+ This library works with Expo. You need to run prebuild to generate native code:
42
+
43
+ ```bash
44
+ npx expo prebuild
45
+ ```
46
+
47
+ **Note**: Make sure New Arch is enabled in your Expo configuration before running prebuild.
48
+
19
49
  ### iOS
20
50
 
21
51
  ```bash
@@ -54,17 +84,17 @@ Both permissions are required for speech recognition to work on iOS.
54
84
  | Feature | Description | iOS | Android |
55
85
  |---------|-------------|-----|---------|
56
86
  | **Real-time transcription** | Get partial results as the user speaks, enabling live UI updates | ✅ | ✅ |
57
- | **Auto-stop on silence** | Automatically stops recognition after configurable inactivity period (default: 8s) | ✅ (flag) | ✅ (flag) |
87
+ | **Auto-stop on silence** | Automatically stops recognition after configurable inactivity period (default: 8s) | ✅ | ✅ |
58
88
  | **Auto-finish progress** | Progress callbacks showing countdown until auto-stop | ✅ | ❌ *(TODO)* |
59
- | **Locale support** | Configure speech recognizer for different languages | ✅ (flag) | ✅ (flag) |
89
+ | **Locale support** | Configure speech recognizer for different languages | ✅ | ✅ |
60
90
  | **Background handling** | Auto-stop when app loses focus/goes to background | ✅ | Not Safe *(TODO)* |
61
- | **Contextual strings** | Domain-specific vocabulary for improved accuracy | ✅ (flag) | ✅ (flag) |
62
- | **Repeating word filter** | Removes consecutive duplicate words from artifacts | ✅ (flag) | ✅ (flag) |
91
+ | **Contextual strings** | Domain-specific vocabulary for improved accuracy | ✅ | ✅ |
92
+ | **Repeating word filter** | Removes consecutive duplicate words from artifacts | ✅ | ✅ |
63
93
  | **Permission handling** | Dedicated `onPermissionDenied` callback | ✅ | ✅ |
64
- | **Automatic punctuation** | Adds punctuation to transcription (iOS 16+) | ✅ (flag) | Auto |
65
- | **Language model selection** | Choose between web search vs free-form models | | ✅ (flag) |
66
- | **Offensive word masking** | Control whether offensive words are masked | Auto | ✅ (flag) |
67
- | **Formatting quality** | Prefer quality vs speed in formatting | | ✅ (flag) |
94
+ | **Automatic punctuation** | Adds punctuation to transcription (iOS 16+) | ✅ | Auto |
95
+ | **Language model selection** | Choose between web search vs free-form models | Auto | ✅ |
96
+ | **Offensive word masking** | Control whether offensive words are masked | Auto | ✅ |
97
+ | **Formatting quality** | Prefer quality vs speed in formatting | Auto | ✅ |
68
98
 
69
99
  ## Usage
70
100
 
@@ -182,6 +212,57 @@ The `Recognizer.dispose()` method is **NOT SAFE** and should rarely be used. Hyb
182
212
 
183
213
  **See:** [Nitro dispose() documentation](https://nitro.margelo.com/docs/hybrid-objects#dispose)
184
214
 
215
+ ## API Reference
216
+
217
+ ### `useRecognizer(callbacks)`
218
+
219
+ A React hook that provides lifecycle-aware access to the speech recognizer.
220
+
221
+ #### Parameters
222
+
223
+ - `callbacks` (object):
224
+ - `onReadyForSpeech?: () => void` - Called when speech recognition starts
225
+ - `onResult?: (textBatches: string[]) => void` - Called with transcription results (array of text batches)
226
+ - `onRecordingStopped?: () => void` - Called when recording stops
227
+ - `onAutoFinishProgress?: (timeLeftMs: number) => void` - Called each second during auto-finish countdown
228
+ - `onError?: (message: string) => void` - Called when an error occurs
229
+ - `onPermissionDenied?: () => void` - Called if microphone permission is denied
230
+
231
+ #### Returns
232
+
233
+ - `startListening(params: SpeechToTextParams)` - Start speech recognition with the given parameters
234
+ - `stopListening()` - Stop speech recognition
235
+ - `addAutoFinishTime(additionalTimeMs?: number)` - Add time to the auto-finish timer (or reset to original if no parameter)
236
+ - `updateAutoFinishTime(newTimeMs: number, withRefresh?: boolean)` - Update the auto-finish timer
237
+
238
+ ### `SpeechToTextParams`
239
+
240
+ Configuration object for speech recognition.
241
+
242
+ #### Common Parameters
243
+
244
+ - `locale?: string` - Language locale (default: `"en-US"`)
245
+ - `autoFinishRecognitionMs?: number` - Auto-stop timeout in milliseconds (default: `8000`)
246
+ - `contextualStrings?: string[]` - Array of domain-specific words for better recognition
247
+ - `disableRepeatingFilter?: boolean` - Disable filter that removes consecutive duplicate words (default: `false`)
248
+
249
+ #### iOS-Specific Parameters
250
+
251
+ - `iosAddPunctuation?: boolean` - Add punctuation to results (iOS 16+, default: `true`)
252
+
253
+ #### Android-Specific Parameters
254
+
255
+ - `androidMaskOffensiveWords?: boolean` - Mask offensive words (Android 13+, default: `false`)
256
+ - `androidFormattingPreferQuality?: boolean` - Prefer quality over latency (Android 13+, default: `false`)
257
+ - `androidUseWebSearchModel?: boolean` - Use web search language model instead of free-form (default: `false`)
258
+ - `androidDisableBatchHandling?: boolean` - Disable default batch handling (may add many empty batches, default: `false`)
259
+
260
+ ## Requirements
261
+
262
+ - React Native >= 0.76
263
+ - New Arch Only
264
+ - react-native-nitro-modules
265
+
185
266
  ## Troubleshooting
186
267
 
187
268
  ### Android Gradle sync issues
@@ -192,6 +273,10 @@ If you're having issues with Android Gradle sync, try running the prebuild for t
192
273
  cd android && ./gradlew :react-native-nitro-modules:preBuild
193
274
  ```
194
275
 
276
+ ## License
277
+
278
+ MIT
279
+
195
280
  ## TODO
196
281
 
197
282
  - [ ] (Android) Timer till the auto finish is called
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gmessier/nitro-speech",
3
- "version": "0.0.6",
4
- "description": "nitro-speech",
3
+ "version": "0.0.7",
4
+ "description": "React Native Speech Recognition Library powered by Nitro Modules",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
7
7
  "types": "./lib/typescript/index.d.ts",
@@ -40,15 +40,31 @@
40
40
  "react-native",
41
41
  "speech",
42
42
  "recognition",
43
- "nitro"
43
+ "speech-recognition",
44
+ "speech-to-text",
45
+ "stt",
46
+ "voice",
47
+ "voice-recognition",
48
+ "transcription",
49
+ "audio",
50
+ "microphone",
51
+ "nitro",
52
+ "nitro-modules"
44
53
  ],
45
54
  "repository": {
46
55
  "type": "git",
47
- "url": "git+https://github.com/NotGeorgeMessier/nitro-speech"
56
+ "url": "git+https://github.com/NotGeorgeMessier/nitro-speech.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/NotGeorgeMessier/nitro-speech/issues"
48
60
  },
49
61
  "author": "George Messier",
50
- "homepage": "https://github.com/NotGeorgeMessier/nitro-speech",
62
+ "homepage": "https://github.com/NotGeorgeMessier/nitro-speech#readme",
51
63
  "license": "MIT",
64
+ "engines": {
65
+ "node": ">=14"
66
+ },
67
+ "sideEffects": false,
52
68
  "publishConfig": {
53
69
  "registry": "https://registry.npmjs.org/"
54
70
  },