Skip to content

Commit a0bdd1c

Browse files
committed
docs: updating the documentations
1 parent 0d0ce9b commit a0bdd1c

2 files changed

Lines changed: 106 additions & 13 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A high-performance text-to-speech library built for bare React Native and Expo,
1111
</div>
1212
<br/>
1313

14-
> **Only New Architecture**: This library is currently compatible with the new architecture. If you're using React Native 0.76 or higher, it is already enabled. However, if your React Native version is between 0.68 and 0.75, you need to enable it first. [Click here if you need help enabling the new architecture](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)
14+
> **Only New Architecture**: This library is only compatible with the new architecture. If you're using React Native 0.76 or higher, it is already enabled. However, if your React Native version is between 0.68 and 0.75, you need to enable it first. [Click here if you need help enabling the new architecture](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)
1515
1616
## Preview
1717

@@ -21,17 +21,19 @@ A high-performance text-to-speech library built for bare React Native and Expo,
2121

2222
## Features
2323

24-
- 🚀 &nbsp;High-performance library built with Turbo Modules for Android and iOS
24+
- 🚀 &nbsp;**High Performance** - Built on Turbo Modules for a fast, native-like experience on Android & iOS
2525

26-
- 🎛️ &nbsp;Provides essential methods for full control over synthesis
26+
- 🎛️ &nbsp;**Full Control** - Complete set of methods for comprehensive speech synthesis management
2727

28-
- 🪄 &nbsp;Support for the `pause` and `resume` methods—including the `onPause` and `onResume` events—on Android as well. Unlike iOS, which natively provides these features, this library implements its own handling on Android (API 26+ required)
28+
- 🪄 &nbsp;**Consistent Playback** - Offers `pause` and `resume` support for iOS and Android. Since this functionality isn’t natively available on Android, the library provides a custom implementation (API 26+) designed to emulate the iOS experience
2929

30-
- 📡 &nbsp;Offers useful events for more precise control over synthesis
30+
- 🔊 &nbsp;**Optional Audio Ducking** - Automatically lowers other app audio to ensure clear, uninterrupted speech
3131

