@umituz/react-native-ai-generation-content 1.17.229 → 1.17.230
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +346 -0
- package/package.json +1 -3
- package/src/domain/README.md +503 -0
- package/src/domains/content-moderation/README.md +363 -0
- package/src/domains/creations/README.md +394 -0
- package/src/domains/face-detection/README.md +395 -0
- package/src/domains/prompts/README.md +387 -0
- package/src/features/ai-hug/README.md +276 -0
- package/src/features/ai-kiss/README.md +276 -0
- package/src/features/anime-selfie/README.md +325 -0
- package/src/features/audio-generation/README.md +370 -0
- package/src/features/colorization/README.md +289 -0
- package/src/features/couple-future/README.md +270 -0
- package/src/features/face-swap/README.md +234 -0
- package/src/features/future-prediction/README.md +281 -0
- package/src/features/hd-touch-up/README.md +309 -0
- package/src/features/image-captioning/README.md +361 -0
- package/src/features/image-to-image/README.md +418 -0
- package/src/features/image-to-video/README.md +369 -0
- package/src/features/inpainting/README.md +302 -0
- package/src/features/meme-generator/README.md +327 -0
- package/src/features/photo-restoration/README.md +286 -0
- package/src/features/remove-background/README.md +292 -0
- package/src/features/remove-object/README.md +352 -0
- package/src/features/replace-background/README.md +288 -0
- package/src/features/script-generator/README.md +362 -0
- package/src/features/shared/README.md +280 -0
- package/src/features/sketch-to-image/README.md +296 -0
- package/src/features/style-transfer/README.md +301 -0
- package/src/features/text-to-image/README.md +228 -0
- package/src/features/text-to-video/README.md +245 -0
- package/src/features/text-to-voice/README.md +335 -0
- package/src/features/upscaling/README.md +247 -0
- package/src/infrastructure/config/README.md +310 -0
- package/src/infrastructure/middleware/README.md +378 -0
- package/src/infrastructure/orchestration/README.md +362 -0
- package/src/infrastructure/services/README.md +382 -0
- package/src/infrastructure/utils/README.md +523 -0
- package/src/infrastructure/wrappers/README.md +336 -0
- package/src/presentation/components/README.md +535 -0
- package/src/presentation/hooks/README.md +380 -0
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/screens/README.md +430 -0
- package/src/presentation/layouts/types/.npmignore.tmp +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Text to Video
|
|
2
|
+
|
|
3
|
+
Generate videos from text descriptions using AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Create videos from natural language descriptions
|
|
8
|
+
- Support for various video durations
|
|
9
|
+
- Multiple aspect ratios (16:9, 9:16, 1:1)
|
|
10
|
+
- Style presets for different video styles
|
|
11
|
+
- Progress tracking during generation
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This feature is part of `@umituz/react-native-ai-generation-content`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @umituz/react-native-ai-generation-content
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
### Using the Hook
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useTextToVideoFeature } from '@umituz/react-native-ai-generation-content';
|
|
27
|
+
|
|
28
|
+
function TextToVideoScreen() {
|
|
29
|
+
const feature = useTextToVideoFeature({
|
|
30
|
+
config: {
|
|
31
|
+
model: 'veo-3',
|
|
32
|
+
onPromptChange: (prompt) => console.log('Prompt changed:', prompt),
|
|
33
|
+
onProcessingStart: () => console.log('Starting generation...'),
|
|
34
|
+
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
35
|
+
onError: (error) => console.error('Error:', error),
|
|
36
|
+
},
|
|
37
|
+
userId: 'user-123',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View>
|
|
42
|
+
<PromptInput
|
|
43
|
+
prompt={feature.state.prompt}
|
|
44
|
+
onChangePrompt={feature.setPrompt}
|
|
45
|
+
placeholder="Describe the video you want to create..."
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<DurationSelector
|
|
49
|
+
selectedDuration={feature.state.duration}
|
|
50
|
+
onSelectDuration={feature.setDuration}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<AspectRatioSelector
|
|
54
|
+
selectedAspectRatio={feature.state.aspectRatio}
|
|
55
|
+
onSelectAspectRatio={feature.setAspectRatio}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<Button
|
|
59
|
+
title="Generate Video"
|
|
60
|
+
onPress={() => feature.generate()}
|
|
61
|
+
disabled={!feature.isReady}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
{feature.state.isProcessing && (
|
|
65
|
+
<View>
|
|
66
|
+
<Text>Progress: {feature.state.progress}%</Text>
|
|
67
|
+
<ProgressBar progress={feature.state.progress} />
|
|
68
|
+
</View>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
{feature.state.result && (
|
|
72
|
+
<Video source={{ uri: feature.state.result.videoUrl }} />
|
|
73
|
+
)}
|
|
74
|
+
</View>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Using the Unified AI Feature Screen
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
83
|
+
|
|
84
|
+
function App() {
|
|
85
|
+
return (
|
|
86
|
+
<AIFeatureScreen
|
|
87
|
+
featureId="text-to-video"
|
|
88
|
+
userId="user-123"
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Configuration Options
|
|
95
|
+
|
|
96
|
+
### Feature Config
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
interface TextToVideoFeatureConfig {
|
|
100
|
+
model?: string; // AI model to use (default: 'veo-3')
|
|
101
|
+
defaultDuration?: number; // Default video duration in seconds
|
|
102
|
+
defaultAspectRatio?: '16:9' | '9:16' | '1:1';
|
|
103
|
+
onPromptChange?: (prompt: string) => void;
|
|
104
|
+
onProcessingStart?: () => void;
|
|
105
|
+
onProcessingComplete?: (result: TextToVideoResult) => void;
|
|
106
|
+
onError?: (error: string) => void;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Generation Options
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
interface TextToVideoOptions {
|
|
114
|
+
duration: number; // Video duration in seconds
|
|
115
|
+
aspectRatio: '16:9' | '9:16' | '1:1';
|
|
116
|
+
style?: 'realistic' | 'cinematic' | 'anime' | '3d';
|
|
117
|
+
negativePrompt?: string;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Usage Flow
|
|
122
|
+
|
|
123
|
+
1. Enter **Prompt** - Describe the video you want to create
|
|
124
|
+
2. Select **Duration** - Choose video length (4-8 seconds)
|
|
125
|
+
3. Select **Aspect Ratio** - Choose 16:9, 9:16, or 1:1
|
|
126
|
+
4. Tap **Generate** - Start video generation
|
|
127
|
+
5. View Result - Watch the generated video
|
|
128
|
+
6. Save or Share - Download or share the video
|
|
129
|
+
|
|
130
|
+
## Component Examples
|
|
131
|
+
|
|
132
|
+
### Duration Selector
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import { DurationSelector, createDurationOptions } from '@umituz/react-native-ai-generation-content';
|
|
136
|
+
|
|
137
|
+
const durations = createDurationOptions([4, 5, 6, 7, 8]);
|
|
138
|
+
|
|
139
|
+
<DurationSelector
|
|
140
|
+
selectedDuration={duration}
|
|
141
|
+
onSelectDuration={setDuration}
|
|
142
|
+
durations={durations}
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Style Presets
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { StylePresetsGrid } from '@umituz/react-native-ai-generation-content';
|
|
150
|
+
|
|
151
|
+
const styles = [
|
|
152
|
+
{ id: 'realistic', name: 'Realistic', preview: '...' },
|
|
153
|
+
{ id: 'cinematic', name: 'Cinematic', preview: '...' },
|
|
154
|
+
{ id: 'anime', name: 'Anime', preview: '...' },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
<StylePresetsGrid
|
|
158
|
+
styles={styles}
|
|
159
|
+
selectedStyle={selectedStyle}
|
|
160
|
+
onSelectStyle={setSelectedStyle}
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Example Prompts
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
const examplePrompts = [
|
|
168
|
+
'A majestic eagle soaring through mountain peaks at sunrise',
|
|
169
|
+
'A futuristic city with flying cars and neon lights',
|
|
170
|
+
'Ocean waves crashing on a peaceful beach during sunset',
|
|
171
|
+
'A cozy cabin in the woods during winter with falling snow',
|
|
172
|
+
'A dramatic battle scene between two knights in armor',
|
|
173
|
+
];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Advanced Usage
|
|
177
|
+
|
|
178
|
+
### Custom Generation Options
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
const result = await feature.generate({
|
|
182
|
+
duration: 6,
|
|
183
|
+
aspectRatio: '16:9',
|
|
184
|
+
style: 'cinematic',
|
|
185
|
+
negativePrompt: 'blurry, low quality, distorted',
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Progress Stages
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
const { state } = useTextToVideoFeature({ ...config });
|
|
193
|
+
|
|
194
|
+
// Progress stages:
|
|
195
|
+
// - Initializing (0-10%)
|
|
196
|
+
// - Processing prompt (10-30%)
|
|
197
|
+
// - Generating frames (30-70%)
|
|
198
|
+
// - Rendering video (70-90%)
|
|
199
|
+
// - Finalizing (90-100%)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Video Saving
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
const { state, saveVideo } = useTextToVideoFeature({
|
|
206
|
+
config: {
|
|
207
|
+
onProcessingComplete: async (result) => {
|
|
208
|
+
if (result.success && result.videoUrl) {
|
|
209
|
+
await saveVideo(result.videoUrl);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
// ... other props
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Best Practices
|
|
218
|
+
|
|
219
|
+
1. **Detailed Prompts**: Use descriptive prompts for better results
|
|
220
|
+
2. **Duration**: Shorter videos (4-5s) generate faster
|
|
221
|
+
3. **Aspect Ratio**: Match aspect ratio to your use case (16:9 for YouTube, 9:16 for TikTok)
|
|
222
|
+
4. **Style**: Choose appropriate style for your content
|
|
223
|
+
5. **Patience**: Video generation takes time, show progress to users
|
|
224
|
+
|
|
225
|
+
## Error Handling
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
const { state, generate } = useTextToVideoFeature({ ...config });
|
|
229
|
+
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (state.error) {
|
|
232
|
+
Alert.alert('Generation Failed', state.error);
|
|
233
|
+
}
|
|
234
|
+
}, [state.error]);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Related Features
|
|
238
|
+
|
|
239
|
+
- [Text to Image](../text-to-image) - Generate images from text
|
|
240
|
+
- [Image to Video](../image-to-video) - Convert images to videos
|
|
241
|
+
- [Script Generator](../script-generator) - Generate video scripts
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Text to Voice
|
|
2
|
+
|
|
3
|
+
Convert text to natural-sounding speech using AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Convert text to lifelike speech
|
|
8
|
+
- Multiple voice options and languages
|
|
9
|
+
- Adjustable speed and pitch
|
|
10
|
+
- Support for long-form text
|
|
11
|
+
- Natural intonation and expression
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This feature is part of `@umituz/react-native-ai-generation-content`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @umituz/react-native-ai-generation-content
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
### Using the Hook
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useTextToVoiceFeature } from '@umituz/react-native-ai-generation-content';
|
|
27
|
+
|
|
28
|
+
function TextToVoiceScreen() {
|
|
29
|
+
const feature = useTextToVoiceFeature({
|
|
30
|
+
config: {
|
|
31
|
+
model: 'chirp-3',
|
|
32
|
+
onTextChange: (text) => console.log('Text changed:', text),
|
|
33
|
+
onProcessingStart: () => console.log('Starting generation...'),
|
|
34
|
+
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
35
|
+
onError: (error) => console.error('Error:', error),
|
|
36
|
+
},
|
|
37
|
+
userId: 'user-123',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const [sound, setSound] = useState<Sound | null>(null);
|
|
41
|
+
|
|
42
|
+
const playAudio = async () => {
|
|
43
|
+
if (feature.state.audioUrl) {
|
|
44
|
+
const { sound } = await Audio.Sound.createAsync(
|
|
45
|
+
{ uri: feature.state.audioUrl },
|
|
46
|
+
{ shouldPlay: true }
|
|
47
|
+
);
|
|
48
|
+
setSound(sound);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View>
|
|
54
|
+
<TextInput
|
|
55
|
+
placeholder="Enter text to convert to speech..."
|
|
56
|
+
onChangeText={feature.setText}
|
|
57
|
+
value={feature.state.text}
|
|
58
|
+
multiline
|
|
59
|
+
numberOfLines={4}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<VoiceSelector
|
|
63
|
+
selectedVoice={feature.state.voice}
|
|
64
|
+
onSelectVoice={feature.setVoice}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
<Button
|
|
68
|
+
title="Generate Speech"
|
|
69
|
+
onPress={() => feature.generate()}
|
|
70
|
+
disabled={!feature.isReady}
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
{feature.state.isProcessing && (
|
|
74
|
+
<ActivityIndicator />
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{feature.state.audioUrl && (
|
|
78
|
+
<View>
|
|
79
|
+
<Button title="Play Audio" onPress={playAudio} />
|
|
80
|
+
<Button title="Save Audio" onPress={() => feature.saveAudio()} />
|
|
81
|
+
</View>
|
|
82
|
+
)}
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Using the Unified AI Feature Screen
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
92
|
+
|
|
93
|
+
function App() {
|
|
94
|
+
return (
|
|
95
|
+
<AIFeatureScreen
|
|
96
|
+
featureId="text-to-voice"
|
|
97
|
+
userId="user-123"
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Configuration Options
|
|
104
|
+
|
|
105
|
+
### Feature Config
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
interface TextToVoiceFeatureConfig {
|
|
109
|
+
model?: string; // AI model to use (default: 'chirp-3')
|
|
110
|
+
defaultVoice?: string; // Default voice ID
|
|
111
|
+
defaultSpeed?: number; // Speech speed (0.25 - 4.0, default: 1.0)
|
|
112
|
+
defaultPitch?: number; // Pitch adjustment (-20.0 - 20.0, default: 0)
|
|
113
|
+
onTextChange?: (text: string) => void;
|
|
114
|
+
onProcessingStart?: () => void;
|
|
115
|
+
onProcessingComplete?: (result: TextToVoiceResult) => void;
|
|
116
|
+
onError?: (error: string) => void;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Generation Options
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
interface TextToVoiceOptions {
|
|
124
|
+
voice: string; // Voice ID
|
|
125
|
+
speed?: number; // Speech rate (0.25 - 4.0)
|
|
126
|
+
pitch?: number; // Pitch adjustment (-20.0 - 20.0)
|
|
127
|
+
language?: string; // Language code (e.g., 'en-US', 'es-ES')
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Available Voices
|
|
132
|
+
|
|
133
|
+
### English Voices
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
const englishVoices = [
|
|
137
|
+
{ id: 'en-US-Neural2-A', name: 'Female (American)', gender: 'female' },
|
|
138
|
+
{ id: 'en-US-Neural2-B', name: 'Male (American)', gender: 'male' },
|
|
139
|
+
{ id: 'en-GB-Neural2-A', name: 'Female (British)', gender: 'female' },
|
|
140
|
+
{ id: 'en-GB-Neural2-B', name: 'Male (British)', gender: 'male' },
|
|
141
|
+
];
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Multi-Language Voices
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
const voices = [
|
|
148
|
+
{ id: 'es-ES-Neural2-A', name: 'Spanish (Female)', language: 'es-ES' },
|
|
149
|
+
{ id: 'fr-FR-Neural2-A', name: 'French (Female)', language: 'fr-FR' },
|
|
150
|
+
{ id: 'de-DE-Neural2-A', name: 'German (Female)', language: 'de-DE' },
|
|
151
|
+
{ id: 'it-IT-Neural2-A', name: 'Italian (Female)', language: 'it-IT' },
|
|
152
|
+
{ id: 'ja-JP-Neural2-A', name: 'Japanese (Female)', language: 'ja-JP' },
|
|
153
|
+
{ id: 'ko-KR-Neural2-A', name: 'Korean (Female)', language: 'ko-KR' },
|
|
154
|
+
{ id: 'zh-CN-Neural2-A', name: 'Chinese (Female)', language: 'zh-CN' },
|
|
155
|
+
];
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Component Examples
|
|
159
|
+
|
|
160
|
+
### Voice Selector
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
164
|
+
|
|
165
|
+
const voices = [
|
|
166
|
+
{ id: 'voice-1', name: 'Sarah', description: 'American English (Female)' },
|
|
167
|
+
{ id: 'voice-2', name: 'John', description: 'American English (Male)' },
|
|
168
|
+
{ id: 'voice-3', name: 'Emma', description: 'British English (Female)' },
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
<GridSelector
|
|
172
|
+
options={voices}
|
|
173
|
+
selectedOption={selectedVoice}
|
|
174
|
+
onSelectOption={setSelectedVoice}
|
|
175
|
+
/>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Speed Control
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import { Slider } from 'react-native';
|
|
182
|
+
|
|
183
|
+
<Slider
|
|
184
|
+
minimumValue={0.25}
|
|
185
|
+
maximumValue={4.0}
|
|
186
|
+
step={0.25}
|
|
187
|
+
value={speed}
|
|
188
|
+
onValueChange={setSpeed}
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<Text>Speed: {speed}x</Text>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Audio Player
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import { Audio } from 'expo-av';
|
|
198
|
+
import { useState, useEffect } from 'react';
|
|
199
|
+
|
|
200
|
+
const [sound, setSound] = useState<Sound | null>(null);
|
|
201
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
202
|
+
|
|
203
|
+
const playAudio = async () => {
|
|
204
|
+
const { sound } = await Audio.Sound.createAsync(
|
|
205
|
+
{ uri: audioUrl },
|
|
206
|
+
{ shouldPlay: true }
|
|
207
|
+
);
|
|
208
|
+
setSound(sound);
|
|
209
|
+
setIsPlaying(true);
|
|
210
|
+
|
|
211
|
+
sound.setOnPlaybackStatusUpdate((status) => {
|
|
212
|
+
if (status.isLoaded && status.didJustFinish) {
|
|
213
|
+
setIsPlaying(false);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
return sound ? () => sound.unloadAsync() : undefined;
|
|
220
|
+
}, [sound]);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Example Texts
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
const exampleTexts = [
|
|
227
|
+
'Welcome to our amazing product! We\'re excited to have you here.',
|
|
228
|
+
'Once upon a time, in a land far away, there lived a wise old wizard.',
|
|
229
|
+
'Breaking news: Scientists have made a groundbreaking discovery.',
|
|
230
|
+
'The sun was setting over the horizon, painting the sky in orange and pink.',
|
|
231
|
+
'Transform your business with our innovative solutions.',
|
|
232
|
+
];
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Advanced Usage
|
|
236
|
+
|
|
237
|
+
### Custom Voice Options
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
const result = await feature.generate({
|
|
241
|
+
voice: 'en-US-Neural2-A',
|
|
242
|
+
speed: 1.2,
|
|
243
|
+
pitch: 2.0,
|
|
244
|
+
language: 'en-US',
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Long-Form Text
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
// For long texts, consider chunking
|
|
252
|
+
const longText = '...'; // Your long text
|
|
253
|
+
const chunks = longText.match(/.{1,5000}/g) || [];
|
|
254
|
+
|
|
255
|
+
for (const chunk of chunks) {
|
|
256
|
+
const result = await feature.generate({ text: chunk });
|
|
257
|
+
// Process each chunk
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### SSML Support
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
// Some models support SSML for advanced control
|
|
265
|
+
const ssmlText = `
|
|
266
|
+
<speak>
|
|
267
|
+
<p>Hello <break time="1s"/> world!</p>
|
|
268
|
+
<p>This is <emphasis level="strong">important</emphasis>.</p>
|
|
269
|
+
</speak>
|
|
270
|
+
`;
|
|
271
|
+
|
|
272
|
+
const result = await feature.generate({ text: ssmlText, useSSML: true });
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Best Practices
|
|
276
|
+
|
|
277
|
+
1. **Text Length**: Keep text under 5000 characters for best results
|
|
278
|
+
2. **Voice Selection**: Choose voice that matches your content tone
|
|
279
|
+
3. **Speed**: Use 0.8-1.2 speed for most natural speech
|
|
280
|
+
4. **Punctuation**: Use proper punctuation for natural pauses
|
|
281
|
+
5. **Testing**: Test different voices to find the best match
|
|
282
|
+
|
|
283
|
+
## Use Cases
|
|
284
|
+
|
|
285
|
+
### Audiobook Narration
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
const result = await feature.generate({
|
|
289
|
+
voice: 'en-GB-Neural2-B',
|
|
290
|
+
speed: 0.9,
|
|
291
|
+
pitch: 0,
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Voice Assistant
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
const result = await feature.generate({
|
|
299
|
+
voice: 'en-US-Neural2-A',
|
|
300
|
+
speed: 1.1,
|
|
301
|
+
pitch: 1.0,
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Accessibility
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
const result = await feature.generate({
|
|
309
|
+
voice: 'en-US-Neural2-A',
|
|
310
|
+
speed: 1.0,
|
|
311
|
+
pitch: 0,
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Error Handling
|
|
316
|
+
|
|
317
|
+
```tsx
|
|
318
|
+
const { state, generate } = useTextToVoiceFeature({ ...config });
|
|
319
|
+
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
if (state.error) {
|
|
322
|
+
Alert.alert('Generation Failed', state.error);
|
|
323
|
+
}
|
|
324
|
+
}, [state.error]);
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Related Features
|
|
328
|
+
|
|
329
|
+
- [Text to Image](../text-to-image) - Generate images from text
|
|
330
|
+
- [Audio Generation](../audio-generation) - Generate audio content
|
|
331
|
+
- [Script Generator](../script-generator) - Generate scripts for voiceovers
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT
|