Skip to main content
This guide helps you migrate from version 0.2.x to 0.3.0 of react-native-sherpa-onnx. Version 0.3.0 introduces significant improvements including full iOS support, better performance, and ~95% size reduction, but requires code changes.

Overview

Version 0.3.0 introduces:
  • Instance-based API (TTS + STT)
  • Improved return types and type safety
  • Model-specific options structure
  • Renamed types and methods
Breaking Changes: This release changes the public API. Please follow all migration steps before upgrading.

Instance-based API (TTS + STT)

1

Understanding the Change

TTS and STT now use an instance-based factory pattern instead of module-level singletons. Each call to createTTS() / createSTT() returns an independent engine instance.Key requirement: You must call .destroy() when done to free native resources.
2

Migrate TTS Code

Before (0.2.x):
After (0.3.0):
3

Migrate STT Code

Before (0.2.x):
After (0.3.0):

Speech-to-Text (STT) Changes

Return Type Changes

transcribeFile now returns a detailed object instead of just a string:
New return type structure:
If you only need the text, use result.text to get the transcription string.

Hotwords Support

initializeSTT now supports two additional optional options:

Deprecated Types

Native Method Renames

If you call the TurboModule directly, methods were renamed:

Text-to-Speech (TTS) Changes

Model Options Structure

Model-specific options (noise scales, length scale) now use a nested modelOptions structure instead of flat properties.

Update Parameters

The updateParams method also uses the new structure:

New Model-Specific Types

The following types are now exported:

Instance Methods and TurboModule

If you call the TurboModule directly, all instance-bound methods now take instanceId as the first parameter:

Deprecated Types

Complete Migration Example

Before (0.2.x):
After (0.3.0):

Common Patterns

Managing Multiple Instances

React Hook Pattern

Need Help?

If you encounter issues during migration:
  1. Check the API Reference for detailed method signatures
  2. Review Troubleshooting for common issues
  3. See Examples for working code samples
  4. Open an issue on GitHub