32-
- 💅 &nbsp;Includes a customizable [HighlightedText](./docs/USAGE.md#highlightedtext) component to display the currently spoken text
32+
- 📡 &nbsp;**Rich Events** - Comprehensive event system for precise synthesis lifecycle monitoring
3333

34-
-&nbsp;Fully type-safe and written in TypeScript
34+
- 💅 &nbsp;**Visual Feedback** - Customizable [HighlightedText](./docs/USAGE.md#highlightedtext) component for real-time speech visualization
35+
36+
-&nbsp;**Type Safety** - Fully written in TypeScript with complete type definitions
3537

3638
## Installation
3739

docs/USAGE.md

Lines changed: 97 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
- [Expo](#expo)
77
- [API Overview](#api-overview)
88
- [Getting Available Voices](#getting-available-voices)
9+
- [Engine Management (Android)](#engine-management-android)
10+
- [Get Available Engines](#get-available-engines)
11+
- [Set Speech Engine](#set-speech-engine)
12+
- [Open Voice Data Installer](#open-voice-data-installer)
913
- [Initializing Global Speech Options](#initializing-global-speech-options)
1014
- [Resetting Speech Options](#resetting-speech-options)
1115
- [Speaking Text](#speaking-text)
@@ -113,6 +117,81 @@ Speech.getAvailableVoices('en-US').then(voices => {
113117

114118
---
115119

120+
### Engine Management (Android)
121+
122+
These methods are available only on the Android platform and allow you to manage the underlying text-to-speech engine.
123+
124+
#### Get Available Engines
125+
126+
Gets a list of all available text-to-speech engines installed on the device.
127+
128+
**API Definition**
129+
130+
```ts
131+
Speech.getEngines(): Promise<EngineProps[]>
132+
```
133+
134+
**Engine Properties:**
135+
136+
- `name`: The unique system identifier for the engine (e.g., "com.google.android.tts").
137+
- `label`: The human-readable display name (e.g., "Google Text-to-Speech Engine").
138+
- `isDefault`: A boolean flag indicating if this is the default engine.
139+
140+
**Example Usage:**
141+
142+
```ts
143+
Speech.getEngines().then(engines => {
144+
engines.forEach(engine => {
145+
console.log(`Engine: ${engine.label} (${engine.name})`);
146+
if (engine.isDefault) {
147+
console.log('This is the default engine.');
148+
}
149+
});
150+
});
151+
```
152+
153+
#### Set Speech Engine
154+
155+
Sets the text-to-speech engine to use for all subsequent synthesis.
156+
157+
**API Definition**
158+
159+
```ts
160+
Speech.setEngine(engineName: string): Promise<void>
161+
```
162+
163+
**Example Usage:**
164+
165+
```ts
166+
// First, get available engines
167+
const engines = await Speech.getEngines();
168+
169+
if (engines.length > 0) {
170+
// Then set a specific engine by its name
171+
await Speech.setEngine(engines[0].name);
172+
}
173+
```
174+
175+
#### Open Voice Data Installer
176+
177+
Opens the system activity that allows the user to install or manage TTS voice data.
178+
179+
**API Definition**
180+
181+
```ts
182+
Speech.openVoiceDataInstaller(): Promise<void>
183+
```
184+
185+
**Example Usage:**
186+
187+
```ts
188+
Speech.openVoiceDataInstaller().catch(error => {
189+
console.error('Failed to open voice data installer.', error);
190+
});
191+
```
192+
193+
---
194+
116195
### Initializing Global Speech Options
117196

118197
Set global speech options that apply to all speech synthesis calls.
@@ -125,11 +204,21 @@ Speech.initialize(options: VoiceOptions): void
125204

126205
**VoiceOptions Properties:**
127206

128-
- `language`: Language code or IETF BCP 47 language tag (e.g., `'en-US'`, `'fr-FR'`).
129-
- `volume`: Volume level (from `0.0` to `1.0`).
130-
- `voice`: Specific voice identifier to use.
131-
- `pitch`: Pitch multiplier (Android: `0.1``2.0`; iOS: `0.5``2.0`).
132-
- `rate`: Speech rate (Android: `0.1``2.0`; iOS: varies based on `AVSpeechUtterance` limits).
207+
| Property | Type | Description | Platform Support |
208+
| ------------ | --------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------- |
209+
| `language` | `string` | Language code or IETF BCP 47 language tag (e.g., `'en-US'`, `'fr-FR'`) | Both |
210+
| `volume` | `number` | Volume level from `0.0` (silent) to `1.0` (maximum) | Both |
211+
| `voice` | `string` | Specific voice identifier to use (obtained from `getAvailableVoices()`) | Both |
212+
| `pitch` | `number` | Pitch multiplier: Android `0.1``2.0`, iOS `0.5``2.0` | Both |
213+
| `rate` | `number` | Speech rate: Android `0.1``2.0`, iOS varies based on `AVSpeechUtterance` limits | Both |
214+
| `ducking` | `boolean` | If `true`, temporarily lowers audio from other apps while speech is active. Defaults to `false` | Both |
215+
| `silentMode` | `'obey' \| 'respect' \| 'ignore'` | Controls how speech interacts with the device's silent switch. Ignored if `ducking` is `true` | iOS only |
216+
217+
**silentMode Options (iOS only):**
218+
219+
- **`obey`** (default): Does not change the app's audio session. Speech follows the system default behavior.
220+
- **`respect`**: Speech will be silenced by the ringer switch. Use for non-critical audio content.
221+
- **`ignore`**: Speech will play even if the ringer is off. Use for critical audio when ducking is not desired.
133222

134223
**Example Usage:**
135224

@@ -139,6 +228,8 @@ Speech.initialize({
139228
volume: 1.0,
140229
pitch: 1.2,
141230
rate: 0.8,
231+
ducking: false,
232+
silentMode: 'obey', // iOS only; ignored if ducking is true
142233
});
143234
```
144235

@@ -336,7 +427,7 @@ stoppedSubscription.remove();
336427
337428
**Callback Parameters:**
338429

339-
- `id`: The uttenrance identifier
430+
- `id`: The utterance identifier
340431
- `length`: The text being spoken length
341432
- `location`: The current position in the spoken text
342433

0 commit comments

Comments
 (0)