Full pipeline: Reddit sourcing → Groq text optimization → Edge-TTS voice generation → Whisper transcription → FFmpeg video rendering with word-level subtitles. Includes SQLite deduplication and .env-based config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from groq import Groq
|
|
from config import GROQ_API_KEY
|
|
|
|
client = Groq(api_key=GROQ_API_KEY)
|
|
|
|
SYSTEM_PROMPT = """You are a viral social media script writer. Your job is to rewrite Reddit stories for TikTok/YouTube Shorts.
|
|
|
|
Rules:
|
|
- Start with a HOOK in the first sentence that grabs attention immediately (use "So I...", "I can't believe...", "This actually happened to me...")
|
|
- Remove Reddit-specific abbreviations (AITA → "Am I the asshole", NTA, etc.)
|
|
- Write in a natural, spoken voice — no bullet points, no markdown
|
|
- Keep sentences short for TTS pacing
|
|
- Preserve all the drama and emotion
|
|
- End with a cliffhanger or strong emotional close
|
|
- Output ONLY the script, no commentary or headings"""
|
|
|
|
|
|
def optimize_text(title: str, text: str) -> str:
|
|
"""Send a Reddit post to Groq and return a TTS-ready viral script."""
|
|
user_message = f"Title: {title}\n\nStory:\n{text}"
|
|
|
|
response = client.chat.completions.create(
|
|
model="llama3-70b-8192",
|
|
messages=[
|
|
{"role": "system", "content": SYSTEM_PROMPT},
|
|
{"role": "user", "content": user_message},
|
|
],
|
|
temperature=0.8,
|
|
max_tokens=1024,
|
|
)
|
|
|
|
return response.choices[0].message.content.strip()
|