Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,6 @@ It's recommended to use `ndkVersion = "24.0.8215888"` (or above) in your root pr

You will need to prebuild the project before using it. See [Expo guide](https://docs.expo.io/guides/using-libraries/#using-a-library-in-a-expo-project) for more details.

## Add Microphone Permissions (Optional)

If you want to use realtime transcribe, you need to add the microphone permission to your app.

### iOS

Add these lines to `ios/[YOU_APP_NAME]/info.plist`

```xml
<key>NSMicrophoneUsageDescription</key>
<string>This app requires microphone access in order to transcribe speech</string>
```

For tvOS, please note that the microphone is not supported.

### Android

Add the following line to `android/app/src/main/AndroidManifest.xml`

```xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
```

## Tips & Tricks

The [Tips & Tricks](docs/TIPS.md) document is a collection of tips and tricks for using `whisper.rn`.
Expand Down Expand Up @@ -320,59 +297,6 @@ We have provided a mock version of `whisper.rn` for testing purpose you can use
jest.mock('whisper.rn', () => require('whisper.rn/jest-mock'))
```

## Deprecated APIs

### `transcribeRealtime` (Deprecated)

> ⚠️ **Deprecated**: Use `RealtimeTranscriber` instead for enhanced features and better performance.

```js
const { stop, subscribe } = await whisperContext.transcribeRealtime(options)

subscribe((evt) => {
const { isCapturing, data, processTime, recordingTime } = evt
console.log(
`Realtime transcribing: ${isCapturing ? 'ON' : 'OFF'}\n` +
`Result: ${data.result}\n\n` +
`Process time: ${processTime}ms\n` +
`Recording time: ${recordingTime}ms`,
)
if (!isCapturing) console.log('Finished realtime transcribing')
})
```

In iOS, You may need to change the Audio Session so that it can be used with other audio playback, or to optimize the quality of the recording. So we have provided AudioSession utilities for you:

Option 1 - Use options in transcribeRealtime:

```js
import { AudioSessionIos } from 'whisper.rn'

const { stop, subscribe } = await whisperContext.transcribeRealtime({
audioSessionOnStartIos: {
category: AudioSessionIos.Category.PlayAndRecord,
options: [AudioSessionIos.CategoryOption.MixWithOthers],
mode: AudioSessionIos.Mode.Default,
},
audioSessionOnStopIos: 'restore', // Or an AudioSessionSettingIos
})
```

Option 2 - Manage the Audio Session in anywhere:

```js
import { AudioSessionIos } from 'whisper.rn'

await AudioSessionIos.setCategory(AudioSessionIos.Category.PlayAndRecord, [
AudioSessionIos.CategoryOption.MixWithOthers,
])
await AudioSessionIos.setMode(AudioSessionIos.Mode.Default)
await AudioSessionIos.setActive(true)
// Then you can start do recording
```

In Android, you may need to request the microphone permission by [`PermissionAndroid`](https://reactnative.dev/docs/permissionsandroid).

## Apps using `whisper.rn`

- [BRICKS](https://bricks.tools): Our product for building interactive signage in simple way. We provide LLM functions as Generator LLM/Assistant.
Expand Down
1 change: 0 additions & 1 deletion android/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ set(
${RNWHISPER_LIB_DIR}/ggml-quants.c
${RNWHISPER_LIB_DIR}/gguf.cpp
${RNWHISPER_LIB_DIR}/whisper.cpp
${RNWHISPER_LIB_DIR}/rn-audioutils.cpp
${RNWHISPER_LIB_DIR}/rn-whisper.cpp
${RNWHISPER_LIB_DIR}/jsi/RNWhisperJSI.cpp
${CMAKE_SOURCE_DIR}/jni.cpp
Expand Down
26 changes: 0 additions & 26 deletions android/src/main/java/com/rnwhisper/RNWhisper.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,6 @@ public void transcribeFile(double id, double jobId, String filePathOrBase64, Rea
promise.reject("Context not found");
return;
}
if (context.isCapturing()) {
promise.reject("The context is in realtime transcribe mode");
return;
}
if (context.isTranscribing()) {
promise.reject("Context is already transcribing");
return;
Expand Down Expand Up @@ -279,10 +275,6 @@ public void transcribeData(double id, double jobId, String dataBase64, ReadableM
promise.reject("Context not found");
return;
}
if (context.isCapturing()) {
promise.reject("The context is in realtime transcribe mode");
return;
}
if (context.isTranscribing()) {
promise.reject("Context is already transcribing");
return;
Expand All @@ -294,24 +286,6 @@ public void transcribeData(double id, double jobId, String dataBase64, ReadableM
tasks.put(task, "transcribeData-" + id);
}

public void startRealtimeTranscribe(double id, double jobId, ReadableMap options, Promise promise) {
final WhisperContext context = contexts.get((int) id);
if (context == null) {
promise.reject("Context not found");
return;
}
if (context.isCapturing()) {
promise.reject("Context is already in capturing");
return;
}
int state = context.startRealtimeTranscribe((int) jobId, options);
if (state == AudioRecord.STATE_INITIALIZED) {
promise.resolve(null);
return;
}
promise.reject("Failed to start realtime transcribe. State: " + state);
}

public void abortTranscribe(double id, double jobId, Promise promise) {
WhisperContext context = contexts.get((int) id);
if (context == null) {
Expand Down
Loading