Spaces:
Running
Running
| """ | |
| V8 Autonomous Viral Engine | |
| -------------------------- | |
| Fully automated pipeline for viral video generation. | |
| """ | |
| import os | |
| from utils.transcription import transcribe_video | |
| from utils.highlights import detect_highlights | |
| from utils.clipper import create_clips | |
| from utils.srt import generate_srt | |
| from utils.render import render_subtitles | |
| from utils.variations import generate_hooks | |
| from utils.pacing import pacing_engine | |
| from utils.viral_scorer import score_clip | |
| # ===================================================== | |
| # CORE AUTONOMOUS PIPELINE | |
| # ===================================================== | |
| def run_autonomous_engine(video_path): | |
| """ | |
| One-call system → full viral pipeline | |
| """ | |
| print("[V8 ENGINE] Starting autonomous pipeline...") | |
| # 1. TRANSCRIBE | |
| words = transcribe_video(video_path) | |
| # 2. DETECT HIGHLIGHTS | |
| highlights = detect_highlights(words) | |
| if not highlights: | |
| return { | |
| "status": "failed", | |
| "reason": "No highlights detected" | |
| } | |
| # 3. AUTO CLIP GENERATION | |
| clips = create_clips(video_path, highlights) | |
| if not clips: | |
| return { | |
| "status": "failed", | |
| "reason": "Clip generation failed" | |
| } | |
| outputs = [] | |
| # 4. PROCESS EACH CLIP AUTONOMOUSLY | |
| for i, clip in enumerate(clips): | |
| try: | |
| clip_words = transcribe_video(clip) | |
| # 5. CAPTIONS | |
| srt = generate_srt(clip_words) | |
| # 6. PACING OPTIMIZATION (NEW V8) | |
| paced_clip = pacing_engine(clip, clip_words) | |
| # 7. HOOK VARIATIONS | |
| hooks = generate_hooks(clip_words) | |
| # 8. RENDER OUTPUT | |
| output_path = clip.replace(".mp4", f"_v8_{i}.mp4") | |
| final_video = render_subtitles( | |
| paced_clip, | |
| srt, | |
| output_path | |
| ) | |
| # 9. VIRAL SCORING | |
| score = score_clip(clip_words) | |
| outputs.append({ | |
| "clip": final_video, | |
| "score": score, | |
| "hooks": hooks[:3], | |
| "index": i | |
| }) | |
| except Exception as e: | |
| print(f"[V8 ENGINE] Clip {i} failed:", str(e)) | |
| continue | |
| # 10. SORT BY VIRAL SCORE | |
| outputs = sorted(outputs, key=lambda x: x["score"], reverse=True) | |
| return { | |
| "status": "completed", | |
| "best_clip": outputs[0] if outputs else None, | |
| "all_variants": outputs | |
| } |