### Install and Run Example App Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/README.md Instructions to set up and run the example application for react-native-sherpa-onnx. This includes installing dependencies and starting the app on Android or iOS. ```sh cd example yarn install yarn android # or yarn ios ``` -------------------------------- ### Start Example App Packager Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/CONTRIBUTING.md Starts the Metro server for the example application. This is necessary to run the example app. ```sh yarn example start ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS simulator or device. ```sh yarn example ios ``` -------------------------------- ### iOS Setup for React Native Sherpa ONNX Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/README.md Navigate to the iOS directory, install bundle dependencies, and then install pods to set up the sherpa-onnx XCFramework. ```sh cd your-app/ios bundle install bundle exec pod install ``` -------------------------------- ### Create Streaming STT Engine and Process Audio Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/stt-streaming.md Quick start example demonstrating how to create a streaming STT engine, create a stream, feed audio chunks, and process results. Remember to release the stream and destroy the engine when done. ```typescript import { createStreamingSTT } from 'react-native-sherpa-onnx/stt'; // 1) Create streaming engine const engine = await createStreamingSTT({ modelPath: { type: 'asset', path: 'models/streaming-zipformer-en' }, modelType: 'transducer', // or 'auto' to detect }); // 2) Create a stream (one per recognition session) const stream = await engine.createStream(); // 3) Feed audio and get results const { result, isEndpoint } = await stream.processAudioChunk(samples, 16000); console.log('Partial:', result.text); if (isEndpoint) console.log('Utterance ended'); // 4) Cleanup await stream.release(); await engine.destroy(); ``` -------------------------------- ### Run Example App on Android Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. ```sh yarn example android ``` -------------------------------- ### Example of Short Path for Successful Initialization Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/sherpa-onnx-prebuilt/issue-tts-espeak-ng-path-length.md This example shows a shorter, non-problematic path for bundled TTS models that allows for successful espeak-ng initialization. This serves as a control case demonstrating that the issue is specifically related to path length. ```text .../VoiceLabOfflineTools.app/models/vits-piper-de_DE-thorsten-medium-int8/espeak-ng-data ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/CONTRIBUTING.md Installs all necessary dependencies for the project using Yarn workspaces. Run this in the root directory. ```sh yarn ``` -------------------------------- ### Quick Start: Live Transcription with PCM and Streaming STT Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/pcm-live-stream.md Demonstrates the complete workflow for live transcription, from creating a streaming STT engine and PCM live stream to processing audio chunks and cleanup. Ensure microphone permissions are granted before starting. ```typescript import { createPcmLiveStream } from 'react-native-sherpa-onnx/audio'; import { createStreamingSTT, getOnlineTypeOrNull } from 'react-native-sherpa-onnx/stt'; const SAMPLE_RATE = 16000; // 1) Create streaming STT const engine = await createStreamingSTT({ modelPath: { type: 'asset', path: 'models/streaming-zipformer-en' }, modelType: 'transducer', }); const stream = await engine.createStream(); // 2) Create PCM live stream const pcm = createPcmLiveStream({ sampleRate: SAMPLE_RATE }); pcm.onError((msg) => console.error('PCM error:', msg)); const unsubData = pcm.onData(async (samples, sampleRate) => { const { result } = await stream.processAudioChunk(samples, sampleRate); if (result.text) console.log('Partial:', result.text); }); await pcm.start(); // ... recording ... // 3) Stop and cleanup await pcm.stop(); unsubData(); await stream.release(); await engine.destroy(); ``` -------------------------------- ### Example: Endpoint Tuning Configuration Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/stt-streaming.md Provides an example of how to configure custom endpoint detection rules to fine-tune the end-of-utterance behavior. ```APIDOC ## Example: Endpoint tuning This example demonstrates how to customize the `endpointConfig` when initializing the STT engine to adjust end-of-utterance detection sensitivity. ```typescript const engine = await createStreamingSTT({ modelPath: { type: 'asset', path: 'models/streaming-zipformer-en' }, modelType: 'transducer', // Custom endpoint detection configuration endpointConfig: { // Rule 1: Low sensitivity, allows short silences and no speech required initially rule1: { mustContainNonSilence: false, minTrailingSilence: 1.0, minUtteranceLength: 0 }, // Rule 2: Medium sensitivity, requires speech and moderate silence rule2: { mustContainNonSilence: true, minTrailingSilence: 0.8, minUtteranceLength: 0 }, // Rule 3: High sensitivity, limits max utterance length regardless of silence rule3: { mustContainNonSilence: false, minTrailingSilence: 0, minUtteranceLength: 30 }, }, }); ``` ``` -------------------------------- ### Install Coreutils for stdbuf Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/BUILD_MSYS2.md Installs the coreutils package in the MSYS2 shell, which provides the 'stdbuf' command. This command is used to get line-by-line output from FFmpeg's configure and make processes. ```bash pacman -S --noconfirm coreutils ``` -------------------------------- ### Example CSV Row Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/scripts/alignment-models/README.md An example row demonstrating the expected format for the sources.csv file, including model ID, ONNX URL, license URL, license type, and commercial use status. ```text wav2vec2-base-960h-int8;https://huggingface.co/…/model.onnx;https://huggingface.co/…/LICENSE;apache-2.0;yes ``` -------------------------------- ### Install React Native Sherpa ONNX SDK Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/README.md Install the SDK using npm. If your project uses Yarn v3+ or Plug'n'Play, configure Yarn to use the Node Modules linker. ```sh npm install react-native-sherpa-onnx ``` ```yaml # .yarnrc.yml nodeLinker: node-modules ``` ```sh YARN_NODE_LINKER=node-modules yarn install ``` -------------------------------- ### Example: Using processAudioChunk for Simpler Workflow Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/stt-streaming.md Illustrates a simplified approach to streaming STT using the `processAudioChunk` method, which combines multiple operations into a single call for convenience. ```APIDOC ## Example: Using processAudioChunk (simpler) This example shows how to use the `processAudioChunk` method for a more streamlined audio processing loop. ```typescript // Assuming 'stream' is an initialized SttStream object // and 'audioChunks' is an array of audio data buffers for (const chunk of audioChunks) { // Process a chunk of audio and get the result and endpoint status const { result, isEndpoint } = await stream.processAudioChunk(chunk, 16000); if (result.text) { setTranscript(t => t + result.text); // Append recognized text } if (isEndpoint) { // Stop processing if an endpoint is detected break; } } ``` ``` -------------------------------- ### Start Model Download Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Initiates the download process for a model and handles any necessary post-processing. The `onProgress` callback can be used to track download progress. ```typescript await downloadModel(ModelCategory.Tts, 'vits-piper-en_US-lessac-medium', { onProgress: (p) => console.log(p.bytesProcessed, p.totalBytes), }); ``` -------------------------------- ### Configure Gradle for Prebuilt libarchive Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/libarchive_prebuilt/README.md The prebuilt-download.gradle script typically handles the SDK layout for jniLibs and headers. For a local setup, manually copy build outputs to the appropriate directories. ```gradle android/src/main/jniLibs// android/src/main/cpp/include/libarchive ``` -------------------------------- ### Install MinGW64 Packages Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/BUILD_MSYS2.md Installs necessary build tools like make, yasm, diffutils, and the GCC compiler for the x86_64 architecture within the MSYS2 MinGW64 shell. ```bash pacman -S --noconfirm make yasm diffutils mingw-w64-x86_64-gcc ``` -------------------------------- ### Configure Background Downloader Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Configure the background downloader with options for showing notifications and grouping them. This is an optional setup step. ```typescript import { configureBackgroundDownloader } from 'react-native-sherpa-onnx/download'; configureBackgroundDownloader({ showNotificationsEnabled: true, notificationsGrouping: { enabled: false, mode: 'individual', texts: { downloadTitle: 'Model download', downloadStarting: 'Starting...', downloadProgress: 'Downloading... {progress}%', }, }, }); ``` -------------------------------- ### Build Sherpa-Onnx with QNN Support Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/sherpa-onnx-prebuilt/README.md Builds sherpa-onnx with Qualcomm NPU acceleration for arm64-v8a. Requires QNN SDK to be installed and its path set. ```sh export QNN_SDK_ROOT=/path/to/qnn-sdk cd third_party/sherpa-onnx-prebuilt ./build_sherpa_onnx.sh --qnn ``` -------------------------------- ### Example Failure Log Output Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/sherpa-onnx-prebuilt/issue-tts-espeak-ng-path-length.md This log snippet illustrates the error messages observed when espeak-ng fails to initialize due to a path length issue, specifically the 'No such file or directory' error for 'phontab'. ```text [TtsModelDetect] DetectTtsModel: modelDir=.../VoiceLabOfflineTools.app/models/vits-piper-de_DE-thorsten-medium-int8 espeak-ng dataDir=.../vits-piper-de_DE-thorsten-medium-int8/vits-piper-de_DE-thorsten-medium-int8/espeak-ng-data (empty=0) TtsWrapper: TTS: modelDir=.../VoiceLabOfflineTools.app/models/vits-piper-de_DE-thorsten-medium-int8 TtsWrapper: TTS: vits data_dir=.../vits-piper-de_DE-thorsten-medium-int8/espeak-ng-data (empty=0) TtsWrapper: TTS: Creating OfflineTts instance... Error processing file '/usr/share/espeak-ng-data/phontab': No such file or directory. WARNING: All log messages before absl::InitializeLog() is called are written to STDERR E0000 00:00:... init.cc:232] grpc_wait_for_shutdown_with_timeout() timed out. TtsWrapper: TtsWrapper destroyed ``` -------------------------------- ### Example: Mic Input to Partial Results to Endpoint Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/stt-streaming.md Demonstrates a common streaming STT workflow: capturing audio from the microphone, processing it in chunks, updating the UI with partial results, and handling utterance endpoints. ```APIDOC ## Detailed Example: Mic --> chunks --> partial results --> endpoint ```typescript // Initialize the streaming STT engine const engine = await createStreamingSTT({ modelPath: { type: 'asset', path: 'models/streaming-zipformer-en' }, modelType: 'transducer', enableEndpoint: true, // Enable endpoint detection }); // Create a new stream for recognition const stream = await engine.createStream(); // Function to process incoming audio chunks async function onAudioChunk(samples: number[], sampleRate: number) { // Feed audio samples into the stream await stream.acceptWaveform(samples, sampleRate); // Process buffered audio as long as the stream is ready while (await stream.isReady()) { await stream.decode(); // Decode the buffered audio const result = await stream.getResult(); // Get the current recognition result if (result.text) { updateUI(result.text); // Update the user interface with partial text } // Check if an endpoint (end of utterance) is detected if (await stream.isEndpoint()) { onUtteranceEnd(); // Handle the end of an utterance await stream.reset(); // Reset the stream to reuse it for the next utterance break; // Exit the loop after endpoint detection } } } // Cleanup when recording stops or the session ends // await stream.inputFinished(); // Signal end of input if applicable // await stream.release(); // Release stream resources // await engine.destroy(); // Destroy the STT engine ``` ``` -------------------------------- ### Build libshine for Android Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/shine_prebuilt/README.md Sets environment variables for the Android NDK and API level, then executes the build script for libshine. Ensure `ANDROID_NDK_ROOT` points to your NDK installation. ```bash export ANDROID_NDK_ROOT="C:/path/to/android-ndk" export ANDROID_API=24 cd third_party/shine_prebuilt ./build_shine_msys2.sh ``` -------------------------------- ### Build and Run iOS App Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/example/README.md Builds and runs the React Native application on an iOS simulator or device. This command also handles CocoaPods installation if needed. Run from the 'example' directory. ```sh # One-time: install Ruby gems (CocoaPods) if you haven’t already bundle install # Run on simulator (triggers pod install if needed) yarn ios # Or build only (e.g. for CI), output in ios/build yarn build:ios ``` -------------------------------- ### Quick Start: Discover, Detect, and Create STT Engine Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/model-setup.md This snippet demonstrates the typical workflow for setting up an STT engine. It first discovers available bundled models, then detects the type of a specific model, and finally creates the STT engine using the resolved model path. ```typescript import { assetModelPath, listAssetModels, resolveModelPath, } from 'react-native-sherpa-onnx'; import { createSTT, detectSttModel } from 'react-native-sherpa-onnx/stt'; // 1) Discover bundled models const models = await listAssetModels(); // [{ folder: 'sherpa-onnx-whisper-tiny-en', hint: 'stt' }, ...] // 2) Detect model type before loading const modelPath = assetModelPath('models/sherpa-onnx-whisper-tiny-en'); const detection = await detectSttModel(modelPath); console.log(detection.modelType); // 'whisper' // 3) Create engine const stt = await createSTT({ modelPath, modelType: 'auto', // uses detected type }); ``` -------------------------------- ### Hotwords File Format Example Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/hotwords.md Define hotwords in a plain text file, with one phrase per line. An optional score can be appended after a colon to override the global hotwords score for that specific phrase. Lines starting with '#' are treated as phrases, not comments. ```plaintext sherpa onnx :3.0 react native :2.5 zipformer custom term :4.0 ``` -------------------------------- ### Download QNN Runtime Libraries Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/execution-providers.md Demonstrates how to download the QNN model category, which includes the necessary runtime libraries for QNN execution provider. ```typescript import { ModelCategory, downloadModelByCategory } from 'react-native-sherpa-onnx/download'; await downloadModelByCategory(ModelCategory.Qnn, 'qnn-libs-sm8xxx'); ``` -------------------------------- ### Local Use of Publish Script Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/publish-maven/README.md Run this script from the repository root after copying `publish.env.example` to `publish.env` and setting the required environment variables (`MAVEN_VERSION`, `AAR_SRC`, `MAVEN_REPO_PAT`). ```bash ./third_party/ffmpeg_prebuilt/publish-maven/publish-to-github-pages.sh ``` -------------------------------- ### Quick Start: Create TTS Engine and Generate Speech Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/tts.md This snippet demonstrates the basic workflow for initializing a TTS engine, generating speech from text, and saving the resulting audio to a file. Ensure you have the necessary model files and call `tts.destroy()` when finished. ```typescript import { createTTS, saveAudioToFile } from 'react-native-sherpa-onnx/tts'; // 1) Create TTS engine const tts = await createTTS({ modelPath: { type: 'asset', path: 'models/sherpa-onnx-vits-piper-en' }, modelType: 'auto', numThreads: 2, }); // 2) Generate speech const audio = await tts.generateSpeech('Hello, world!'); console.log('sampleRate:', audio.sampleRate, 'samples:', audio.samples.length); // 3) Save to file await saveAudioToFile(audio, '/path/to/output.wav'); // 4) Cleanup await tts.destroy(); ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/example/README.md Starts the Metro JavaScript bundler, which is essential for React Native development. Run this command from the root of your project. ```sh # Using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Test FunASR Model (Multilingual, INT8) Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/test/fixtures/asr-models-structure.txt This example shows how to test the FunASR model with INT8 quantization, supporting multiple languages like Yue, Zh, En, Ja, and Ko. It likely involves processing various audio files. ```python sherpa-onnx-sense-voice-funasr-nano-int8-2025-12-17/test_wavs/yue.wav sherpa-onnx-sense-voice-funasr-nano-int8-2025-12-17/test_wavs/zh.wav sherpa-onnx-sense-voice-funasr-nano-int8-2025-12-17/test_wavs/en.wav sherpa-onnx-sense-voice-funasr-nano-int8-2025-12-17/test_wavs/ja.wav sherpa-onnx-sense-voice-funasr-nano-int8-2025-12-17/test_wavs/ko.wav ``` -------------------------------- ### Install MSYS2 Toolchain Packages Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/shine_prebuilt/README.md Installs necessary build tools and toolchain packages within an MSYS2 MinGW64 or UCRT64 shell. Ensure you run `pacman -Syu` first to update the system. ```bash pacman -Syu --noconfirm pacman -S --noconfirm base-devel make yasm diffutils mingw-w64-x86_64-toolchain ``` -------------------------------- ### TTS Initialization with Model Options After Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/migration.md Demonstrates the new TTS initialization using `modelOptions` for model-specific parameters like noise and length scale. ```typescript createTTS({ modelPath, modelType: 'vits', modelOptions: { vits: { noiseScale: 0.667, noiseScaleW: 0.8, lengthScale: 1.0 } } }) ``` -------------------------------- ### Install MSYS2 Packages for FFmpeg Build Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/README.md Install necessary packages for building FFmpeg on Windows using MSYS2. These packages include build tools, make, yasm, diffutils, and the mingw toolchain. ```bash pacman -Syu --noconfirm pacman -S --noconfirm base-devel make yasm diffutils mingw-w64-x86_64-toolchain ``` -------------------------------- ### Build Sherpa-Onnx (Default, No QNN) Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/sherpa-onnx-prebuilt/README.md Builds all ABIs for sherpa-onnx without Qualcomm NPU support. No extra SDK is required. ```sh cd third_party/sherpa-onnx-prebuilt ./build_sherpa_onnx.sh ``` -------------------------------- ### STT Instance API Before Migration Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/migration.md Illustrates the prior module-level singleton pattern for STT initialization and transcription. ```typescript await initializeSTT({ modelPath: { type: 'asset', path: 'models/whisper' } }); const result = await transcribeFile('/audio.wav'); await unloadSTT(); ``` -------------------------------- ### Example of Long Path Leading to Failure Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/sherpa-onnx-prebuilt/issue-tts-espeak-ng-path-length.md This example illustrates a long path structure for bundled TTS models that can trigger the espeak-ng path length issue on iOS. The nested structure, including a doubled model ID folder, contributes to the overall path length. ```text .../VoiceLabOfflineTools.app/models/vits-piper-de_DE-thorsten-medium-int8/vits-piper-de_DE-thorsten-medium-int8/espeak-ng-data ``` -------------------------------- ### Select Best Execution Provider for ONNX Runtime Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/execution-providers.md Demonstrates how to dynamically select the optimal execution provider (QNN, NNAPI, Core ML, or CPU) based on the platform and device capabilities. It checks for QNN support on Android first, then NNAPI, and Core ML on iOS, falling back to CPU. ```typescript import { getQnnSupport, getNnapiSupport, getXnnpackSupport, getCoreMlSupport, getAvailableProviders, } from 'react-native-sherpa-onnx'; import { Platform } from 'react-native'; // Pick the best provider for this device let provider = 'cpu'; if (Platform.OS === 'android') { const qnn = await getQnnSupport(); if (qnn.canInit) { provider = 'qnn'; } else { const nnapi = await getNnapiSupport(); if (nnapi.canInit) provider = 'nnapi'; } } else { const cml = await getCoreMlSupport(); if (cml.canInit) provider = 'coreml'; } // Pass to engine creation const stt = await createSTT({ modelPath: { type: 'asset', path: 'models/my-stt-model' }, provider, }); ``` -------------------------------- ### List Downloaded Models Migration Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/migration.md Demonstrates the renaming of `listDownloadedModelsByCategory` to `listDownloadedModels` for retrieving a list of installed models. ```typescript // Before const installed = await listDownloadedModelsByCategory(ModelCategory.Alignment); // After const installed = await listDownloadedModels(ModelCategory.Alignment); ``` -------------------------------- ### PcmLiveStreamHandle Methods Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/pcm-live-stream.md The `PcmLiveStreamHandle` provides methods to start, stop, and manage callbacks for PCM audio data and errors. ```APIDOC ## PcmLiveStreamHandle ### Methods - **`start()`** - **Signature:** `() => Promise` - **Description:** Starts native audio capture. Ensure microphone permission is granted before calling this method. - **`stop()`** - **Signature:** `() => Promise` - **Description:** Stops the native audio capture. - **`onData(callback)`** - **Signature:** `(callback: (samples: Float32Array, sampleRate: number) => void) => () => void` - **Description:** Registers a listener for incoming PCM audio chunks. The callback receives `samples` (a `Float32Array` of float PCM data in the range [-1, 1]) and the `sampleRate`. Returns a function to unsubscribe the listener. - **`onError(callback)`** - **Signature:** `(callback: (message: string) => void) => () => void` - **Description:** Registers an error listener. The callback receives an error `message` string. Returns a function to unsubscribe the listener. ### Notes - The `onData` callback receives base64-encoded Int16 PCM from the native side, which is then decoded into a `Float32Array`. ``` -------------------------------- ### configureBackgroundDownloader Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Applies runtime configuration to the background downloader before the first download is initiated. This function does not return a value. ```APIDOC ## configureBackgroundDownloader(options) ### Description Applies downloader runtime config before first download. ### Method (Implicitly a function call in a TypeScript context) ### Parameters #### Path Parameters - **options** (BackgroundDownloaderSetConfigOptions) - Required - The configuration options for the background downloader. ### Response #### Success Response - **void** - This function does not return a value. ``` -------------------------------- ### Build FFmpeg on Linux/macOS Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/README.md Build FFmpeg prebuilts on Linux or macOS. Navigate to the prebuilt directory and execute the build script. ```bash cd third_party/ffmpeg_prebuilt ./build_ffmpeg.sh ``` -------------------------------- ### Extract Model Archive Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Starts the extraction process for a model archive that is already available locally. This is a prerequisite for using the model. ```typescript await extractModel(ModelCategory.Stt, 'sherpa-onnx-whisper-tiny'); ``` -------------------------------- ### Get Incomplete Extractions Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Lists interrupted extractions for a specified model category. Use this to resume or manage partial downloads. ```typescript function getIncompleteExtractions(category: ModelCategory): Promise; const extractionStates = await getIncompleteExtractions(ModelCategory.Stt); ``` -------------------------------- ### Initialize FFmpeg Submodule Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/third_party/ffmpeg_prebuilt/README.md Initialize the FFmpeg submodule if it has not been done already. This command fetches the FFmpeg source code. ```bash git submodule update --init third_party/ffmpeg ``` -------------------------------- ### Disable libarchive on iOS using CocoaPods Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/disable-libarchive.md Set the `SHERPA_ONNX_DISABLE_LIBARCHIVE` environment variable before running `pod install` to skip downloading libarchive.xcframework. ```bash export SHERPA_ONNX_DISABLE_LIBARCHIVE=1 cd ios && pod install ``` -------------------------------- ### Get Model Path Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Retrieves the local file system path for a downloaded model. This path is required for initializing the model with the SDK. ```typescript function getModelPath(category: ModelCategory, id: string): Promise; const path = await getModelPath(ModelCategory.Stt, 'sherpa-onnx-whisper-tiny'); ``` -------------------------------- ### List Models from Multiple Sources Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/model-setup.md Demonstrates how to list models from bundled assets, Play Asset Delivery (PAD), and downloaded models using various helper functions. ```typescript import { listAssetModels, getAssetPackPath, listModelsAtPath, fileModelPath, assetModelPath, } from 'react-native-sherpa-onnx'; import { getLocalModelPathByCategory, listDownloadedModelsByCategory, ModelCategory } from 'react-native-sherpa-onnx/download'; // Bundled const bundled = await listAssetModels(); // PAD (Android) const padPath = await getAssetPackPath('sherpa_models'); const padModels = padPath ? await listModelsAtPath(padPath, true) : []; // Downloaded const downloaded = await listDownloadedModelsByCategory(ModelCategory.Stt); ``` -------------------------------- ### Get Models Cache Status Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/download-manager.md Returns timestamp metadata for the models cache within a specific category. This can be used to determine when the cache was last updated. ```typescript const status = await getModelsCacheStatus(ModelCategory.Stt); ``` -------------------------------- ### Get Whisper Supported Languages Source: https://github.com/xdcobra/react-native-sherpa-onnx/blob/main/docs/stt.md Retrieves a list of languages supported by Whisper models. Use the 'id' for model options and 'name' for display in UI elements. ```typescript import { getWhisperLanguages } from 'react-native-sherpa-onnx/stt'; const languages = getWhisperLanguages(); // languages[0] => { id: 'en', name: 'english' } ```