Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -306,39 +306,6 @@ class ImageScraper:
|
|
| 306 |
duration = len(script.split()) * 0.3
|
| 307 |
return AudioFileClip(duration=duration)
|
| 308 |
|
| 309 |
-
|
| 310 |
-
def get_stock_images(self) -> List[str]:
|
| 311 |
-
"""Return preset stock images as fallback"""
|
| 312 |
-
return [
|
| 313 |
-
"https://images.pexels.com/photos/60504/security-protection-anti-virus-software-60504.jpeg",
|
| 314 |
-
"https://images.pexels.com/photos/5380642/pexels-photo-5380642.jpeg",
|
| 315 |
-
"https://images.pexels.com/photos/2582937/pexels-photo-2582937.jpeg",
|
| 316 |
-
"https://images.pexels.com/photos/7319074/pexels-photo-7319074.jpeg",
|
| 317 |
-
"https://images.pexels.com/photos/4164418/pexels-photo-4164418.jpeg",
|
| 318 |
-
"https://images.pexels.com/photos/3861969/pexels-photo-3861969.jpeg",
|
| 319 |
-
"https://images.pexels.com/photos/5473298/pexels-photo-5473298.jpeg",
|
| 320 |
-
"https://images.pexels.com/photos/4348401/pexels-photo-4348401.jpeg",
|
| 321 |
-
"https://images.pexels.com/photos/8386440/pexels-photo-8386440.jpeg",
|
| 322 |
-
"https://images.pexels.com/photos/5473950/pexels-photo-5473950.jpeg"
|
| 323 |
-
]
|
| 324 |
-
|
| 325 |
-
def get_images(self, query: str, num_images: int = 15) -> List[str]:
|
| 326 |
-
# First try Pixabay
|
| 327 |
-
images = self.get_pixabay_images(query)
|
| 328 |
-
|
| 329 |
-
# If no Pixabay images, try with technology-related terms
|
| 330 |
-
if not images:
|
| 331 |
-
tech_terms = ["digital security", "technology", "cyber security", "data protection"]
|
| 332 |
-
for term in tech_terms:
|
| 333 |
-
images.extend(self.get_pixabay_images(term))
|
| 334 |
-
|
| 335 |
-
# If still no images, use stock images
|
| 336 |
-
if not images:
|
| 337 |
-
images = self.get_stock_images()
|
| 338 |
-
|
| 339 |
-
# Remove duplicates and limit to num_images
|
| 340 |
-
return list(dict.fromkeys(images))[:num_images]
|
| 341 |
-
|
| 342 |
def scrape_pexels(self, query: str) -> List[str]:
|
| 343 |
urls = []
|
| 344 |
try:
|
|
|
|
| 306 |
duration = len(script.split()) * 0.3
|
| 307 |
return AudioFileClip(duration=duration)
|
| 308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
def scrape_pexels(self, query: str) -> List[str]:
|
| 310 |
urls = []
|
| 311 |
try:
|