github-actions[bot]
commited on
Commit
Β·
070dced
1
Parent(s):
63de584
Add HF Spaces config
Browse files
README.md
CHANGED
|
@@ -1,295 +1,9 @@
|
|
| 1 |
-
# π¬ Somira Content Automation
|
| 2 |
-
|
| 3 |
-
**AI-powered video generation pipeline that transforms text scripts into professional product advertisements.**
|
| 4 |
-
|
| 5 |
---
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
cd somira-automation
|
| 14 |
-
|
| 15 |
-
# Create virtual environment (recommended)
|
| 16 |
-
python -m venv venv
|
| 17 |
-
source venv/bin/activate # Windows: venv\Scripts\activate
|
| 18 |
-
|
| 19 |
-
# Install dependencies
|
| 20 |
-
pip install -r requirements.txt
|
| 21 |
-
```
|
| 22 |
-
|
| 23 |
-
### 2. API Setup
|
| 24 |
-
|
| 25 |
-
**You need these API keys:**
|
| 26 |
-
|
| 27 |
-
#### Gemini API (Free)
|
| 28 |
-
1. Go to https://aistudio.google.com/app/apikey
|
| 29 |
-
2. Click "Create API Key"
|
| 30 |
-
3. Copy the key
|
| 31 |
-
|
| 32 |
-
#### RunwayML API ($10 minimum)
|
| 33 |
-
1. Go to https://dev.runwayml.com/
|
| 34 |
-
2. Sign up and create organization
|
| 35 |
-
3. Go to "API Keys" β "Create new key"
|
| 36 |
-
4. Add $10+ credits in "Billing" tab
|
| 37 |
-
|
| 38 |
-
#### Google Cloud (Free tier available)
|
| 39 |
-
1. Go to https://console.cloud.google.com/
|
| 40 |
-
2. Create project β Enable "Text-to-Speech API"
|
| 41 |
-
3. Create service account β Download JSON key
|
| 42 |
-
4. Create storage bucket
|
| 43 |
-
|
| 44 |
-
### 3. Configuration
|
| 45 |
-
```bash
|
| 46 |
-
# Copy and edit environment file
|
| 47 |
-
cp .env.example .env
|
| 48 |
-
```
|
| 49 |
-
|
| 50 |
-
Edit `.env` with your keys:
|
| 51 |
-
```bash
|
| 52 |
-
# Required API Keys
|
| 53 |
-
GEMINI_API_KEY=AIzaSyC_your_key_here
|
| 54 |
-
RUNWAYML_API_KEY=key_your_runwayml_key_here
|
| 55 |
-
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
|
| 56 |
-
GCS_BUCKET_NAME=your-bucket-name
|
| 57 |
-
|
| 58 |
-
```
|
| 59 |
-
|
| 60 |
-
### 4. Verify Setup
|
| 61 |
-
```bash
|
| 62 |
-
python main.py --health-check
|
| 63 |
-
```
|
| 64 |
-
You should see: `β
All systems operational!`
|
| 65 |
-
|
| 66 |
-
### 5. Generate Your First Video
|
| 67 |
-
```bash
|
| 68 |
-
python main.py
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
---
|
| 72 |
-
|
| 73 |
-
## π― What It Does
|
| 74 |
-
|
| 75 |
-
This system automatically creates 15-second vertical videos (perfect for TikTok/Reels) by:
|
| 76 |
-
|
| 77 |
-
1. **AI Video Generation** - Creates unique hook videos using RunwayML Gen-4
|
| 78 |
-
2. **Smart Content Selection** - Gemini AI analyzes your script to pick relevant product footage
|
| 79 |
-
3. **Professional Voice-overs** - Converts text to natural speech using Google TTS
|
| 80 |
-
4. **Auto Editing** - Merges videos, adds background music, subtitles, and effects
|
| 81 |
-
5. **Cloud Storage** - Uploads final videos to Google Cloud Storage
|
| 82 |
-
|
| 83 |
-
**Pipeline Time**: ~1-2 minutes per video
|
| 84 |
-
|
| 85 |
-
---
|
| 86 |
-
|
| 87 |
-
## π» Usage
|
| 88 |
-
|
| 89 |
-
### Basic Commands
|
| 90 |
-
```bash
|
| 91 |
-
# Generate video with default content
|
| 92 |
-
python main.py
|
| 93 |
-
|
| 94 |
-
# Test system (uses minimal credits)
|
| 95 |
-
python main.py --test
|
| 96 |
-
|
| 97 |
-
# Health check
|
| 98 |
-
python main.py --health-check
|
| 99 |
-
|
| 100 |
-
# Custom content
|
| 101 |
-
python main.py --strategy strategy.json --script script.txt
|
| 102 |
-
```
|
| 103 |
-
|
| 104 |
-
### Custom Content
|
| 105 |
-
Create `my_script.txt`:
|
| 106 |
-
```
|
| 107 |
-
I heard a pop and my neck was stuck. After one minute with Somira massager, the pain was gone. This product actually works!
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
Create `my_strategy.json`:
|
| 111 |
-
```json
|
| 112 |
-
{
|
| 113 |
-
"brand": "Somira",
|
| 114 |
-
"gemini_prompt": "A dramatic scene showing neck pain relief",
|
| 115 |
-
"runway_prompt": "Person experiencing neck pain then relief",
|
| 116 |
-
"style": "commercial",
|
| 117 |
-
"aspect_ratio": "9:16",
|
| 118 |
-
"duration": 5
|
| 119 |
-
}
|
| 120 |
-
```
|
| 121 |
-
|
| 122 |
-
Run:
|
| 123 |
-
```bash
|
| 124 |
-
python main.py --strategy my_strategy.json --script my_script.txt
|
| 125 |
-
```
|
| 126 |
-
|
| 127 |
-
### Batch Processing
|
| 128 |
-
```python
|
| 129 |
-
import asyncio
|
| 130 |
-
from automation import ContentAutomation
|
| 131 |
-
|
| 132 |
-
async def create_videos():
|
| 133 |
-
automation = ContentAutomation(config)
|
| 134 |
-
|
| 135 |
-
scripts = ["script1.txt", "script2.txt", "script3.txt"]
|
| 136 |
-
for script_file in scripts:
|
| 137 |
-
with open(script_file) as f:
|
| 138 |
-
result = await automation.execute_pipeline(strategy, f.read())
|
| 139 |
-
print(f"Created: {result['final_url']}")
|
| 140 |
-
|
| 141 |
-
asyncio.run(create_videos())
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
---
|
| 145 |
-
|
| 146 |
-
## π° Pricing
|
| 147 |
-
|
| 148 |
-
### Cost Per Video
|
| 149 |
-
| Service | Cost |
|
| 150 |
-
|---------|------|
|
| 151 |
-
| RunwayML (5s video) | ~$0.50 |
|
| 152 |
-
| Gemini API | ~$0.001 |
|
| 153 |
-
| Google TTS | ~$0.001 |
|
| 154 |
-
| Cloud Storage | ~$0.001 |
|
| 155 |
-
| **Total** | **~$0.50** |
|
| 156 |
-
|
| 157 |
-
### Monthly Estimate (100 videos)
|
| 158 |
-
- **RunwayML**: $50
|
| 159 |
-
- **Other services**: $2-5
|
| 160 |
-
- **Total**: ~$55/month
|
| 161 |
-
|
| 162 |
-
---
|
| 163 |
-
|
| 164 |
-
## ποΈ How It Works
|
| 165 |
-
|
| 166 |
-
### Pipeline Steps
|
| 167 |
-
1. **Asset Generation** (30-60s)
|
| 168 |
-
- AI creates hook video from prompt
|
| 169 |
-
- Selects 3 relevant product videos
|
| 170 |
-
- Generates voice-over from script
|
| 171 |
-
- Picks background music
|
| 172 |
-
|
| 173 |
-
2. **Video Composition** (10-20s)
|
| 174 |
-
- Merges all video clips
|
| 175 |
-
- Adds audio tracks and music
|
| 176 |
-
- Applies transitions
|
| 177 |
-
|
| 178 |
-
3. **Subtitles** (5-10s)
|
| 179 |
-
- Generates animated subtitles
|
| 180 |
-
- Times them to voice-over
|
| 181 |
-
|
| 182 |
-
4. **Cloud Upload** (5-15s)
|
| 183 |
-
- Uploads to Google Cloud Storage
|
| 184 |
-
- Returns public URL
|
| 185 |
-
|
| 186 |
-
### Output Specifications
|
| 187 |
-
- **Format**: MP4, H.264
|
| 188 |
-
- **Aspect Ratio**: 9:16 (vertical)
|
| 189 |
-
- **Duration**: 15 seconds max
|
| 190 |
-
- **Resolution**: 1080x1920
|
| 191 |
-
- **Audio**: 44.1kHz, stereo
|
| 192 |
-
|
| 193 |
-
---
|
| 194 |
-
|
| 195 |
-
## π§ Technical Details
|
| 196 |
-
|
| 197 |
-
### Project Structure
|
| 198 |
-
```
|
| 199 |
-
somira-automation/
|
| 200 |
-
βββ main.py # CLI entry point
|
| 201 |
-
βββ automation.py # Pipeline orchestrator
|
| 202 |
-
βββ api_clients.py # Gemini, RunwayML, TTS, GCS
|
| 203 |
-
βββ video_renderer.py # Video processing engine
|
| 204 |
-
βββ asset_selector.py # AI video selection
|
| 205 |
-
βββ utils.py # Logging & utilities
|
| 206 |
-
βββ requirements.txt # Python dependencies
|
| 207 |
-
βββ config/
|
| 208 |
-
βββ api_keys.yaml # API configurations
|
| 209 |
-
βββ content_strategies.yaml
|
| 210 |
-
```
|
| 211 |
-
|
| 212 |
-
### Key Dependencies
|
| 213 |
-
- `moviepy` - Video editing and composition
|
| 214 |
-
- `google-generativeai` - Gemini API client
|
| 215 |
-
- `google-cloud-texttospeech` - TTS service
|
| 216 |
-
- `google-cloud-storage` - Cloud storage
|
| 217 |
-
- `aiohttp` - Async HTTP requests
|
| 218 |
-
- `pandas` - Data processing
|
| 219 |
-
|
| 220 |
-
### API Requirements
|
| 221 |
-
- **Gemini**: Free tier available
|
| 222 |
-
- **RunwayML**: $10 minimum deposit
|
| 223 |
-
- **Google Cloud**: $300 free credits for new accounts
|
| 224 |
-
- **Storage**: 5GB free tier
|
| 225 |
-
|
| 226 |
-
---
|
| 227 |
-
|
| 228 |
-
## π Troubleshooting
|
| 229 |
-
|
| 230 |
-
### Common Issues
|
| 231 |
-
|
| 232 |
-
**"API key not found"**
|
| 233 |
-
- Check `.env` file exists and has correct keys
|
| 234 |
-
- Restart terminal after adding keys to `.env`
|
| 235 |
-
|
| 236 |
-
**"Insufficient RunwayML credits"**
|
| 237 |
-
- Add credits at https://dev.runwayml.com/
|
| 238 |
-
- Minimum $10 required
|
| 239 |
-
|
| 240 |
-
**"Google Cloud permission denied"**
|
| 241 |
-
- Verify service account JSON path in `.env`
|
| 242 |
-
- Check service account has "Storage Admin" role
|
| 243 |
-
|
| 244 |
-
**"Module not found"**
|
| 245 |
-
```bash
|
| 246 |
-
pip install -r requirements.txt
|
| 247 |
-
```
|
| 248 |
-
|
| 249 |
-
**Videos taking too long**
|
| 250 |
-
- RunwayML generation takes 30-60 seconds
|
| 251 |
-
- Use `--test` for quick verification
|
| 252 |
-
|
| 253 |
-
### Performance Tips
|
| 254 |
-
- Keep scripts under 200 characters for optimal TTS
|
| 255 |
-
- Use specific, visual prompts for better AI videos
|
| 256 |
-
- Test with `--test` flag before full runs
|
| 257 |
-
- Monitor API usage in respective dashboards
|
| 258 |
-
|
| 259 |
-
---
|
| 260 |
-
|
| 261 |
-
## π Support
|
| 262 |
-
|
| 263 |
-
### Debugging
|
| 264 |
-
- Run with `--verbose` for detailed logs
|
| 265 |
-
- Check console output for specific error messages
|
| 266 |
-
- Verify all APIs are enabled in their consoles
|
| 267 |
-
|
| 268 |
-
### Cost Control
|
| 269 |
-
- Use `--test` frequently during development
|
| 270 |
-
- Set billing alerts in Google Cloud & RunwayML
|
| 271 |
-
- Monitor usage in API dashboards
|
| 272 |
-
|
| 273 |
-
### Security
|
| 274 |
-
- β
Never commit `.env` file (included in `.gitignore`)
|
| 275 |
-
- β
Use environment variables for all keys
|
| 276 |
-
- β
Rotate API keys every 90 days
|
| 277 |
-
- β Never hardcode keys in source files
|
| 278 |
-
|
| 279 |
-
---
|
| 280 |
-
|
| 281 |
-
## π Next Steps
|
| 282 |
-
|
| 283 |
-
1. β
Complete API setup
|
| 284 |
-
2. β
Run `python main.py --health-check`
|
| 285 |
-
3. β
Test with `python main.py --test`
|
| 286 |
-
4. β
Generate first video with `python main.py`
|
| 287 |
-
5. π Customize scripts and strategies for your products
|
| 288 |
-
6. π Scale with batch processing for multiple videos
|
| 289 |
-
|
| 290 |
-
**Need help?** Check the error messages in console - they're designed to be helpful and specific about what went wrong.
|
| 291 |
-
|
| 292 |
-
---
|
| 293 |
-
|
| 294 |
-
*Happy video generating! π¬*
|
| 295 |
-
..
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Elvoro Tools
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
app_port: 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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