react-native-nobodywho 2.5.0 → 4.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.
package/README.md CHANGED
@@ -1,23 +1,56 @@
1
- # NobodyWho React Native
1
+ # NobodyWho React Native / Expo
2
2
 
3
- NobodyWho is a React Native library for running large language models locally and offline on iOS and Android.
3
+ NobodyWho is a React Native / Expo library for running large language models locally and offline on iOS and Android.
4
4
 
5
- Free to use in commercial projects under the EUPL-1.2 license — no API key required. Supports text, vision, embeddings, RAG & function calling.
5
+ Free to use in commercial projects under the EUPL-1.2 license — no API key required. Supports text, vision, hearing, speech-to-text, text-to-speech, voice activity detection, embeddings, RAG & function calling.
6
6
 
7
7
  - [Documentation](https://docs.nobodywho.ooo) — React Native & other frameworks documentation
8
- - [Starter example app](https://github.com/nobodywho-ooo/react-native-starter-example) — Test this library in 5 minutes
8
+ - [RN starter example app](https://github.com/nobodywho-ooo/react-native-starter-example) / [Expo starter example app](https://github.com/nobodywho-ooo/expo-starter-example) — Test this library in 5 minutes
9
9
  - [Discord](https://discord.gg/qhaMc2qCYB) — Get help, share ideas, and connect with other developers
10
10
  - [GitHub Issues](https://github.com/nobodywho-ooo/nobodywho/issues) — Report bugs
11
11
  - [GitHub Discussions](https://github.com/nobodywho-ooo/nobodywho/discussions) — Ask questions and request features
12
12
 
13
- ## Quick Start
13
+ ## How do I get started?
14
14
 
15
- Install the library:
15
+ First, install `react-native-nobodywho`.
16
+ ```bash
17
+ # React Native
18
+ npm install react-native-nobodywho
19
+ # Expo
20
+ npx expo install react-native-nobodywho
21
+ ```
22
+
23
+ ### React Native
24
+
25
+ No additional initialization step is required — the native module is loaded automatically when you first import from the package.
26
+
27
+ ### Expo
28
+
29
+ NobodyWho ships native code, so it does **not** run in [Expo Go](https://docs.expo.dev/get-started/set-up-your-environment/). You need a [development build](https://docs.expo.dev/develop/development-builds/introduction/).
30
+
31
+ #### • Continuous Native Generation (CNG) projects
16
32
 
33
+ In a managed project, `ios/` and `android/` are not committed. For the **first build**, run the command for the platform you are targeting (`run:ios` and `run:android` are alternatives — pick your target). It runs prebuild automatically since the native folders don't exist yet, installs pods, and builds NobodyWho in:
34
+
35
+ ```bash
36
+ npx expo run:ios
37
+ # or
38
+ npx expo run:android
17
39
  ```
18
- npm install react-native-nobodywho
40
+
41
+ After you **upgrade** NobodyWho (or any other native dependency), the native folders already exist, so `run:*` would build against stale native code. Regenerate them from scratch, then rebuild:
42
+
43
+ ```bash
44
+ npx expo prebuild --clean # regenerate ios/ and android/ from scratch
45
+ npx expo run:ios # then rebuild (or run:android)
19
46
  ```
20
47
 
48
+ #### • Bare projects
49
+
50
+ Here `ios/` and `android/` are committed. Autolinking registers the module on your next native build — just rebuild with `expo run:*` (or your existing native build). Do not run `prebuild --clean` here unless you intend to regenerate the native folders, since it overwrites manual native edits.
51
+
52
+ You can also build with [EAS Build](https://docs.expo.dev/build/introduction/) instead of building locally. No config plugin is required.
53
+
21
54
  ## Supported Model Format
22
55
 
23
56
  This library uses the **GGUF format** — a binary format optimized for fast loading and efficient LLM inference. A wide selection of GGUF models is available on [Hugging Face](https://huggingface.co/models).
@@ -152,3 +185,76 @@ const response = await chat
152
185
  You can pass multiple images/audio files and interleave text between them. If the model performs poorly, try reordering the text, audio and image parts — this can make a noticeable difference. If images consume too much context, increase `contextSize` or preprocess images with compression.
153
186
 
154
187
  See the [Vision & Hearing documentation](https://docs.nobodywho.ooo/react-native/vision/) for model recommendations and advanced tips.
188
+
189
+ ---
190
+
191
+ ## Speech to Text
192
+
193
+ Transcribe spoken audio into text using Whisper models in ONNX format:
194
+
195
+ ```typescript
196
+ import { SpeechToText } from "react-native-nobodywho";
197
+
198
+ const stt = await SpeechToText.load({
199
+ source: "hf://onnx-community/whisper-base",
200
+ });
201
+
202
+ const text = await stt.transcribeFile("recording.mp3").completed();
203
+ console.log(text);
204
+ ```
205
+
206
+ You can also transcribe raw PCM buffers with `transcribePcm`, and stream the transcription token by token.
207
+
208
+ See the [Speech to Text documentation](https://docs.nobodywho.ooo/react-native/speech-to-text/) for more.
209
+
210
+ ---
211
+
212
+ ## Text to Speech
213
+
214
+ Generate natural-sounding speech from text, ready to save as a WAV file or play back in your app:
215
+
216
+ ```typescript
217
+ import { TextToSpeech } from "react-native-nobodywho";
218
+
219
+ const tts = await TextToSpeech.load({
220
+ source: "hf://NobodyWho/Kokoro-82M", // Hugging Face repo or local folder.
221
+ voice: "bf_emma", // Voice to use from the model.
222
+ language: "en-gb", // Language code for the input text.
223
+ });
224
+
225
+ const wav = await tts.synthesize("Hello from NobodyWho!");
226
+ // wav is a Uint8Array containing WAV bytes.
227
+ ```
228
+
229
+ NobodyWho supports the Kokoro, Pocket TTS, and Supertonic speech synthesis architectures.
230
+
231
+ See the [Text to Speech documentation](https://docs.nobodywho.ooo/react-native/text-to-speech/) for more.
232
+
233
+ ---
234
+
235
+ ## Voice Activity Detection
236
+
237
+ Detect speech automatically in an audio stream, so you know when to stop listening to the microphone and start transcribing:
238
+
239
+ ```typescript
240
+ import {
241
+ VoiceActivityDetection,
242
+ VoiceActivityDetectionEvent,
243
+ } from "react-native-nobodywho";
244
+
245
+ const vad = await VoiceActivityDetection.load({
246
+ sampleRate: 16000,
247
+ source: "hf://onnx-community/silero-vad",
248
+ });
249
+
250
+ while (true) {
251
+ const chunk = readMic();
252
+ if (vad.push(chunk) === VoiceActivityDetectionEvent.SpeechEnded) break;
253
+ }
254
+
255
+ const speech = vad.finish(); // buffered speech, ready to pass to SpeechToText
256
+ ```
257
+
258
+ You can also segment speech out of an existing recording with `segment()`.
259
+
260
+ See the [Voice Activity Detection documentation](https://docs.nobodywho.ooo/react-native/voice-activity-detection/) for more.
@@ -70,7 +70,11 @@ task resolveNativeLibraries {
70
70
  description = "Downloads NobodyWho native shared libraries from GitHub Releases"
71
71
 
72
72
  doLast {
73
- abiToTriple.each { abi, triple ->
73
+ // Honor reactNativeArchitectures (the standard RN convention for
74
+ // restricting which ABIs a build needs) so a consumer building
75
+ // arm64-v8a-only never triggers an x86_64 download it doesn't need.
76
+ def wantedAbis = reactNativeArchitectures().toList()
77
+ abiToTriple.findAll { abi, triple -> wantedAbis.contains(abi) }.each { abi, triple ->
74
78
  def abiDir = new File(nativeLibsDir, abi)
75
79
  def libFile = new File(abiDir, "libnobodywho_uniffi.so")
76
80