@picovoice/cheetah-react-native
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Cheetah Binding for iOS

Cheetah Speech-to-Text Engine

Made in Vancouver, Canada by Picovoice

Cheetah is an on-device speech-to-text engine. Cheetah is:

  • Private; All voice processing runs locally.
  • Accurate
  • Compact and Computationally-Efficient
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (4, 3) and NVIDIA Jetson Nano

Compatibility

This binding is for running Cheetah on React Native 0.62.2+ on the following platforms:

  • Android 5.0+ (SDK 21+)
  • iOS 10.0+

Installation

To start install, ensure you have installed yarn and CocoaPods. Then, add the following native modules to your react-native project:

yarn add @picovoice/cheetah-react-native

or

npm i @picovoice/cheetah-react-native --save

Link the iOS packageL

cd ios && pod install && cd ..

NOTE: Due to a limitation in React Native CLI auto-linking, the native module cannot be included as a transitive dependency. If you are creating a module that depends on cheetah-react-native, you will have to list these as peer dependencies and require developers to install it alongside.

AccessKey

Cheetah requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cheetah SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Adding custom Cheetah models

Create a custom model using the Picovoice Console or use the default model.

Android

To add a Leopard model file to your Android application, add the file as a bundled resource by placing it under the assets directory of your Android application.

iOS

To add a Leopard model file to your iOS application, add the file as a bundled resource by selecting Build Phases in Xcode and adding it to the Copy Bundle Resources step.

Usage

Transcribe audio:

import {Cheetah, CheetahErrors} from '@picovoice/cheetah-react-native';

const getAudioFrame = () => {
  // get audio frames
}

try {
  while (1) {
    const cheetah = await Cheetah.create("${ACCESS_KEY}", "${MODEL_FILE}")
    const {transcript, isEndpoint} = await cheetah.process(getAudioFrame())
    if (isEndpoint) {
      const {transcript} = await cheetah.flush()
    }
  }
} catch (err: any) {
  if (err instanceof CheetahErrors) {
    // handle error
  }
}

Replace ${ACCESS_KEY} with your AccessKey obtained from Picovoice Console and ${MODEL_FILE} with the file name of the Cheetah model file. Finally, when done be sure to explicitly release the resources using cheetah.delete().

Demo App

For example usage refer to our React Native demo application.

Install

npm i @picovoice/cheetah-react-native

DownloadsWeekly Downloads

10

Version

1.1.0

License

Apache-2.0

Unpacked Size

109 kB

Total Files

38

Last publish

Collaborators

  • dynamix70
  • erismikpico
  • ilavery
  • iliadrm
  • kenarsa
  • kyeo