Skip to content

Commit 28be479

Browse files
msluszniakclaude
andcommitted
docs: update API reference
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 173e6eb commit 28be479

11 files changed

Lines changed: 348 additions & 31 deletions

docs/docs/06-api-reference/classes/ResourceFetcher.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Class: ResourceFetcher
22

3-
Defined in: [utils/ResourceFetcher.ts:53](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L53)
3+
Defined in: [utils/ResourceFetcher.ts:83](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L83)
44

55
This module provides functions to download and work with downloaded files stored in the application's document directory inside the `react-native-executorch/` directory.
66
These utilities can help you manage your storage and clean up the downloaded files when they are no longer needed.
@@ -21,7 +21,7 @@ These utilities can help you manage your storage and clean up the downloaded fil
2121

2222
> `static` **fs**: `object`
2323
24-
Defined in: [utils/ResourceFetcher.ts:128](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L128)
24+
Defined in: [utils/ResourceFetcher.ts:158](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L158)
2525

2626
Filesystem utilities for reading downloaded resources.
2727

@@ -60,7 +60,7 @@ Currently supports reading file contents as strings for configuration files.
6060

6161
> `static` **fetch**(`callback?`, ...`sources`): `Promise`\<`string`[] \| `null`\>
6262
63-
Defined in: [utils/ResourceFetcher.ts:105](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L105)
63+
Defined in: [utils/ResourceFetcher.ts:135](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L135)
6464

6565
Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch.
6666

@@ -91,7 +91,7 @@ If the fetch was interrupted, it returns a promise which resolves to `null`.
9191

9292
> `static` **getAdapter**(): [`ResourceFetcherAdapter`](../interfaces/ResourceFetcherAdapter.md)
9393
94-
Defined in: [utils/ResourceFetcher.ts:87](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L87)
94+
Defined in: [utils/ResourceFetcher.ts:117](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L117)
9595

9696
Gets the current resource fetcher adapter instance.
9797

@@ -115,7 +115,7 @@ If no adapter has been set via [setAdapter](#setadapter).
115115

116116
> `static` **resetAdapter**(): `void`
117117
118-
Defined in: [utils/ResourceFetcher.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L74)
118+
Defined in: [utils/ResourceFetcher.ts:104](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L104)
119119

120120
Resets the resource fetcher adapter to null.
121121

@@ -133,7 +133,7 @@ Resets the resource fetcher adapter to null.
133133

134134
> `static` **setAdapter**(`adapter`): `void`
135135
136-
Defined in: [utils/ResourceFetcher.ts:64](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L64)
136+
Defined in: [utils/ResourceFetcher.ts:94](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L94)
137137

138138
Sets a custom resource fetcher adapter for resource operations.
139139

docs/docs/06-api-reference/classes/TextToSpeechModule.md

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Class: TextToSpeechModule
22

3-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:17](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L17)
3+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:18](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L18)
44

55
Module for Text to Speech (TTS) functionalities.
66

@@ -20,7 +20,7 @@ Module for Text to Speech (TTS) functionalities.
2020

2121
> **nativeModule**: `any` = `null`
2222
23-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:21](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L21)
23+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L22)
2424

2525
Native module instance
2626

@@ -30,7 +30,7 @@ Native module instance
3030

3131
> **delete**(): `void`
3232
33-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:182](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L182)
33+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:229](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L229)
3434

3535
Unloads the model from memory.
3636

@@ -44,7 +44,7 @@ Unloads the model from memory.
4444

4545
> **forward**(`text`, `speed?`): `Promise`\<`Float32Array`\<`ArrayBufferLike`\>\>
4646
47-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:109](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L109)
47+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:118](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L118)
4848

4949
Synthesizes the provided text into speech.
5050
Returns a promise that resolves to the full audio waveform as a `Float32Array`.
@@ -71,11 +71,43 @@ A promise resolving to the synthesized audio waveform.
7171

7272
---
7373

74+
### forwardFromPhonemes()
75+
76+
> **forwardFromPhonemes**(`phonemes`, `speed?`): `Promise`\<`Float32Array`\<`ArrayBufferLike`\>\>
77+
78+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:135](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L135)
79+
80+
Synthesizes pre-computed phonemes into speech, bypassing the built-in phonemizer.
81+
This allows using an external G2P system (e.g. the Python `phonemizer` library,
82+
espeak-ng, or any custom phonemizer).
83+
84+
#### Parameters
85+
86+
##### phonemes
87+
88+
`string`
89+
90+
The pre-computed IPA phoneme string.
91+
92+
##### speed?
93+
94+
`number` = `1.0`
95+
96+
Optional speed multiplier for the speech synthesis (default is 1.0).
97+
98+
#### Returns
99+
100+
`Promise`\<`Float32Array`\<`ArrayBufferLike`\>\>
101+
102+
A promise resolving to the synthesized audio waveform.
103+
104+
---
105+
74106
### load()
75107

