reddit-video-bot/main.py
sylyx 98e829c995 Initial implementation of reddit-video-bot
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>
2026-05-16 10:29:32 +02:00

45 lines
1.3 KiB
Python

import os
import sys
from src.reddit_client import get_next_post, mark_processed
from src.processor import optimize_text
from src.voice_gen import generate_audio
from src.subtitler import transcribe
from src.video_engine import render_video
WHISPER_MODEL = os.getenv("WHISPER_MODEL", "base")
TEMP_AUDIO = "temp_audio.mp3"
def run():
print("[main] Fetching next Reddit post...")
post = get_next_post()
if not post:
print("[main] No new viral posts found. Try again later.")
sys.exit(0)
print(f"[main] Found: r/{post['subreddit']}{post['title'][:60]} (score: {post['score']})")
print("[main] Optimizing text with Groq...")
script = optimize_text(post["title"], post["text"])
print(f"[main] Script preview: {script[:120]}...")
print("[main] Generating voice...")
generate_audio(script, TEMP_AUDIO)
print("[main] Transcribing with Whisper...")
words = transcribe(TEMP_AUDIO, model_name=WHISPER_MODEL)
print(f"[main] Got {len(words)} word timestamps.")
print("[main] Rendering video...")
output_path = render_video(TEMP_AUDIO, words, post["id"])
mark_processed(post["id"])
print(f"[main] Done! Video saved to: {output_path}")
if os.path.exists(TEMP_AUDIO):
os.remove(TEMP_AUDIO)
if __name__ == "__main__":
run()