@umituz/react-native-ai-generation-content 1.17.232 → 1.17.233
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/README.md +236 -261
- package/package.json +1 -1
- package/src/domains/content-moderation/README.md +239 -296
- package/src/domains/creations/README.md +242 -325
- package/src/domains/face-detection/README.md +228 -307
- package/src/domains/prompts/README.md +242 -312
- package/src/features/ai-hug/README.md +381 -219
- package/src/features/ai-kiss/README.md +388 -219
- package/src/features/anime-selfie/README.md +327 -256
- package/src/features/audio-generation/README.md +352 -309
- package/src/features/colorization/README.md +332 -228
- package/src/features/couple-future/README.md +387 -212
- package/src/features/future-prediction/README.md +391 -221
- package/src/features/hd-touch-up/README.md +339 -252
- package/src/features/image-captioning/README.md +359 -299
- package/src/features/image-to-image/README.md +398 -357
- package/src/features/image-to-video/README.md +337 -292
- package/src/features/inpainting/README.md +348 -244
- package/src/features/meme-generator/README.md +350 -269
- package/src/features/remove-background/README.md +335 -234
- package/src/features/remove-object/README.md +341 -288
- package/src/features/replace-background/README.md +353 -236
- package/src/features/script-generator/README.md +358 -287
- package/src/features/shared/README.md +254 -223
- package/src/features/sketch-to-image/README.md +331 -234
- package/src/features/style-transfer/README.md +336 -237
- package/src/features/text-to-video/README.md +360 -193
- package/src/features/text-to-voice/README.md +382 -272
|
@@ -1,335 +1,445 @@
|
|
|
1
|
-
# Text to Voice
|
|
1
|
+
# Text to Voice Feature
|
|
2
2
|
|
|
3
3
|
Convert text to natural-sounding speech using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Support for long-form text
|
|
11
|
-
- Natural intonation and expression
|
|
7
|
+
```typescript
|
|
8
|
+
import { useTextToVoiceFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Location**: `src/features/text-to-voice/`
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
npm install @umituz/react-native-ai-generation-content
|
|
19
|
-
```
|
|
15
|
+
Convert written text into lifelike speech using AI-powered text-to-speech technology. Support for multiple voices, languages, adjustable speed and pitch, with natural intonation and expression for audiobooks, accessibility, voice assistants, and more.
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
---
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
import { useTextToVoiceFeature } from '@umituz/react-native-ai-generation-content';
|
|
21
|
+
### When to Use This Feature
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
```
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Creating audiobooks and narration
|
|
25
|
+
- Building voice assistants
|
|
26
|
+
- Accessibility features for visually impaired
|
|
27
|
+
- Voiceovers for videos and presentations
|
|
28
|
+
- Podcast and content creation
|
|
87
29
|
|
|
88
|
-
|
|
30
|
+
❌ **When NOT to Use:**
|
|
31
|
+
- Generating audio from descriptions (use Audio Generation)
|
|
32
|
+
- Real-time translation (use translation services)
|
|
33
|
+
- Voice cloning or impersonation
|
|
34
|
+
- Music generation
|
|
89
35
|
|
|
90
|
-
|
|
91
|
-
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
36
|
+
### Implementation Strategy
|
|
92
37
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
```
|
|
38
|
+
1. **Enter text** to convert to speech
|
|
39
|
+
2. **Select voice** from available options
|
|
40
|
+
3. **Adjust settings** (speed, pitch)
|
|
41
|
+
4. **Generate speech** with progress tracking
|
|
42
|
+
5. **Preview audio** with playback controls
|
|
43
|
+
6. **Save or share** final audio file
|
|
102
44
|
|
|
103
|
-
|
|
45
|
+
---
|
|
104
46
|
|
|
105
|
-
|
|
47
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
106
48
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
onTextChange?: (text: string) => void;
|
|
114
|
-
onProcessingStart?: () => void;
|
|
115
|
-
onProcessingComplete?: (result: TextToVoiceResult) => void;
|
|
116
|
-
onError?: (error: string) => void;
|
|
117
|
-
}
|
|
118
|
-
```
|
|
49
|
+
### 1. Input Requirements
|
|
50
|
+
- **MUST** provide text to convert
|
|
51
|
+
- **MUST** select valid voice
|
|
52
|
+
- **MUST** keep text under character limits (5000 chars recommended)
|
|
53
|
+
- **MUST NOT** use copyrighted material without permission
|
|
54
|
+
- **MUST NOT** generate offensive or harmful content
|
|
119
55
|
|
|
120
|
-
###
|
|
56
|
+
### 2. Configuration
|
|
57
|
+
- **MUST** provide valid `userId` for tracking
|
|
58
|
+
- **MUST** specify voice selection
|
|
59
|
+
- **MUST** implement `onError` callback
|
|
60
|
+
- **MUST** implement audio playback controls
|
|
61
|
+
- **MUST** handle file saving locally
|
|
121
62
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
```
|
|
63
|
+
### 3. State Management
|
|
64
|
+
- **MUST** check `isReady` before enabling generate button
|
|
65
|
+
- **MUST** validate text and voice before generation
|
|
66
|
+
- **MUST** handle `isProcessing` state to prevent duplicate requests
|
|
67
|
+
- **MUST** display `error` state with clear messages
|
|
68
|
+
- **MUST** implement proper cleanup on unmount (dispose audio)
|
|
130
69
|
|
|
131
|
-
|
|
70
|
+
### 4. Performance
|
|
71
|
+
- **MUST** implement progress indicators during generation
|
|
72
|
+
- **MUST** cache generated audio locally
|
|
73
|
+
- **MUST** allow users to cancel long generations
|
|
74
|
+
- **MUST** implement proper audio file disposal
|
|
75
|
+
- **MUST NOT** generate multiple audio files simultaneously
|
|
132
76
|
|
|
133
|
-
###
|
|
77
|
+
### 5. Audio Quality
|
|
78
|
+
- **MUST** provide audio preview with playback controls
|
|
79
|
+
- **MUST** support common audio formats (MP3, WAV)
|
|
80
|
+
- **MUST** handle large audio file sizes
|
|
81
|
+
- **MUST** implement play/pause/stop controls
|
|
82
|
+
- **MUST** offer regeneration with different settings
|
|
134
83
|
|
|
135
|
-
|
|
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
|
-
```
|
|
84
|
+
---
|
|
143
85
|
|
|
144
|
-
|
|
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
|
-
```
|
|
86
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
157
87
|
|
|
158
|
-
|
|
88
|
+
### Strictly Forbidden
|
|
159
89
|
|
|
160
|
-
|
|
90
|
+
❌ **NEVER** do the following:
|
|
161
91
|
|
|
162
|
-
|
|
163
|
-
|
|
92
|
+
1. **No Empty Text**
|
|
93
|
+
- Always validate text is provided
|
|
94
|
+
- Never call generate() without text
|
|
95
|
+
- Guide users with example texts
|
|
164
96
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
];
|
|
97
|
+
2. **No Auto-Generation**
|
|
98
|
+
- Never start generation without user action
|
|
99
|
+
- Always require explicit "Generate" button press
|
|
100
|
+
- Show preview before processing
|
|
170
101
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
onSelectOption={setSelectedVoice}
|
|
175
|
-
/>
|
|
176
|
-
```
|
|
102
|
+
3. **No Hardcoded Credentials**
|
|
103
|
+
- Never store API keys in component files
|
|
104
|
+
- Use environment variables or secure storage
|
|
177
105
|
|
|
178
|
-
|
|
106
|
+
4. **No Unhandled Errors**
|
|
107
|
+
- Never ignore generation failures
|
|
108
|
+
- Always explain what went wrong
|
|
109
|
+
- Provide retry or alternative options
|
|
179
110
|
|
|
180
|
-
|
|
181
|
-
|
|
111
|
+
5. **No Memory Leaks**
|
|
112
|
+
- Never store multiple audio files in memory
|
|
113
|
+
- Always cleanup audio references on unmount
|
|
114
|
+
- Implement proper audio disposal (unloadAsync)
|
|
182
115
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
value={speed}
|
|
188
|
-
onValueChange={setSpeed}
|
|
189
|
-
/>
|
|
116
|
+
6. **No Blocked UI**
|
|
117
|
+
- Never block main thread with audio processing
|
|
118
|
+
- Always show progress indicator
|
|
119
|
+
- Allow cancellation
|
|
190
120
|
|
|
191
|
-
|
|
192
|
-
|
|
121
|
+
7. **No Copyright Infringement**
|
|
122
|
+
- Never generate copyrighted content without permission
|
|
123
|
+
- Never use for voice cloning or impersonation
|
|
124
|
+
- Implement content moderation
|
|
193
125
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🤖 AI Agent Directions
|
|
129
|
+
|
|
130
|
+
### For AI Code Generation Tools
|
|
131
|
+
|
|
132
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
133
|
+
|
|
134
|
+
#### Prompt Template for AI Agents
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
You are implementing a text to voice feature using @umituz/react-native-ai-generation-content.
|
|
138
|
+
|
|
139
|
+
REQUIREMENTS:
|
|
140
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
141
|
+
2. Use the useTextToVoiceFeature hook
|
|
142
|
+
3. Select voice from available options
|
|
143
|
+
4. Implement text input for speech content
|
|
144
|
+
5. Adjust settings (speed, pitch)
|
|
145
|
+
6. Validate text and voice before generation
|
|
146
|
+
7. Implement audio playback for preview
|
|
147
|
+
8. Handle long processing times with progress
|
|
148
|
+
9. Implement proper error handling
|
|
149
|
+
10. Implement cleanup on unmount (CRITICAL: dispose audio)
|
|
150
|
+
|
|
151
|
+
CRITICAL RULES:
|
|
152
|
+
- MUST validate text and voice before calling generate()
|
|
153
|
+
- MUST implement audio playback controls (play, pause, stop)
|
|
154
|
+
- MUST handle voice selection
|
|
155
|
+
- MUST handle speed and pitch adjustments
|
|
156
|
+
- MUST implement debouncing (300ms)
|
|
157
|
+
- MUST allow regeneration with different settings
|
|
158
|
+
- MUST properly dispose audio on unmount (useEffect cleanup)
|
|
159
|
+
|
|
160
|
+
CONFIGURATION:
|
|
161
|
+
- Provide valid userId (string)
|
|
162
|
+
- Set voice: string (voice ID)
|
|
163
|
+
- Set speed?: number (speech rate 0.25 - 4.0, default: 1.0)
|
|
164
|
+
- Set pitch?: number (pitch adjustment -20.0 - 20.0, default: 0)
|
|
165
|
+
- Set language?: string (language code, default: 'en-US')
|
|
166
|
+
- Implement onSaveAudio callback
|
|
167
|
+
- Configure callbacks: onTextChange, onProcessingStart, onProcessingComplete, onError
|
|
168
|
+
|
|
169
|
+
VOICE OPTIONS:
|
|
170
|
+
- English: Multiple male/female voices (US, UK, etc.)
|
|
171
|
+
- Multi-language: Spanish, French, German, Italian, Japanese, Korean, Chinese
|
|
172
|
+
- Default voice: Set in config
|
|
173
|
+
|
|
174
|
+
SETTINGS:
|
|
175
|
+
- speed: Speech rate (0.25 - 4.0, default: 1.0)
|
|
176
|
+
- pitch: Pitch adjustment (-20.0 - 20.0, default: 0)
|
|
177
|
+
- language: Language code (e.g., 'en-US', 'es-ES')
|
|
178
|
+
|
|
179
|
+
AUDIO CONTROLS:
|
|
180
|
+
- Play: Start audio playback
|
|
181
|
+
- Pause: Pause current playback
|
|
182
|
+
- Stop: Stop and reset playback
|
|
183
|
+
- Unload: Dispose audio resource (CRITICAL for cleanup)
|
|
184
|
+
|
|
185
|
+
STRICTLY FORBIDDEN:
|
|
186
|
+
- No empty text validation
|
|
187
|
+
- No auto-generation without user action
|
|
188
|
+
- No hardcoded API keys
|
|
189
|
+
- No unhandled errors
|
|
190
|
+
- No memory leaks (especially audio)
|
|
191
|
+
- No blocking UI
|
|
192
|
+
- No copyright infringement
|
|
193
|
+
|
|
194
|
+
CLEANUP CHECKLIST:
|
|
195
|
+
- [ ] Audio unloaded on unmount
|
|
196
|
+
- [ ] Sound reference nullified
|
|
197
|
+
- [ ] Event listeners removed
|
|
198
|
+
- [ ] No memory leaks
|
|
199
|
+
|
|
200
|
+
QUALITY CHECKLIST:
|
|
201
|
+
- [ ] Text input for speech content
|
|
202
|
+
- [ ] Voice selector added
|
|
203
|
+
- [ ] Speed control implemented
|
|
204
|
+
- [ ] Pitch control implemented
|
|
205
|
+
- [ ] Validation before generate()
|
|
206
|
+
- [ ] Audio playback controls (play, pause, stop)
|
|
207
|
+
- [ ] Progress indicator during processing
|
|
208
|
+
- [ ] Error display with retry option
|
|
209
|
+
- [ ] Save/share functionality
|
|
210
|
+
- [ ] Regeneration with different settings
|
|
211
|
+
- [ ] Proper cleanup on unmount
|
|
221
212
|
```
|
|
222
213
|
|
|
223
|
-
|
|
214
|
+
#### AI Implementation Checklist
|
|
215
|
+
|
|
216
|
+
Use this checklist when generating code:
|
|
217
|
+
|
|
218
|
+
- [ ] Feature imported from correct path
|
|
219
|
+
- [ ] Text input for speech content implemented
|
|
220
|
+
- [ ] Voice selector added
|
|
221
|
+
- [ ] Speed control implemented
|
|
222
|
+
- [ ] Pitch control implemented
|
|
223
|
+
- [ ] Validation before generate()
|
|
224
|
+
- [ ] Audio playback controls (play, pause, stop)
|
|
225
|
+
- [ ] Progress indicator during processing
|
|
226
|
+
- [ ] Error display with user-friendly message
|
|
227
|
+
- [ ] Save/share buttons
|
|
228
|
+
- [ ] Regeneration option
|
|
229
|
+
- [ ] **CRITICAL**: Audio cleanup on unmount
|
|
230
|
+
- [ ] **CRITICAL**: Sound reference disposal
|
|
231
|
+
- [ ] **CRITICAL**: Event listener cleanup
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 🛠️ Configuration Strategy
|
|
236
|
+
|
|
237
|
+
### Essential Configuration
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
// Required fields
|
|
241
|
+
{
|
|
242
|
+
userId: string
|
|
243
|
+
voice: string
|
|
244
|
+
text: string
|
|
245
|
+
}
|
|
224
246
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
// Optional callbacks
|
|
248
|
+
{
|
|
249
|
+
speed?: number // 0.25 - 4.0, default: 1.0
|
|
250
|
+
pitch?: number // -20.0 - 20.0, default: 0
|
|
251
|
+
language?: string // e.g., 'en-US', 'es-ES'
|
|
252
|
+
onTextChange?: (text: string) => void
|
|
253
|
+
onProcessingStart?: () => void
|
|
254
|
+
onProcessingComplete?: (result) => void
|
|
255
|
+
onError?: (error: string) => void
|
|
256
|
+
}
|
|
233
257
|
```
|
|
234
258
|
|
|
235
|
-
|
|
259
|
+
### Recommended Settings
|
|
236
260
|
|
|
237
|
-
|
|
261
|
+
1. **Voices**
|
|
262
|
+
- English: Multiple options (male/female, US/UK)
|
|
263
|
+
- Multi-language: Support for major languages
|
|
264
|
+
- Default: Set in configuration
|
|
238
265
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
266
|
+
2. **Speed Settings**
|
|
267
|
+
- 0.25 - 0.75: Slow (audiobooks, learning)
|
|
268
|
+
- 0.8 - 1.2: Normal (most use cases)
|
|
269
|
+
- 1.3 - 2.0: Fast (quick consumption)
|
|
270
|
+
- 2.1 - 4.0: Very fast (skimming)
|
|
271
|
+
|
|
272
|
+
3. **Pitch Settings**
|
|
273
|
+
- -20 to -5: Lower pitch
|
|
274
|
+
- -5 to 5: Normal range (default: 0)
|
|
275
|
+
- 5 to 20: Higher pitch
|
|
276
|
+
|
|
277
|
+
4. **Text Length**
|
|
278
|
+
- Recommended: Under 5000 characters
|
|
279
|
+
- Long texts: Consider chunking
|
|
280
|
+
- Short texts: Better for performance
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 📊 State Management
|
|
285
|
+
|
|
286
|
+
### Feature States
|
|
287
|
+
|
|
288
|
+
**isReady**: boolean
|
|
289
|
+
- Text provided and voice selected
|
|
290
|
+
- Check before enabling generate button
|
|
247
291
|
|
|
248
|
-
|
|
292
|
+
**isProcessing**: boolean
|
|
293
|
+
- Speech generation in progress
|
|
294
|
+
- Show loading/progress indicator
|
|
295
|
+
- Disable generate button
|
|
249
296
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const chunks = longText.match(/.{1,5000}/g) || [];
|
|
297
|
+
**progress**: number (0-100)
|
|
298
|
+
- Generation progress percentage
|
|
299
|
+
- Update progress bar
|
|
254
300
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
301
|
+
**error**: string | null
|
|
302
|
+
- Error message if generation failed
|
|
303
|
+
- Display to user with clear message
|
|
304
|
+
|
|
305
|
+
**result**: {
|
|
306
|
+
audioUrl: string
|
|
307
|
+
voice?: string
|
|
308
|
+
text?: string
|
|
309
|
+
speed?: number
|
|
310
|
+
pitch?: number
|
|
311
|
+
language?: string
|
|
312
|
+
metadata?: any
|
|
258
313
|
}
|
|
259
|
-
```
|
|
260
314
|
|
|
261
|
-
|
|
315
|
+
---
|
|
262
316
|
|
|
263
|
-
|
|
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
|
-
`;
|
|
317
|
+
## 🎨 Best Practices
|
|
271
318
|
|
|
272
|
-
|
|
273
|
-
```
|
|
319
|
+
### Text Preparation
|
|
274
320
|
|
|
275
|
-
|
|
321
|
+
1. **Text Length**
|
|
322
|
+
- Keep under 5000 characters for best results
|
|
323
|
+
- Consider chunking for long texts
|
|
324
|
+
- Test with shorter texts first
|
|
276
325
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
5. **Testing**: Test different voices to find the best match
|
|
326
|
+
2. **Punctuation**
|
|
327
|
+
- Use proper punctuation for natural pauses
|
|
328
|
+
- Include commas, periods, question marks
|
|
329
|
+
- Use punctuation to control pacing
|
|
282
330
|
|
|
283
|
-
|
|
331
|
+
3. **Formatting**
|
|
332
|
+
- Clear, readable text
|
|
333
|
+
- Remove unnecessary whitespace
|
|
334
|
+
- Use abbreviations consistently
|
|
284
335
|
|
|
285
|
-
###
|
|
336
|
+
### Voice Selection
|
|
286
337
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
});
|
|
293
|
-
```
|
|
338
|
+
1. **Match Content Type**
|
|
339
|
+
- Audiobooks: Clear, pleasant voice
|
|
340
|
+
- Presentations: Professional voice
|
|
341
|
+
- Entertainment: Dynamic voice
|
|
342
|
+
- Accessibility: Clear, neutral voice
|
|
294
343
|
|
|
295
|
-
|
|
344
|
+
2. **Language Matching**
|
|
345
|
+
- Match voice to text language
|
|
346
|
+
- Consider accent preferences
|
|
347
|
+
- Test different voices
|
|
296
348
|
|
|
297
|
-
|
|
298
|
-
const result = await feature.generate({
|
|
299
|
-
voice: 'en-US-Neural2-A',
|
|
300
|
-
speed: 1.1,
|
|
301
|
-
pitch: 1.0,
|
|
302
|
-
});
|
|
303
|
-
```
|
|
349
|
+
### Settings Optimization
|
|
304
350
|
|
|
305
|
-
|
|
351
|
+
1. **Speed**
|
|
352
|
+
- 0.8-1.2: Most natural speech
|
|
353
|
+
- Adjust based on content type
|
|
354
|
+
- Test with playback before saving
|
|
306
355
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
pitch: 0,
|
|
312
|
-
});
|
|
313
|
-
```
|
|
356
|
+
2. **Pitch**
|
|
357
|
+
- Keep near 0 for natural sound
|
|
358
|
+
- Small adjustments (-5 to +5)
|
|
359
|
+
- Avoid extreme values
|
|
314
360
|
|
|
315
|
-
|
|
361
|
+
---
|
|
316
362
|
|
|
317
|
-
|
|
318
|
-
const { state, generate } = useTextToVoiceFeature({ ...config });
|
|
363
|
+
## 🐛 Common Pitfalls
|
|
319
364
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
365
|
+
### Audio Playback Issues
|
|
366
|
+
|
|
367
|
+
❌ **Problem**: Audio won't play
|
|
368
|
+
✅ **Solution**: Check audio URL, format compatibility
|
|
369
|
+
|
|
370
|
+
### Memory Leaks
|
|
371
|
+
|
|
372
|
+
❌ **Problem**: App crashes after multiple generations
|
|
373
|
+
✅ **Solution**: Implement proper audio cleanup in useEffect
|
|
374
|
+
|
|
375
|
+
### Quality Issues
|
|
376
|
+
|
|
377
|
+
❌ **Problem**: Speech sounds unnatural
|
|
378
|
+
✅ **Solution**: Adjust speed and pitch, try different voice
|
|
379
|
+
|
|
380
|
+
### Long Text Issues
|
|
381
|
+
|
|
382
|
+
❌ **Problem**: Generation fails for long texts
|
|
383
|
+
✅ **Solution**: Chunk text into smaller segments
|
|
384
|
+
|
|
385
|
+
### Cleanup Issues
|
|
386
|
+
|
|
387
|
+
❌ **Problem**: Audio continues playing after unmount
|
|
388
|
+
✅ **Solution**: Implement proper cleanup with unloadAsync
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 📦 Related Components
|
|
393
|
+
|
|
394
|
+
Use these components from the library:
|
|
395
|
+
|
|
396
|
+
- **TextInput**: For speech content
|
|
397
|
+
- **VoiceSelector**: Choose voice
|
|
398
|
+
- **SpeedControl**: Adjust speech rate
|
|
399
|
+
- **PitchControl**: Adjust pitch
|
|
400
|
+
- **AudioPlayer**: Play generated audio
|
|
401
|
+
- **ProgressBar**: Progress display
|
|
402
|
+
|
|
403
|
+
Located at: `src/presentation/components/`
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## 🔄 Migration Strategy
|
|
408
|
+
|
|
409
|
+
If migrating from previous implementation:
|
|
410
|
+
|
|
411
|
+
1. **Update imports** to new path
|
|
412
|
+
2. **Add voice selector**
|
|
413
|
+
3. **Implement speed/pitch controls**
|
|
414
|
+
4. **Add audio playback controls**
|
|
415
|
+
5. **Update state handling** for new structure
|
|
416
|
+
6. **Implement proper audio cleanup** (CRITICAL)
|
|
417
|
+
7. **Test all voices**
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## 📚 Additional Resources
|
|
422
|
+
|
|
423
|
+
- Main documentation: `/docs/`
|
|
424
|
+
- API reference: `/docs/api/`
|
|
425
|
+
- Examples: `/docs/examples/basic/text-to-voice/`
|
|
426
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
**Last Updated**: 2025-01-08
|
|
431
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
326
432
|
|
|
327
|
-
|
|
433
|
+
---
|
|
328
434
|
|
|
329
|
-
|
|
330
|
-
- [Audio Generation](../audio-generation) - Generate audio content
|
|
331
|
-
- [Script Generator](../script-generator) - Generate scripts for voiceovers
|
|
435
|
+
## 📝 Changelog
|
|
332
436
|
|
|
333
|
-
|
|
437
|
+
### v2.0.0 - 2025-01-08
|
|
438
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
439
|
+
- Removed extensive code examples
|
|
440
|
+
- Added rules, prohibitions, and AI agent directions
|
|
441
|
+
- Focus on best practices and implementation guidance
|
|
442
|
+
- Added critical audio cleanup guidance
|
|
334
443
|
|
|
335
|
-
|
|
444
|
+
### v1.0.0 - Initial Release
|
|
445
|
+
- Initial feature documentation
|