Skip to content

React Native Bindings

Native bridge modules over the cactus C API for iOS and Android.

Integration

cactus build --apple
cactus build --android
  1. Add the bridge files from this folder to your React Native app
  2. Add the raw bindings they depend on: bindings/kotlin/ (Android), bindings/swift/ (Apple)
  3. Register the Android package in MainApplication.kt:
    override fun getPackages() = PackageList(this).packages.apply {
        add(com.cactus.reactnative.CactusPackage())
    }
    

Usage

import Cactus from './index';

const handle = await Cactus.init('/path/to/model', null, false);
const result = await Cactus.complete(handle, messagesJson, null, null, null, false);
await Cactus.destroy(handle);

Streaming transcription

Push 16 kHz mono PCM16 (base64) as it arrives; each call returns {"success":true,"confirmed":...,"pending":...} (confirmed is final, pending is the volatile tail).

const stream = await Cactus.streamTranscribeStart(handle, '{"language":"en"}');
for (const chunkBase64 of pcmChunks) {
  const json = await Cactus.streamTranscribeProcess(stream, chunkBase64);
  // parse json -> append "confirmed", show "pending" as a live preview
}
const tail = await Cactus.streamTranscribeStop(stream);