76108
> **load**(`config`, `onDownloadProgressCallback?`): `Promise`\<`void`\>
77109
78-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:30](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L30)
110+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:31](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L31)
79111

80112
Loads the model and voice assets specified by the config object.
81113
`onDownloadProgressCallback` allows you to monitor the current progress.
@@ -104,7 +136,7 @@ Optional callback to monitor download progress.
104136

105137
> **stream**(`input`): `AsyncGenerator`\<`Float32Array`\<`ArrayBufferLike`\>\>
106138
107-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:127](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L127)
139+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:196](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L196)
108140

109141
Starts a streaming synthesis session. Yields audio chunks as they are generated.
110142

@@ -124,11 +156,36 @@ An async generator yielding Float32Array audio chunks.
124156

125157
---
126158

159+
### streamFromPhonemes()
160+
161+
> **streamFromPhonemes**(`input`): `AsyncGenerator`\<`Float32Array`\<`ArrayBufferLike`\>\>
162+
163+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:210](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L210)
164+
165+
Starts a streaming synthesis session from pre-computed phonemes.
166+
Bypasses the built-in phonemizer, allowing use of external G2P systems.
167+
168+
#### Parameters
169+
170+
##### input
171+
172+
[`TextToSpeechStreamingPhonemeInput`](../interfaces/TextToSpeechStreamingPhonemeInput.md)
173+
174+
Input object containing phonemes and optional speed.
175+
176+
#### Returns
177+
178+
`AsyncGenerator`\<`Float32Array`\<`ArrayBufferLike`\>\>
179+
180+
An async generator yielding Float32Array audio chunks.
181+
182+
---
183+
127184
### streamStop()
128185

