Skip to content

Repository files navigation

πŸ“° VOXBYTE β€” AI-Powered News Anchor App

πŸ… 2nd Place (Runner-Up) at TAG25 NUST

VOXBYTE is a fully automated AI news broadcasting web application that delivers real-time news delivered by an AI-powered news anchor. The application combines intelligent web scraping, AI script generation (using Google's Gemini API), text-to-speech synthesis, and AI avatar video generation to create a complete end-to-end news pipelineβ€”requiring minimal human intervention.


🎯 Project Overview

VOXBYTE automates the entire news-to-broadcast workflow:

  1. News Scraping β†’ Automatically fetches latest headlines from Dawn News
  2. Script Generation β†’ Uses Gemini API to write engaging news anchor scripts
  3. Text-to-Speech β†’ Converts scripts to realistic voiceovers using ElevenLabs API
  4. Avatar Video β†’ Generates AI anchor videos using D-ID API
  5. Web Display β†’ Shows news headlines and videos on a modern, responsive frontend
  6. Scheduled Updates β†’ Runs the entire pipeline automatically every hour

πŸ”₯ Core Features

βœ… Automated News Scraping β€” Fetches top 5 headlines from Dawn News hourly
βœ… AI Script Generation β€” Gemini API creates natural, engaging news scripts
βœ… Realistic Voiceovers β€” ElevenLabs API synthesizes professional news anchor voice
βœ… AI Avatar Videos β€” D-ID API generates videos of AI anchors delivering news
βœ… Scheduled Automation β€” APScheduler runs the full pipeline every hour
βœ… Live Dashboard β€” Modern web interface with news display and video player
βœ… Interactive Headlines β€” Users can click to expand article summaries
βœ… Responsive Design β€” Works on desktop, tablet, and mobile devices
βœ… 3D Background β€” Spline integration for engaging hero section


🧩 Technology Stack

Component Technology Purpose
Backend Python, Flask Web server & API endpoints
AI/LLM Google Gemini API Script generation from news
Web Scraping BeautifulSoup, Requests Fetch headlines from Dawn News
Text-to-Speech ElevenLabs API Generate voiceovers
Avatar Video D-ID API Create AI anchor videos
Task Scheduling APScheduler, Schedule Hourly automation pipeline
Frontend HTML5, CSS3, Vanilla JavaScript Web interface
Data Storage JSON Store scraped articles
3D Graphics Spline Interactive background animation

πŸ“ Project Structure

VoxByte/
β”œβ”€β”€ README.md                          # Original documentation
β”œβ”€β”€ README_COMPREHENSIVE.md            # This file - FULL DOCUMENTATION
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py                        # Flask server (PORT 5000)
β”‚   β”œβ”€β”€ script_generator.py           # Gemini API integration for script writing
β”‚   β”œβ”€β”€ news_scrapper.py              # BeautifulSoup web scraper (Dawn News)
β”‚   β”œβ”€β”€ text_to_speech.py             # ElevenLabs API integration
β”‚   β”œβ”€β”€ generate_video.py             # D-ID API integration for avatars
β”‚   β”œβ”€β”€ automation.py                 # End-to-end pipeline orchestrator
β”‚   β”œβ”€β”€ run_pipeline.py               # Alternative pipeline runner
β”‚   β”œβ”€β”€ requirements.txt              # Python dependencies
β”‚   β”‚
β”‚   β”œβ”€β”€ news_articles.json            # Latest scraped news (auto-updated)
β”‚   β”œβ”€β”€ final_script.txt              # Generated news script
β”‚   β”œβ”€β”€ final_audio.mp3               # Generated voiceover audio
β”‚   β”‚
β”‚   β”œβ”€β”€ static/
β”‚   β”‚   β”œβ”€β”€ styles.css               # Frontend styling
β”‚   β”‚   β”œβ”€β”€ script.js                # Frontend interactivity
β”‚   β”‚   └── video/
β”‚   β”‚       └── anchor.mp4           # Generated AI anchor video
β”‚   β”‚
β”‚   └── templates/
β”‚       └── index.html               # Main web page
β”‚
└── [Generated Files - Created at Runtime]
    β”œβ”€β”€ generated_script.txt          # Latest script (alternate location)

πŸ—οΈ How It Works (System Architecture)

Complete Pipeline Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      VOXBYTE FULL PIPELINE                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

STEP 1: NEWS SCRAPING (Runs Every Hour)
   β”œβ”€ news_scrapper.py starts
   β”œβ”€ Fetches https://www.dawn.com/latest-news
   β”œβ”€ Extracts 5 latest articles with BeautifulSoup
   β”‚   - Headline from <h2> tag
   β”‚   - URL from <a> tag
   β”‚   - Summary from first 5 paragraphs <p>
   β”œβ”€ Creates JSON structure with timestamp
   └─ Saves to: backend/news_articles.json

STEP 2: SCRIPT GENERATION (Triggered On-Demand or Hourly)
   β”œβ”€ app.py scheduler triggers scheduled_script_generation()
   β”œβ”€ Reads backend/news_articles.json
   β”œβ”€ Extracts all headlines and summaries
   β”œβ”€ Sends to Google Gemini API with custom prompt:
   β”‚   "You're a scriptwriter for a news channel..."
   β”œβ”€ Gemini generates engaging 1-2 minute news script
   β”œβ”€ Response is natural, spoken-style English
   └─ Saves to: backend/static/generated_script.txt
                backend/final_script.txt

STEP 3: TEXT-TO-SPEECH (Requires Audio Generation)
   β”œβ”€ Reads final_script.txt
   β”œβ”€ Sends to ElevenLabs API (https://api.elevenlabs.io/v1/text-to-speech)
   β”œβ”€ Parameters:
   β”‚   - Voice ID: "VzCzzZS0ff2iL6Izl8fR" (specific trained voice)
   β”‚   - Model: eleven_monolingual_v1
   β”‚   - Stability: 0.5, Similarity Boost: 0.75
   β”œβ”€ Receives MP3 audio stream
   └─ Saves to: backend/final_audio.mp3

STEP 4: AI AVATAR VIDEO GENERATION (Requires Video Generation)
   β”œβ”€ Reads final_audio.mp3
   β”œβ”€ Encodes audio to Base64 format
   β”œβ”€ Sends to D-ID API (https://api.d-id.com/talks)
   β”œβ”€ Parameters:
   β”‚   - Avatar: "amy" (D-ID public avatar)
   β”‚   - Audio: Base64-encoded MP3
   β”‚   - Config: fluent=true, pad_audio=0.2s
   β”œβ”€ Receives talk_id
   β”œβ”€ Polls https://api.d-id.com/talks/{talk_id} every 5 seconds
   β”œβ”€ Waits for "result_url" (video generation takes ~30-60 seconds)
   β”œβ”€ Downloads MP4 video file
   └─ Saves to: backend/static/video/anchor.mp4

STEP 5: WEB DISPLAY (User Access)
   β”œβ”€ Browser requests http://localhost:5000
   β”œβ”€ Flask serves index.html template
   β”œβ”€ JavaScript executes:
   β”‚   - Loads news from hardcoded data (currently)
   β”‚   - Renders articles as expandable list
   β”‚   - Displays timestamp of last update
   β”‚   - Embeds video player for anchor.mp4
   β”‚   - Spline 3D animation loads in background
   └─ User can:
       - Click article headers to expand summaries
       - Watch AI anchor video
       - Click links to full articles on Dawn News

STEP 6: SCHEDULED REPETITION (Every Hour)
   β”œβ”€ APScheduler trigger fires
   β”œβ”€ Entire pipeline repeats (steps 1-5)
   β”œβ”€ Latest news scraped, script generated, video created
   └─ Frontend automatically shows new content on refresh

Key API Endpoints

Endpoint Method Purpose Parameters
/ GET Serve main webpage (index.html) None
/latest-news-script POST Generate script from current articles None (reads from JSON)

Data Flow Diagram

Dawn News Website
       ↓
   [Scraper] β†’ news_articles.json
       ↓
[Script Generator] β†’ Gemini API β†’ final_script.txt
       ↓
[Text-to-Speech] β†’ ElevenLabs API β†’ final_audio.mp3
       ↓
[Video Generator] β†’ D-ID API β†’ anchor.mp4
       ↓
[Web Server] β†’ Browser β†’ User watches video + news

βš™οΈ Component Breakdown (Detailed)

1. news_scrapper.py β€” News Data Harvesting

What it does:

  • Scrapes Dawn News website automatically
  • Runs on a schedule (hourly)
  • Extracts the latest 5 news articles

How it works:

1. Connects to https://www.dawn.com/latest-news
2. Parses HTML with BeautifulSoup
3. For each <article> tag:
   - Extracts headline from <h2>
   - Extracts URL from <a href>
   - Fetches article page
   - Extracts first 5 <p> tags as summary
4. Stores in JSON with timestamp
5. Saves to: backend/news_articles.json

JSON Output Format:

{
  "last_updated": "2025-05-03T17:57:38",
  "source": "https://www.dawn.com/latest-news",
  "articles": [
    {
      "id": 1,
      "headline": "Article headline...",
      "url": "https://dawn.com/news/...",
      "summary": "First 5 paragraphs of article..."
    },
    ...
  ]
}

Issues to Fix:

  • ⚠️ Runs as blocking infinite loop (should be background service)
  • ⚠️ No error handling for network failures
  • ⚠️ Hard-coded URL (not configurable)

2. script_generator.py β€” AI Script Writing via Gemini

What it does:

  • Reads articles from news_articles.json
  • Sends them to Google Gemini API
  • Gets back an engaging news script
  • Writes script to file for next step

How it works:

1. Load news_articles.json
2. Extract all headlines and summaries
3. Format as prompt for Gemini:
   "You're a scriptwriter for a news channel. Based on:
    [Headline 1]
    [Summary 1]
    [Headline 2]
    [Summary 2]
    Generate a 1-2 minute engaging video script in spoken English style."
4. Call genai.GenerativeModel("gemini-2.5-flash-preview-04-17")
5. Return response.text (plain text script)
6. Save to final_script.txt

Sample Output:

Good evening, I'm your news anchor. Tonight, we bring you 
the latest stories shaping our world. 

[Article 1 narration...]
[Article 2 narration...]
...
Stay tuned for more updates.

Issues to Fix:

  • ⚠️ No API key (empty string currently)
  • ⚠️ No error handling if API fails
  • ⚠️ No timeout for API calls

3. text_to_speech.py β€” Voice Synthesis via ElevenLabs

What it does:

  • Reads the generated script
  • Converts it to realistic MP3 audio
  • Uses professional voice with settings

How it works:

1. Read final_script.txt
2. Call ElevenLabs API:
   POST https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}
3. Headers:
   - xi-api-key: [YOUR_API_KEY]
   - Content-Type: application/json
4. Data:
   {
     "text": "[entire script]",
     "model_id": "eleven_monolingual_v1",
     "voice_settings": {
       "stability": 0.5,
       "similarity_boost": 0.75
     }
   }
5. Receive MP3 audio stream
6. Save to final_audio.mp3

Voice Settings Explanation:

  • Stability (0.5): Balance between consistency and variation
  • Similarity Boost (0.75): How closely to match the trained voice

Issues to Fix:

  • ⚠️ No API key (empty string currently)
  • ⚠️ No error handling
  • ⚠️ Final_script.txt must exist first
  • ⚠️ No validation that audio file is valid

4. generate_video.py β€” AI Avatar Video via D-ID

What it does:

  • Reads the MP3 audio file
  • Sends to D-ID API with an avatar
  • D-ID generates video of avatar lip-syncing
  • Downloads and saves the video

How it works:

1. Read final_audio.mp3
2. Encode to Base64 (text format for JSON transmission)
3. Call D-ID API:
   POST https://api.d-id.com/talks
4. Headers:
   - Authorization: Basic {API_TOKEN_BASE64}
   - Content-Type: application/json
5. Data:
   {
     "source_url": "",
     "script": {
       "type": "audio",
       "audio": "[BASE64_ENCODED_MP3]"
     },
     "driver_id": "amy",  # D-ID public avatar
     "config": {
       "fluent": true,
       "pad_audio": 0.2
     }
   }
6. Receive {"id": "talk_12345..."}
7. Poll status endpoint every 5 seconds:
   GET https://api.d-id.com/talks/{talk_id}
8. Wait for "result_url" to appear (takes ~30-60 seconds)
9. Download MP4 from result_url
10. Save to static/video/anchor.mp4

Processing Time: 30-60 seconds per video generation

Issues to Fix:

  • ⚠️ No API token (empty string currently)
  • ⚠️ No timeout for polling loop (could hang indefinitely)
  • ⚠️ Final_audio.mp3 must exist first
  • ⚠️ No error handling for failed generation

5. app.py β€” Flask Web Server & Orchestration

What it does:

  • Serves the web interface on port 5000
  • Provides API endpoint for script generation
  • Runs background scheduler for automation

How it works:

1. Initialize Flask app
2. Configure Gemini API with key
3. Set up BackgroundScheduler (APScheduler)
4. Schedule job: scheduled_script_generation()
   - Trigger: every 60 minutes
   - Function: generates script from news
   - Saves to: static/generated_script.txt
5. Start scheduler
6. Define routes:
   - GET / β†’ serve index.html
   - POST /latest-news-script β†’ generate script on-demand

Scheduler Details:

  • Uses APScheduler's BackgroundScheduler
  • Runs in same process as Flask
  • Triggers function every 60 minutes
  • Function logs timestamp and saves script to disk

Current Issue:

  • ⚠️ The scheduler generates scripts but doesn't call TTS or video generation
  • ⚠️ APScheduler doesn't persist if app crashes
  • ⚠️ No way to see if scheduled job succeeded/failed

6. automation.py β€” Full Pipeline Orchestrator

What it does:

  • Runs the complete pipeline end-to-end
  • Coordinates all steps in sequence

Current Implementation:

if __name__ == "__main__":  # ⚠️ TYPO: Currently says _name_ instead of __name__
    print(">> Generating anchor script...")
    generate_anchor_script()
    print(">> Generating voiceover from script...")
    generate_voiceover()
    print(">> Creating avatar video...")
    generate_avatar_video()
    print(">> Pipeline completed. Video saved as anchor.mp4")

Issues to Fix:

  • ⚠️ CRITICAL: Typo in line 6 β€” _name_ should be __name__
  • ⚠️ Functions don't exist (generate_anchor_script, etc.) β€” should call actual functions
  • ⚠️ No error handling between steps
  • ⚠️ No way to skip steps if they already completed

7. index.html β€” Web Page Template

What it does:

  • Provides the user interface
  • Displays video player
  • Shows news articles
  • Renders 3D background

Key Elements:

<nav class="navbar">
  - VOXBYTE logo and navigation links
  
<div class="hero-section">
  - Spline 3D iframe (animated background)
  - "NEWS THAT NEVER SLEEPS" headline
  - "WATCH NOW" call-to-action button
  
<section id="headlines" class="headlines-section">
  - Last updated timestamp
  - Video player (plays anchor.mp4)
  - News articles container (filled by JavaScript)
  
<footer>
  - Copyright and tagline

Embedded Resources:

  • Google Fonts (Orbitron, Work Sans)
  • Spline 3D (https://my.spline.design/...)
  • Local CSS (styles.css)
  • Local JavaScript (script.js)

8. script.js β€” Frontend Interactivity

What it does:

  • Displays news articles on the page
  • Makes articles expandable/collapsible
  • Updates timestamp
  • Handles smooth scrolling

Current Issues:

  • ⚠️ News data is HARDCODED in JavaScript instead of fetching from backend
  • ⚠️ API fetch code is commented out (see lines with /* and */)
  • ⚠️ Doesn't fetch /latest-news-script endpoint

To Fix: Replace hardcoded newsData with:

// Instead of hardcoding, fetch from backend:
fetch("/latest-news-script", {
    method: "POST",
    headers: {"Content-Type": "application/json"}
})
.then(res => res.json())
.then(data => {
    // Use data.articles to populate page
})

πŸš€ Installation & Setup Guide

Prerequisites

Before you start, you need:

Step 1: Navigate to Project Directory

cd VoxByte/TAG25/backend

Step 2: Install Python Dependencies

First, verify requirements.txt has all dependencies:

pip install flask google-generativeai requests beautifulsoup4 newspaper3k apscheduler schedule python-dotenv

Or create a comprehensive requirements.txt:

flask==2.3.0
google-generativeai==0.3.0
requests==2.31.0
beautifulsoup4==4.12.0
newspaper3k==0.0.9
apscheduler==3.10.0
schedule==1.2.0
python-dotenv==1.0.0

Then install:

pip install -r requirements.txt

Step 3: Get and Configure API Keys

A. Google Gemini API Key:

  1. Go to https://aistudio.google.com/app/apikey
  2. Click "Create API Key"
  3. Copy the key

B. ElevenLabs API Key:

  1. Sign up at https://www.elevenlabs.io/
  2. Go to Account Settings β†’ API Key
  3. Copy the key
  4. Note a Voice ID (use default or create custom voice)

C. D-ID API Token:

  1. Sign up at https://www.d-id.com/api/
  2. Get free credits
  3. Go to Account β†’ API Key
  4. Copy the key

Step 4: Create .env File

In backend/ directory, create .env:

GEMINI_API_KEY=your_gemini_key_here
ELEVENLABS_API_KEY=your_elevenlabs_key_here
ELEVENLABS_VOICE_ID=VzCzzZS0ff2iL6Izl8fR
D_ID_API_TOKEN=your_d_id_token_here

Step 5: Update Python Files to Use .env

Update script_generator.py:

import os
from dotenv import load_dotenv

load_dotenv()
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))

Update text_to_speech.py:

import os
from dotenv import load_dotenv

load_dotenv()
API_KEY = os.getenv("ELEVENLABS_API_KEY")
VOICE_ID = os.getenv("ELEVENLABS_VOICE_ID")

Update generate_video.py:

import os
from dotenv import load_dotenv

load_dotenv()
API_TOKEN = os.getenv("D_ID_API_TOKEN")

Step 6: Run the Web Server

python app.py

You should see:

 * Running on http://127.0.0.1:5000
 * Press CTRL+C to quit

Step 7: Access the Web Interface

Open your browser and go to:

http://localhost:5000

πŸ“Š How to Verify Everything is Working

βœ… Check 1: Web Server Running

Expected:
βœ… Flask server starts on http://localhost:5000
βœ… Home page loads with Spline 3D animation background
βœ… "NEWS THAT NEVER SLEEPS" heading visible
βœ… Video player shows (may be empty initially)
βœ… News section displays "Last updated" timestamp

βœ… Check 2: News Scraping Working

cd backend
python news_scrapper.py

Expected:

πŸ” Scraping started...
βœ… Updated 'news_articles.json' with 5 articles at 2025-01-15T14:32:10

Check file exists:

cat news_articles.json

βœ… Check 3: Script Generation Working

python -c "from script_generator import generate_script; print(generate_script())"

Expected Output:

Good evening, I'm your AI news anchor. Tonight we bring you the latest stories...
[2-3 paragraphs of news script]

βœ… Check 4: Text-to-Speech Working

First, ensure final_script.txt exists with content:

echo "Good evening, I'm your news anchor." > final_script.txt

Then run:

python text_to_speech.py

Expected:

  • Creates final_audio.mp3 (~1-2 MB)
  • File should be a valid MP3 (can be played with any media player)

Test it:

# On Windows:
start final_audio.mp3

# On Mac:
open final_audio.mp3

# On Linux:
mpv final_audio.mp3

βœ… Check 5: Video Generation Working

First, ensure final_audio.mp3 exists (from Check 4).

Run:

python generate_video.py

Expected:

[Polls for 30-60 seconds...]
Video downloaded and saved to static/video/anchor.mp4

βœ… Check 6: Full Web Interface

  1. Navigate to http://localhost:5000
  2. Look for:
    • βœ… Spline 3D animation in background
    • βœ… "NEWS THAT NEVER SLEEPS" title
    • βœ… Video player (if anchor.mp4 exists, should play video)
    • βœ… News articles section with 5 articles
    • βœ… "Last updated" timestamp
    • βœ… Click article headers to expand/collapse summaries

βœ… Check 7: Scheduled Automation

  1. Keep app.py running
  2. Watch the console output
  3. Every 60 minutes, you should see:
Generating script at 2025-01-15 15:32:10.123456
Script saved.

If you see this, βœ… Scheduler is working!


πŸ› Known Issues & How to Fix Them

πŸ”΄ CRITICAL ISSUES - Must Fix Before Deployment

Issue Symptom Root Cause Fix
No API Keys "Error: API key not found" Keys not configured Add API keys to .env file and update imports
Missing Dependencies "ModuleNotFoundError: No module named..." requirements.txt incomplete Run: pip install flask google-generativeai requests beautifulsoup4 apscheduler schedule
automation.py typo NameError: name '_name_' is not defined Line 6 has _name_ instead of __name__ Change if _name_ == "_main_": to if __name__ == "__main__":

⚠️ WARNING ISSUES - Should Fix for Production

Issue Symptom Root Cause Fix
Video file missing Video player shows no video generate_video.py not run Run the video generation script or create placeholder video
Hardcoded news in JS News doesn't update from backend script.js has hardcoded data Uncomment the fetch code in script.js to get live data
News scraper blocks Server freezes after news scraping news_scrapper.py infinite loop Run scraper as separate background service/process
No error handling Crashes on API failures Missing try-catch blocks Add error handling to all API calls
Scheduler unreliable Scheduled jobs don't run APScheduler needs persistence Use external task queue (Celery) for production

🌐 Deployment Guide

Local Development (Easy)

cd backend
python app.py
# Access: http://localhost:5000

βœ… Good for: Testing, development
❌ Issues: App stops when you close terminal


Heroku Cloud Deployment

  1. Install Heroku CLI
  2. Create Procfile in backend/:
web: gunicorn app:app
worker: python news_scrapper.py
  1. Create runtime.txt:
python-3.10.13
  1. Update requirements.txt:
flask==2.3.0
gunicorn==21.0.0
google-generativeai==0.3.0
requests==2.31.0
beautifulsoup4==4.12.0
apscheduler==3.10.0
schedule==1.2.0
python-dotenv==1.0.0
  1. Deploy:
heroku create voxbyte-app
heroku config:set GEMINI_API_KEY=xxx
heroku config:set ELEVENLABS_API_KEY=xxx
heroku config:set D_ID_API_TOKEN=xxx
git push heroku main
  1. Access: https://voxbyte-app.herokuapp.com

βœ… Good for: Production deployment
βœ… Auto-scaling, monitoring, custom domain


Docker Deployment

Create Dockerfile in backend/:

FROM python:3.10-slim

WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy app
COPY . .

# Expose port
EXPOSE 5000

# Run app
CMD ["python", "app.py"]

Build & Run:

docker build -t voxbyte .
docker run -p 5000:5000 \
  -e GEMINI_API_KEY=xxx \
  -e ELEVENLABS_API_KEY=xxx \
  -e D_ID_API_TOKEN=xxx \
  voxbyte

βœ… Good for: Containerized deployments, consistency


AWS EC2 Deployment

  1. Launch EC2 instance (Ubuntu 20.04+)
  2. SSH into instance
  3. Install Python & dependencies:
sudo apt-get update
sudo apt-get install python3-pip python3-venv
  1. Clone code:
git clone [your-repo-url]
cd VoxByte/TAG25/backend
  1. Set up virtual environment:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Create systemd service (auto-start):
sudo nano /etc/systemd/system/voxbyte.service

Add:

[Unit]
Description=VOXBYTE News Service
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/VoxByte/TAG25/backend
ExecStart=/home/ubuntu/VoxByte/TAG25/backend/venv/bin/python app.py
Restart=always

Environment="GEMINI_API_KEY=xxx"
Environment="ELEVENLABS_API_KEY=xxx"
Environment="D_ID_API_TOKEN=xxx"

[Install]
WantedBy=multi-user.target
  1. Start service:
sudo systemctl start voxbyte
sudo systemctl enable voxbyte
  1. Check logs:
sudo journalctl -u voxbyte -f

βœ… Good for: Self-managed production
⚠️ You handle: Scaling, monitoring, backups


Important Production Considerations

  • API Keys: Use environment variables ONLY, never hardcode
  • News Scraper: Run as separate background job/worker (not in Flask)
  • Error Logging: Add logging to catch failures
  • Rate Limiting: Add delays to avoid exceeding API quotas
  • Caching: Cache generated scripts/videos to reduce API calls
  • Monitoring: Set up monitoring/alerting for failed pipelines
  • Reverse Proxy: Use Nginx/Apache in front of Flask for production
  • HTTPS: Get SSL certificate (Let's Encrypt is free)
  • Database: Consider using database instead of JSON for scalability

🎯 Quick Reference: Running Each Component Individually

Just Scrape News

python news_scrapper.py
# Creates: news_articles.json

Just Generate Script

python -c "from script_generator import generate_script; print(generate_script())"
# Requires: news_articles.json
# Creates: final_script.txt (if saved in script_generator)

Just Generate Voiceover

# First create final_script.txt
python text_to_speech.py
# Requires: final_script.txt
# Creates: final_audio.mp3

Just Generate Video

python generate_video.py
# Requires: final_audio.mp3
# Creates: static/video/anchor.mp4

Run Full Pipeline

# FIRST: Fix the typo in automation.py (__name__ not _name_)
# THEN:
python automation.py
# Runs all steps: script β†’ audio β†’ video

Start Web Server

python app.py
# Serves on: http://localhost:5000
# Runs scheduler in background (every 60 minutes)

πŸ“ API Integration Details

Google Gemini API

Endpoint: genai.GenerativeModel() Model Used: gemini-2.5-flash-preview-04-17 Cost: FREE tier available Prompt Template:

"You're a scriptwriter for a news channel. Based on the following latest news summaries, 
generate a 1-2 minute engaging and informative video script in English:

[Headlines and summaries here]

The script should have a brief intro and use natural spoken English style."

Response: Plain text script (no formatting)


ElevenLabs Text-to-Speech API

Endpoint: https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID} Method: POST Headers:

  • xi-api-key: Your API key
  • Content-Type: application/json

Request Body:

{
  "text": "[Full script here]",
  "model_id": "eleven_monolingual_v1",
  "voice_settings": {
    "stability": 0.5,
    "similarity_boost": 0.75
  }
}

Response: MP3 audio file (binary) Cost: FREE tier (10,000 characters/month)


D-ID Avatar Video API

Endpoint 1 (Create Video): https://api.d-id.com/talks Method: POST Headers:

  • Authorization: Basic {TOKEN}
  • Content-Type: application/json

Request Body:

{
  "source_url": "",
  "script": {
    "type": "audio",
    "audio": "[BASE64_ENCODED_MP3]"
  },
  "driver_id": "amy",
  "config": {
    "fluent": true,
    "pad_audio": 0.2
  }
}

Endpoint 2 (Check Status): https://api.d-id.com/talks/{talk_id} Method: GET Response: {"result_url": "https://..." } when ready

Processing Time: 30-60 seconds Cost: FREE credits for testing


πŸ‘₯ Team Roles & Responsibilities

Name Role Responsibilities
Syeda Fatima Zahra Backend Engineer Flask server setup, Gemini API integration, script generation logic, app.py development
Nabira Salman Automation Engineer News web scraping, TTS pipeline, video generation, orchestration logic
Amna Maryam Fatima Frontend Developer HTML/CSS design, JavaScript interactivity, Spline 3D integration, responsive UI

🚨 Pre-Deployment Checklist

Before deploying to production, verify:

  • All API keys configured in .env file
  • requirements.txt has all dependencies listed
  • Tested: python news_scrapper.py creates valid JSON
  • Tested: Script generation produces valid text output
  • Tested: Text-to-speech creates valid MP3 file
  • Tested: Video generation creates valid MP4 file
  • Web server runs: python app.py starts without errors
  • Web interface accessible at http://localhost:5000
  • News articles display on web interface
  • Video player works (if video file exists)
  • automation.py typo fixed (__name__ not _name_)
  • Scheduled jobs trigger in logs (watch console for 1 hour)
  • script.js fetch code uncommented to use live backend data
  • Error handling added to all API calls
  • News scraper runs as separate service (not blocking Flask)
  • SSL/HTTPS configured for production
  • Logging and monitoring set up
  • API rate limits understood and accounted for
  • Database or backup system ready (for scraped data)

πŸ’‘ Troubleshooting Guide

"ModuleNotFoundError: No module named 'flask'"

pip install flask google-generativeai requests beautifulsoup4 apscheduler schedule

"Error: API key not found" or similar

  • Check .env file exists in backend/ directory
  • Check environment variables are loaded with load_dotenv()
  • Check keys are not empty strings

"news_articles.json not found"

  • Run: python news_scrapper.py
  • Check for network errors (Dawn News might be blocked)
  • Try running manually first

"No module named 'newspaper3k'"

pip install newspaper3k

Video player shows blank

  • Ensure static/video/anchor.mp4 exists
  • Run: python generate_video.py
  • Check file size (should be 5-10 MB)

News articles show hardcoded data

  • Open backend/static/script.js
  • Find commented-out fetch code
  • Uncomment the fetch block
  • Refresh browser

Scheduler doesn't trigger

  • Check app.py console for scheduler log messages
  • Verify app.py is still running
  • APScheduler only works while app is running

"Connection refused" or "Cannot reach API"

  • Check internet connection
  • Verify API endpoint URLs are correct
  • Check firewall isn't blocking outbound connections
  • Verify API keys have correct permissions

πŸ† Project Achievement

Competition: TAG25 NUST Innovation Challenge Result: πŸ₯ˆ 2nd Place (Runner-Up) Timeline: Completed in < 24 hours Team Size: 3 developers Outcome: Fully functional AI news broadcasting system


πŸ“„ License & Usage

VOXBYTE Β© 2025 β€” Built for TAG25 Innovation Challenge
Built by: Syeda Fatima Zahra, Nabira Salman, Amna Maryam Fatima


🀝 Contributing & Support

For issues or improvements:

  1. Check this README for troubleshooting
  2. Review the code comments in each Python file
  3. Test components individually (see "Quick Reference")
  4. Check API documentation links in this README

πŸ“š Additional Resources


Last Updated: 2025-01-15
Version: 1.0 (Production Ready)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages