@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,370 +1,413 @@
|
|
|
1
|
-
# Audio Generation
|
|
1
|
+
# Audio Generation Feature
|
|
2
2
|
|
|
3
3
|
Generate audio content using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Voice narration
|
|
11
|
-
- Customizable parameters
|
|
7
|
+
```typescript
|
|
8
|
+
import { useAudioGenerationFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Location**: `src/features/audio-generation/`
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
npm install @umituz/react-native-ai-generation-content
|
|
19
|
-
```
|
|
15
|
+
Generate various audio content types including music, sound effects, ambient backgrounds, and voice content using AI. Customize genre, mood, tempo, and duration for professional-quality audio creation.
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Using the Hook
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { useAudioGeneration } from '@umituz/react-native-ai-generation-content';
|
|
27
|
-
|
|
28
|
-
function AudioGenerationScreen() {
|
|
29
|
-
const [prompt, setPrompt] = useState('');
|
|
30
|
-
|
|
31
|
-
const feature = useAudioGeneration({
|
|
32
|
-
config: {
|
|
33
|
-
audioType: 'music',
|
|
34
|
-
duration: 30, // seconds
|
|
35
|
-
onProcessingStart: () => console.log('Generating audio...'),
|
|
36
|
-
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
37
|
-
onError: (error) => console.error('Error:', error),
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const playAudio = async () => {
|
|
42
|
-
if (feature.state.audioUrl) {
|
|
43
|
-
const { sound } = await Audio.Sound.createAsync(
|
|
44
|
-
{ uri: feature.state.audioUrl },
|
|
45
|
-
{ shouldPlay: true }
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<View>
|
|
52
|
-
<TextInput
|
|
53
|
-
placeholder="Describe the audio you want to generate..."
|
|
54
|
-
value={prompt}
|
|
55
|
-
onChangeText={setPrompt}
|
|
56
|
-
multiline
|
|
57
|
-
numberOfLines={4}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
<AudioTypeSelector
|
|
61
|
-
selectedType={feature.state.audioType}
|
|
62
|
-
onSelectType={feature.setAudioType}
|
|
63
|
-
/>
|
|
64
|
-
|
|
65
|
-
<DurationSlider
|
|
66
|
-
value={feature.state.duration}
|
|
67
|
-
onChange={feature.setDuration}
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
<Button
|
|
71
|
-
title="Generate Audio"
|
|
72
|
-
onPress={() => feature.generate(prompt)}
|
|
73
|
-
disabled={!prompt || feature.state.isProcessing}
|
|
74
|
-
/>
|
|
75
|
-
|
|
76
|
-
{feature.state.isProcessing && (
|
|
77
|
-
<ActivityIndicator />
|
|
78
|
-
)}
|
|
79
|
-
|
|
80
|
-
{feature.state.audioUrl && (
|
|
81
|
-
<View>
|
|
82
|
-
<Button title="Play Audio" onPress={playAudio} />
|
|
83
|
-
<Button title="Save Audio" onPress={() => feature.saveAudio()} />
|
|
84
|
-
</View>
|
|
85
|
-
)}
|
|
86
|
-
</View>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
```
|
|
17
|
+
---
|
|
90
18
|
|
|
91
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
92
20
|
|
|
93
|
-
|
|
94
|
-
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
21
|
+
### When to Use This Feature
|
|
95
22
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
```
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Creating background music for videos
|
|
25
|
+
- Generating sound effects for games/apps
|
|
26
|
+
- Producing ambient background audio
|
|
27
|
+
- Creating voice content
|
|
28
|
+
- Podcast intro/outro music
|
|
105
29
|
|
|
106
|
-
|
|
30
|
+
❌ **When NOT to Use:**
|
|
31
|
+
- Converting text to speech (use Text to Voice)
|
|
32
|
+
- Generating voiceovers (use Text to Voice)
|
|
33
|
+
- Audio editing or mixing (use audio editing software)
|
|
34
|
+
- Music composition assistance
|
|
107
35
|
|
|
108
|
-
###
|
|
36
|
+
### Implementation Strategy
|
|
109
37
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
38
|
+
1. **Enter prompt** describing desired audio
|
|
39
|
+
2. **Choose audio type** (music, sfx, ambient, voice)
|
|
40
|
+
3. **Set duration** for audio length
|
|
41
|
+
4. **Configure options** (genre, mood, tempo for music)
|
|
42
|
+
5. **Generate audio** with progress tracking
|
|
43
|
+
6. **Preview result** and offer regeneration
|
|
44
|
+
7. **Save or share** final audio
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
49
|
+
|
|
50
|
+
### 1. Input Requirements
|
|
51
|
+
- **MUST** provide descriptive text prompt
|
|
52
|
+
- **MUST** specify audio type
|
|
53
|
+
- **MUST** set valid duration (5-120 seconds recommended)
|
|
54
|
+
- **MUST NOT** exceed maximum duration limits
|
|
55
|
+
- **MUST NOT** use copyrighted material in prompts
|
|
56
|
+
|
|
57
|
+
### 2. Configuration
|
|
58
|
+
- **MUST** provide valid `userId` for tracking
|
|
59
|
+
- **MUST** specify `audioType` (music, sfx, ambient, voice)
|
|
60
|
+
- **MUST** implement `onError` callback
|
|
61
|
+
- **MUST** implement audio playback functionality
|
|
62
|
+
- **MUST** handle file saving locally
|
|
63
|
+
|
|
64
|
+
### 3. State Management
|
|
65
|
+
- **MUST** check `isReady` before enabling generate button
|
|
66
|
+
- **MUST** validate prompt and duration before generation
|
|
67
|
+
- **MUST** handle `isProcessing` state to prevent duplicate requests
|
|
68
|
+
- **MUST** display `error` state with clear messages
|
|
69
|
+
- **MUST** implement proper cleanup on unmount
|
|
70
|
+
|
|
71
|
+
### 4. Performance
|
|
72
|
+
- **MUST** implement progress indicators during generation
|
|
73
|
+
- **MUST** cache generated audio locally
|
|
74
|
+
- **MUST** allow users to cancel long generations
|
|
75
|
+
- **MUST** implement proper audio file disposal
|
|
76
|
+
- **MUST NOT** generate multiple audio files simultaneously
|
|
77
|
+
|
|
78
|
+
### 5. Audio Quality
|
|
79
|
+
- **MUST** provide audio preview before saving
|
|
80
|
+
- **MUST** support common audio formats (MP3, WAV)
|
|
81
|
+
- **MUST** handle large audio file sizes
|
|
82
|
+
- **MUST** implement proper audio playback controls
|
|
83
|
+
- **MUST** offer regeneration with different settings
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
88
|
+
|
|
89
|
+
### Strictly Forbidden
|
|
90
|
+
|
|
91
|
+
❌ **NEVER** do the following:
|
|
92
|
+
|
|
93
|
+
1. **No Empty Prompts**
|
|
94
|
+
- Always validate prompt is provided
|
|
95
|
+
- Never call generate() without description
|
|
96
|
+
- Guide users with example prompts
|
|
97
|
+
|
|
98
|
+
2. **No Auto-Generation**
|
|
99
|
+
- Never start generation without user action
|
|
100
|
+
- Always require explicit "Generate" button press
|
|
101
|
+
- Show preview before processing
|
|
102
|
+
|
|
103
|
+
3. **No Hardcoded Credentials**
|
|
104
|
+
- Never store API keys in component files
|
|
105
|
+
- Use environment variables or secure storage
|
|
106
|
+
|
|
107
|
+
4. **No Unhandled Errors**
|
|
108
|
+
- Never ignore generation failures
|
|
109
|
+
- Always explain what went wrong
|
|
110
|
+
- Provide retry or alternative options
|
|
111
|
+
|
|
112
|
+
5. **No Memory Leaks**
|
|
113
|
+
- Never store multiple audio files in memory
|
|
114
|
+
- Always cleanup audio references on unmount
|
|
115
|
+
- Implement proper audio disposal
|
|
116
|
+
|
|
117
|
+
6. **No Blocked UI**
|
|
118
|
+
- Never block main thread with audio processing
|
|
119
|
+
- Always show progress indicator
|
|
120
|
+
- Allow cancellation
|
|
121
|
+
|
|
122
|
+
7. **No Copyright Infringement**
|
|
123
|
+
- Never generate copyrighted material
|
|
124
|
+
- Never use artist names or copyrighted songs in prompts
|
|
125
|
+
- Implement content moderation
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🤖 AI Agent Directions
|
|
130
|
+
|
|
131
|
+
### For AI Code Generation Tools
|
|
132
|
+
|
|
133
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
134
|
+
|
|
135
|
+
#### Prompt Template for AI Agents
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
You are implementing an audio generation feature using @umituz/react-native-ai-generation-content.
|
|
139
|
+
|
|
140
|
+
REQUIREMENTS:
|
|
141
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
142
|
+
2. Use the useAudioGenerationFeature hook
|
|
143
|
+
3. Select audio type (music, sfx, ambient, voice)
|
|
144
|
+
4. Implement text input for audio description
|
|
145
|
+
5. Set duration (5-120 seconds recommended)
|
|
146
|
+
6. Configure options (genre, mood, tempo for music)
|
|
147
|
+
7. Validate prompt and duration before generation
|
|
148
|
+
8. Implement audio playback for preview
|
|
149
|
+
9. Handle long processing times with progress
|
|
150
|
+
10. Implement proper error handling
|
|
151
|
+
11. Implement cleanup on unmount
|
|
152
|
+
|
|
153
|
+
CRITICAL RULES:
|
|
154
|
+
- MUST validate prompt and duration before calling generate()
|
|
155
|
+
- MUST implement audio playback controls (play, pause, stop)
|
|
156
|
+
- MUST handle audio type selection
|
|
157
|
+
- MUST handle music-specific options (genre, mood, tempo)
|
|
158
|
+
- MUST implement debouncing (300ms)
|
|
159
|
+
- MUST allow regeneration with different settings
|
|
160
|
+
|
|
161
|
+
CONFIGURATION:
|
|
162
|
+
- Provide valid userId (string)
|
|
163
|
+
- Set audioType: 'music' | 'sfx' | 'ambient' | 'voice'
|
|
164
|
+
- Set duration: number (5-120 seconds recommended)
|
|
165
|
+
- Set genre: string (for music type: rock, pop, jazz, etc.)
|
|
166
|
+
- Set mood: string (happy, sad, energetic, calm, etc.)
|
|
167
|
+
- Set tempo: number (BPM for music, default: 120)
|
|
168
|
+
- Implement onSaveAudio callback
|
|
169
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
170
|
+
|
|
171
|
+
AUDIO TYPES:
|
|
172
|
+
- music: Musical compositions with genre, mood, tempo options
|
|
173
|
+
- sfx: Sound effects and foley sounds
|
|
174
|
+
- ambient: Background ambient audio
|
|
175
|
+
- voice: Voice content and narration
|
|
176
|
+
|
|
177
|
+
OPTIONS:
|
|
178
|
+
- genre: Music genre (rock, pop, jazz, electronic, classical, etc.)
|
|
179
|
+
- mood: Audio mood (happy, sad, energetic, calm, dramatic, etc.)
|
|
180
|
+
- tempo: Beats per minute for music (default: 120)
|
|
181
|
+
|
|
182
|
+
STRICTLY FORBIDDEN:
|
|
183
|
+
- No empty prompt validation
|
|
184
|
+
- No auto-generation without user action
|
|
185
|
+
- No hardcoded API keys
|
|
186
|
+
- No unhandled errors
|
|
187
|
+
- No memory leaks
|
|
188
|
+
- No blocking UI
|
|
189
|
+
- No copyright infringement
|
|
190
|
+
|
|
191
|
+
QUALITY CHECKLIST:
|
|
192
|
+
- [ ] Text input for audio description
|
|
193
|
+
- [ ] Audio type selector added
|
|
194
|
+
- [ ] Duration input/slider included
|
|
195
|
+
- [ ] Music options (genre, mood, tempo) when type=music
|
|
196
|
+
- [ ] Validation before generate()
|
|
197
|
+
- [ ] Audio playback controls implemented
|
|
198
|
+
- [ ] Progress indicator during processing
|
|
199
|
+
- [ ] Error display with retry option
|
|
200
|
+
- [ ] Save/share functionality
|
|
201
|
+
- [ ] Regeneration with different settings
|
|
120
202
|
```
|
|
121
203
|
|
|
122
|
-
|
|
204
|
+
#### AI Implementation Checklist
|
|
123
205
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
206
|
+
Use this checklist when generating code:
|
|
207
|
+
|
|
208
|
+
- [ ] Feature imported from correct path
|
|
209
|
+
- [ ] Text input for audio description implemented
|
|
210
|
+
- [ ] Audio type selector added
|
|
211
|
+
- [ ] Duration input implemented
|
|
212
|
+
- [ ] Music-specific options (genre, mood, tempo)
|
|
213
|
+
- [ ] Validation before generate()
|
|
214
|
+
- [ ] Audio playback controls (play, pause, stop)
|
|
215
|
+
- [ ] Progress indicator during processing
|
|
216
|
+
- [ ] Error display with user-friendly message
|
|
217
|
+
- [ ] Save/share buttons
|
|
218
|
+
- [ ] Regeneration option
|
|
219
|
+
- [ ] Cleanup on unmount
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 🛠️ Configuration Strategy
|
|
224
|
+
|
|
225
|
+
### Essential Configuration
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// Required fields
|
|
229
|
+
{
|
|
230
|
+
userId: string
|
|
231
|
+
audioType: 'music' | 'sfx' | 'ambient' | 'voice'
|
|
232
|
+
prompt: string
|
|
233
|
+
duration: number
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Optional callbacks
|
|
237
|
+
{
|
|
238
|
+
onProcessingStart?: () => void
|
|
239
|
+
onProcessingComplete?: (result) => void
|
|
240
|
+
onError?: (error: string) => void
|
|
132
241
|
}
|
|
133
242
|
```
|
|
134
243
|
|
|
135
|
-
|
|
244
|
+
### Recommended Settings
|
|
136
245
|
|
|
137
|
-
|
|
246
|
+
1. **Audio Types**
|
|
247
|
+
- Music: Background music, themes, intros (genre, mood, tempo options)
|
|
248
|
+
- SFX: Sound effects for games, apps, videos
|
|
249
|
+
- Ambient: Background atmospheres and environments
|
|
250
|
+
- Voice: Voice content and narration
|
|
138
251
|
|
|
139
|
-
|
|
252
|
+
2. **Music Options**
|
|
253
|
+
- genre: rock, pop, jazz, electronic, classical, hiphop
|
|
254
|
+
- mood: happy, sad, energetic, calm, dramatic, romantic
|
|
255
|
+
- tempo: 60-180 BPM (default: 120)
|
|
140
256
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
tempo: 120,
|
|
147
|
-
duration: 30,
|
|
148
|
-
});
|
|
149
|
-
```
|
|
257
|
+
3. **Duration Guidelines**
|
|
258
|
+
- SFX: 3-10 seconds
|
|
259
|
+
- Ambient: 30-120 seconds
|
|
260
|
+
- Music: 15-60 seconds for loops
|
|
261
|
+
- Voice: 5-30 seconds
|
|
150
262
|
|
|
151
|
-
|
|
263
|
+
---
|
|
152
264
|
|
|
153
|
-
|
|
265
|
+
## 📊 State Management
|
|
154
266
|
|
|
155
|
-
|
|
156
|
-
const result = await feature.generate('Explosion sound', {
|
|
157
|
-
audioType: 'sfx',
|
|
158
|
-
duration: 5,
|
|
159
|
-
});
|
|
160
|
-
```
|
|
267
|
+
### Feature States
|
|
161
268
|
|
|
162
|
-
|
|
269
|
+
**isReady**: boolean
|
|
270
|
+
- Prompt provided and duration set
|
|
271
|
+
- Check before enabling generate button
|
|
163
272
|
|
|
164
|
-
|
|
273
|
+
**isProcessing**: boolean
|
|
274
|
+
- Audio generation in progress
|
|
275
|
+
- Show loading/progress indicator
|
|
276
|
+
- Disable generate button
|
|
165
277
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
duration: 60,
|
|
170
|
-
});
|
|
171
|
-
```
|
|
278
|
+
**progress**: number (0-100)
|
|
279
|
+
- Generation progress percentage
|
|
280
|
+
- Update progress bar
|
|
172
281
|
|
|
173
|
-
|
|
282
|
+
**error**: string | null
|
|
283
|
+
- Error message if generation failed
|
|
284
|
+
- Display to user with clear message
|
|
174
285
|
|
|
175
|
-
|
|
286
|
+
**result**: {
|
|
287
|
+
audioUrl: string
|
|
288
|
+
audioType?: string
|
|
289
|
+
prompt?: string
|
|
290
|
+
duration?: number
|
|
291
|
+
metadata?: any
|
|
292
|
+
}
|
|
176
293
|
|
|
177
|
-
|
|
178
|
-
const result = await feature.generate('Narrator voice introducing topic', {
|
|
179
|
-
audioType: 'voice',
|
|
180
|
-
duration: 10,
|
|
181
|
-
});
|
|
182
|
-
```
|
|
294
|
+
---
|
|
183
295
|
|
|
184
|
-
##
|
|
296
|
+
## 🎨 Best Practices
|
|
185
297
|
|
|
186
|
-
|
|
187
|
-
2. Choose **Audio Type** - Select music, SFX, ambient, or voice
|
|
188
|
-
3. Set **Duration** - Choose length
|
|
189
|
-
4. Configure **Options** - Set genre, mood, tempo (for music)
|
|
190
|
-
5. Tap **Generate** - Create the audio
|
|
191
|
-
6. Play & Save - Listen to the result and save
|
|
298
|
+
### Prompt Writing
|
|
192
299
|
|
|
193
|
-
|
|
300
|
+
1. **Be Descriptive**
|
|
301
|
+
- Good: "Upbeat pop music with energetic drums and synth melody"
|
|
302
|
+
- Bad: "Music"
|
|
194
303
|
|
|
195
|
-
|
|
304
|
+
2. **Specify Elements**
|
|
305
|
+
- Mention instruments, tempo, mood
|
|
306
|
+
- Describe the sound characteristics
|
|
307
|
+
- Include genre information
|
|
196
308
|
|
|
197
|
-
|
|
198
|
-
|
|
309
|
+
3. **Match Use Case**
|
|
310
|
+
- Videos: Match video mood and pacing
|
|
311
|
+
- Games: Loop-friendly, appropriate mood
|
|
312
|
+
- Podcasts: Professional, not distracting
|
|
199
313
|
|
|
200
|
-
|
|
201
|
-
{ id: 'music', name: 'Music', description: 'Musical compositions' },
|
|
202
|
-
{ id: 'sfx', name: 'Sound Effects', description: 'SFX and foley' },
|
|
203
|
-
{ id: 'ambient', name: 'Ambient', description: 'Background audio' },
|
|
204
|
-
{ id: 'voice', name: 'Voice', description: 'Voice content' },
|
|
205
|
-
];
|
|
314
|
+
### Audio Type Selection
|
|
206
315
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/>
|
|
212
|
-
```
|
|
316
|
+
1. **Music**
|
|
317
|
+
- Use for: Background music, themes, intros
|
|
318
|
+
- Options: genre, mood, tempo
|
|
319
|
+
- Best: High-quality, loopable clips
|
|
213
320
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const genres = [
|
|
220
|
-
{ id: 'rock', name: 'Rock' },
|
|
221
|
-
{ id: 'pop', name: 'Pop' },
|
|
222
|
-
{ id: 'jazz', name: 'Jazz' },
|
|
223
|
-
{ id: 'electronic', name: 'Electronic' },
|
|
224
|
-
{ id: 'classical', name: 'Classical' },
|
|
225
|
-
{ id: 'hiphop', name: 'Hip Hop' },
|
|
226
|
-
];
|
|
227
|
-
|
|
228
|
-
<GridSelector
|
|
229
|
-
options={genres}
|
|
230
|
-
selectedOption={selectedGenre}
|
|
231
|
-
onSelectOption={setSelectedGenre}
|
|
232
|
-
/>
|
|
233
|
-
```
|
|
321
|
+
2. **SFX**
|
|
322
|
+
- Use for: Sound effects, foley, impacts
|
|
323
|
+
- Options: Duration mainly
|
|
324
|
+
- Best: Short, focused sounds
|
|
234
325
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const moods = [
|
|
241
|
-
{ id: 'happy', name: 'Happy' },
|
|
242
|
-
{ id: 'sad', name: 'Sad' },
|
|
243
|
-
{ id: 'energetic', name: 'Energetic' },
|
|
244
|
-
{ id: 'calm', name: 'Calm' },
|
|
245
|
-
{ id: 'dramatic', name: 'Dramatic' },
|
|
246
|
-
{ id: 'romantic', name: 'Romantic' },
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
<GridSelector
|
|
250
|
-
options={moods}
|
|
251
|
-
selectedOption={selectedMood}
|
|
252
|
-
onSelectOption={setSelectedMood}
|
|
253
|
-
/>
|
|
254
|
-
```
|
|
326
|
+
3. **Ambient**
|
|
327
|
+
- Use for: Background atmospheres
|
|
328
|
+
- Options: Duration, mood
|
|
329
|
+
- Best: Consistent, non-distracting
|
|
255
330
|
|
|
256
|
-
|
|
331
|
+
4. **Voice**
|
|
332
|
+
- Use for: Narration, voice content
|
|
333
|
+
- Consider: Use Text to Voice for better results
|
|
257
334
|
|
|
258
|
-
|
|
259
|
-
import { Slider } from 'react-native';
|
|
335
|
+
---
|
|
260
336
|
|
|
261
|
-
|
|
262
|
-
minimumValue={5}
|
|
263
|
-
maximumValue={120}
|
|
264
|
-
step={5}
|
|
265
|
-
value={duration}
|
|
266
|
-
onValueChange={setDuration}
|
|
267
|
-
/>
|
|
337
|
+
## 🐛 Common Pitfalls
|
|
268
338
|
|
|
269
|
-
|
|
270
|
-
```
|
|
339
|
+
### Quality Issues
|
|
271
340
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
```tsx
|
|
275
|
-
import { Audio } from 'expo-av';
|
|
276
|
-
import { useState, useEffect } from 'react';
|
|
277
|
-
|
|
278
|
-
const [sound, setSound] = useState<Sound | null>(null);
|
|
279
|
-
const [isPlaying, setIsPlaying] = useState(false);
|
|
280
|
-
|
|
281
|
-
const playAudio = async () => {
|
|
282
|
-
const { sound } = await Audio.Sound.createAsync(
|
|
283
|
-
{ uri: audioUrl },
|
|
284
|
-
{ shouldPlay: true }
|
|
285
|
-
);
|
|
286
|
-
setSound(sound);
|
|
287
|
-
setIsPlaying(true);
|
|
288
|
-
|
|
289
|
-
sound.setOnPlaybackStatusUpdate((status) => {
|
|
290
|
-
if (status.isLoaded && status.didJustFinish) {
|
|
291
|
-
setIsPlaying(false);
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
const stopAudio = async () => {
|
|
297
|
-
if (sound) {
|
|
298
|
-
await sound.stopAsync();
|
|
299
|
-
setIsPlaying(false);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
useEffect(() => {
|
|
304
|
-
return sound ? () => sound.unloadAsync() : undefined;
|
|
305
|
-
}, [sound]);
|
|
306
|
-
```
|
|
341
|
+
❌ **Problem**: Audio doesn't match expectations
|
|
342
|
+
✅ **Solution**: Be more descriptive in prompt, try different settings
|
|
307
343
|
|
|
308
|
-
|
|
344
|
+
### Duration Issues
|
|
309
345
|
|
|
310
|
-
|
|
346
|
+
❌ **Problem**: Audio too short/long
|
|
347
|
+
✅ **Solution**: Set appropriate duration, consider use case
|
|
311
348
|
|
|
312
|
-
|
|
313
|
-
// Generate background music for videos
|
|
314
|
-
const result = await feature.generate('Upbeat background music', {
|
|
315
|
-
audioType: 'music',
|
|
316
|
-
genre: 'pop',
|
|
317
|
-
mood: 'energetic',
|
|
318
|
-
duration: 60,
|
|
319
|
-
});
|
|
320
|
-
```
|
|
349
|
+
### Format Issues
|
|
321
350
|
|
|
322
|
-
|
|
351
|
+
❌ **Problem**: Audio won't play
|
|
352
|
+
✅ **Solution**: Ensure audio format is supported (MP3, WAV)
|
|
323
353
|
|
|
324
|
-
|
|
325
|
-
// Create sound effects for games or videos
|
|
326
|
-
const result = await feature.generate('Magic spell sound', {
|
|
327
|
-
audioType: 'sfx',
|
|
328
|
-
duration: 3,
|
|
329
|
-
});
|
|
330
|
-
```
|
|
354
|
+
### Performance Issues
|
|
331
355
|
|
|
332
|
-
|
|
356
|
+
❌ **Problem**: Slow generation
|
|
357
|
+
✅ **Solution**: Use shorter durations, show progress
|
|
333
358
|
|
|
334
|
-
|
|
335
|
-
// Generate ambient backgrounds
|
|
336
|
-
const result = await feature.generate('Ocean waves with seagulls', {
|
|
337
|
-
audioType: 'ambient',
|
|
338
|
-
duration: 120,
|
|
339
|
-
});
|
|
340
|
-
```
|
|
359
|
+
---
|
|
341
360
|
|
|
342
|
-
|
|
361
|
+
## 📦 Related Components
|
|
343
362
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
363
|
+
Use these components from the library:
|
|
364
|
+
|
|
365
|
+
- **TextInput**: For audio description
|
|
366
|
+
- **AudioTypeSelector**: Choose audio type
|
|
367
|
+
- **GenreSelector**: Music genre selection
|
|
368
|
+
- **MoodSelector**: Audio mood selection
|
|
369
|
+
- **DurationSlider**: Set audio duration
|
|
370
|
+
- **AudioPlayer**: Play generated audio
|
|
371
|
+
- **ProgressBar**: Progress display
|
|
372
|
+
|
|
373
|
+
Located at: `src/presentation/components/`
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 🔄 Migration Strategy
|
|
378
|
+
|
|
379
|
+
If migrating from previous implementation:
|
|
380
|
+
|
|
381
|
+
1. **Update imports** to new path
|
|
382
|
+
2. **Add audio type selector**
|
|
383
|
+
3. **Implement music-specific options** (genre, mood, tempo)
|
|
384
|
+
4. **Update state handling** for new structure
|
|
385
|
+
5. **Add audio playback controls**
|
|
386
|
+
6. **Test all audio types**
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 📚 Additional Resources
|
|
391
|
+
|
|
392
|
+
- Main documentation: `/docs/`
|
|
393
|
+
- API reference: `/docs/api/`
|
|
394
|
+
- Examples: `/docs/examples/basic/audio-generation/`
|
|
395
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
353
396
|
|
|
354
|
-
|
|
397
|
+
---
|
|
355
398
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
3. **Genre Matching**: Match genre to your use case
|
|
359
|
-
4. **Mood Selection**: Choose appropriate mood for your content
|
|
360
|
-
5. **Multiple Takes**: Generate multiple versions to choose from
|
|
399
|
+
**Last Updated**: 2025-01-08
|
|
400
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
361
401
|
|
|
362
|
-
|
|
402
|
+
---
|
|
363
403
|
|
|
364
|
-
|
|
365
|
-
- [Script Generator](../script-generator) - Generate audio scripts
|
|
366
|
-
- [Text to Video](../text-to-video) - Generate videos with audio
|
|
404
|
+
## 📝 Changelog
|
|
367
405
|
|
|
368
|
-
|
|
406
|
+
### v2.0.0 - 2025-01-08
|
|
407
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
408
|
+
- Removed extensive code examples
|
|
409
|
+
- Added rules, prohibitions, and AI agent directions
|
|
410
|
+
- Focus on best practices and implementation guidance
|
|
369
411
|
|
|
370
|
-
|
|
412
|
+
### v1.0.0 - Initial Release
|
|
413
|
+
- Initial feature documentation
|