129186
> **streamStop**(): `void`
130187
131-
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:175](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L175)
188+
Defined in: [modules/natural_language_processing/TextToSpeechModule.ts:222](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts#L222)
132189

133190
Stops the streaming process if there is any ongoing.
134191

docs/docs/06-api-reference/functions/useTextToSpeech.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **useTextToSpeech**(`TextToSpeechProps`): [`TextToSpeechType`](../interfaces/TextToSpeechType.md)
44
5-
Defined in: [hooks/natural_language_processing/useTextToSpeech.ts:19](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts#L19)
5+
Defined in: [hooks/natural_language_processing/useTextToSpeech.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts#L22)
66

77
React hook for managing Text to Speech instance.
88

docs/docs/06-api-reference/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,11 @@
262262
- [TextToImageType](interfaces/TextToImageType.md)
263263
- [TextToSpeechConfig](interfaces/TextToSpeechConfig.md)
264264
- [TextToSpeechInput](interfaces/TextToSpeechInput.md)
265+
- [TextToSpeechPhonemeInput](interfaces/TextToSpeechPhonemeInput.md)
265266
- [TextToSpeechProps](interfaces/TextToSpeechProps.md)
267+
- [TextToSpeechStreamingCallbacks](interfaces/TextToSpeechStreamingCallbacks.md)
266268
- [TextToSpeechStreamingInput](interfaces/TextToSpeechStreamingInput.md)
269+
- [TextToSpeechStreamingPhonemeInput](interfaces/TextToSpeechStreamingPhonemeInput.md)
267270
- [TextToSpeechType](interfaces/TextToSpeechType.md)
268271
- [TokenizerProps](interfaces/TokenizerProps.md)
269272
- [TokenizerType](interfaces/TokenizerType.md)

docs/docs/06-api-reference/interfaces/ResourceFetcherAdapter.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Interface: ResourceFetcherAdapter
22

3-
Defined in: [utils/ResourceFetcher.ts:18](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L18)
3+
Defined in: [utils/ResourceFetcher.ts:48](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L48)
44

55
Adapter interface for resource fetching operations.
66
**Required Methods:**
@@ -19,7 +19,7 @@ these two methods for the library to function correctly.
1919

2020
> **fetch**(`callback`, ...`sources`): `Promise`\<`string`[] \| `null`\>
2121
22-
Defined in: [utils/ResourceFetcher.ts:30](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L30)
22+
Defined in: [utils/ResourceFetcher.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L60)
2323

2424
Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch.
2525

@@ -54,7 +54,7 @@ If the fetch was interrupted, it returns a promise which resolves to `null`.
5454

5555
> **readAsString**(`path`): `Promise`\<`string`\>
5656
57-
Defined in: [utils/ResourceFetcher.ts:44](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L44)
57+
Defined in: [utils/ResourceFetcher.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/utils/ResourceFetcher.ts#L74)
5858

5959
Read file contents as a string.
6060

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Interface: TextToSpeechPhonemeInput
2+
3+
Defined in: [types/tts.ts:103](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L103)
4+
5+
Text to Speech module input for pre-computed phonemes.
6+
Use this when you have your own phonemizer (e.g. the Python `phonemizer`
7+
library, espeak-ng, or any custom G2P system) and want to bypass the
8+
built-in phonemizer pipeline.
9+
10+
## Extended by
11+
12+
- [`TextToSpeechStreamingPhonemeInput`](TextToSpeechStreamingPhonemeInput.md)
13+
14+
## Properties
15+
16+
### phonemes
17+
18+
> **phonemes**: `string`
19+
20+
Defined in: [types/tts.ts:104](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L104)
21+
22+
pre-computed IPA phoneme string
23+
24+
---
25+
26+
### speed?
27+
28+
> `optional` **speed**: `number`
29+
30+
Defined in: [types/tts.ts:105](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L105)
31+
32+
optional speed argument - the higher it is, the faster the speech becomes
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Interface: TextToSpeechStreamingCallbacks
2+
3+
Defined in: [types/tts.ts:189](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L189)
4+
5+
Shared streaming lifecycle callbacks for TTS streaming modes.
6+
7+
## Extended by
8+
9+
- [`TextToSpeechStreamingInput`](TextToSpeechStreamingInput.md)
10+
- [`TextToSpeechStreamingPhonemeInput`](TextToSpeechStreamingPhonemeInput.md)
11+
12+
## Properties
13+
14+
### onBegin()?
15+
16+
> `optional` **onBegin**: () => `void` \| `Promise`\<`void`\>
17+
18+
Defined in: [types/tts.ts:190](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L190)
19+
20+
Called when streaming begins
21+
22+
#### Returns
23+
24+
`void` \| `Promise`\<`void`\>
25+
26+
---
27+
28+
### onEnd()?
29+
30+
> `optional` **onEnd**: () => `void` \| `Promise`\<`void`\>
31+
32+
Defined in: [types/tts.ts:192](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L192)
33+
34+
Called when streaming ends
35+
36+
#### Returns
37+
38+
`void` \| `Promise`\<`void`\>
39+
40+
---
41+
42+
### onNext()?
43+
44+
> `optional` **onNext**: (`audio`) => `void` \| `Promise`\<`void`\>
45+
46+
Defined in: [types/tts.ts:191](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L191)
47+
48+
Called after each audio chunk gets calculated.
49+
50+
#### Parameters
51+
52+
##### audio
53+
54+
`Float32Array`
55+
56+
#### Returns
57+
58+
`void` \| `Promise`\<`void`\>

docs/docs/06-api-reference/interfaces/TextToSpeechStreamingInput.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Interface: TextToSpeechStreamingInput
22

3-
Defined in: [types/tts.ts:156](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L156)
3+
Defined in: [types/tts.ts:205](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L205)
44

55
Text to Speech streaming input definition
66

@@ -11,43 +11,51 @@ Callbacks can be both synchronous or asynchronous.
1111

1212
## Extends
1313

14-
- [`TextToSpeechInput`](TextToSpeechInput.md)
14+
- [`TextToSpeechInput`](TextToSpeechInput.md).[`TextToSpeechStreamingCallbacks`](TextToSpeechStreamingCallbacks.md)
1515

1616
## Properties
1717

1818
### onBegin()?
1919

2020
> `optional` **onBegin**: () => `void` \| `Promise`\<`void`\>
2121
22-
Defined in: [types/tts.ts:157](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L157)
22+
Defined in: [types/tts.ts:190](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L190)
2323

2424
Called when streaming begins
2525

2626
#### Returns
2727

2828
`void` \| `Promise`\<`void`\>
2929

30+
#### Inherited from
31+
32+
[`TextToSpeechStreamingCallbacks`](TextToSpeechStreamingCallbacks.md).[`onBegin`](TextToSpeechStreamingCallbacks.md#onbegin)
33+
3034
---
3135

3236
### onEnd()?
3337

3438
> `optional` **onEnd**: () => `void` \| `Promise`\<`void`\>
3539
36-
Defined in: [types/tts.ts:159](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L159)
40+
Defined in: [types/tts.ts:192](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L192)
3741

3842
Called when streaming ends
3943

4044
#### Returns
4145

4246
`void` \| `Promise`\<`void`\>
4347

48+
#### Inherited from
49+
50+
[`TextToSpeechStreamingCallbacks`](TextToSpeechStreamingCallbacks.md).[`onEnd`](TextToSpeechStreamingCallbacks.md#onend)
51+
4452
---
4553

4654
### onNext()?
4755

4856
> `optional` **onNext**: (`audio`) => `void` \| `Promise`\<`void`\>
4957
50-
Defined in: [types/tts.ts:158](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L158)
58+
Defined in: [types/tts.ts:191](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/tts.ts#L191)
5159

5260
Called after each audio chunk gets calculated.
5361

@@ -61,6 +69,10 @@ Called after each audio chunk gets calculated.
6169

6270
`void` \| `Promise`\<`void`\>
6371

72+
#### Inherited from
73+
74+
[`TextToSpeechStreamingCallbacks`](TextToSpeechStreamingCallbacks.md).[`onNext`](TextToSpeechStreamingCallbacks.md#onnext)
75+
6476
---
6577

6678
### speed?

0 commit comments

Comments
 (0)