| def score_clip(words): |
| """ |
| Returns virality score (0–100) |
| based on speech + structure signals |
| """ |
|
|
| if not words: |
| return 0 |
|
|
| text = " ".join([w["text"] for w in words]).lower() |
|
|
| score = 0 |
|
|
| |
| |
| |
| hook_words = ["you", "imagine", "stop", "listen", "this", "never", "why"] |
|
|
| if any(h in text[:50] for h in hook_words): |
| score += 25 |
|
|
| |
| |
| |
| exclamations = sum(1 for w in words if "!" in w["text"]) |
| score += min(exclamations * 5, 20) |
|
|
| |
| |
| |
| duration = words[-1]["end"] - words[0]["start"] |
|
|
| if 6 <= duration <= 25: |
| score += 25 |
| elif duration < 6: |
| score -= 10 |
| else: |
| score -= 5 |
|
|
| |
| |
| |
| score += min(len(words) / 2, 20) |
|
|
| |
| return max(0, min(100, score)) |