Skip to content

AZ8089/new-perspective

Repository files navigation

Perchspective 🔍

A Next.js app that analyzes the bias of any YouTube video using Gemini 2.5 Flash — extracts the real transcript, classifies bias across 5 dimensions, and recommends videos from opposing and neutral perspectives.

Features

  • 🎬 YouTube Embed — watch the video right in the app
  • 📝 Transcript Extraction — real captions via youtube-transcript
  • 🤖 Gemini 2.5 Flash — AI bias classification (server-side, key stays private)
  • 📊 5 Bias Dimensions — Political Leaning, Emotional Tone, Factual Density, Perspective Diversity, Source Credibility
  • 🧭 Political Spectrum Needle — animated visual indicator
  • Bias Signals — specific detected patterns (loaded language, omission, etc.)
  • 🔗 4 Alternative Searches — Left, Right, Neutral/Expert, International

Setup

1. Get a Gemini API Key

Go to https://aistudio.google.com/app/apikey and create a free API key.

2. Install dependencies

npm install

3. Add your API key

Create (or edit) .env.local in the project root:

GEMINI_API_KEY=your_actual_api_key_here

⚠️ Never commit this file. It's in .gitignore by default.

4. Run the app

npm run dev

Open http://localhost:3000

Usage

  1. Paste any YouTube URL into the input field
  2. Click ANALYZE
  3. Wait ~10-20 seconds for transcript extraction + Gemini analysis
  4. View the full bias breakdown and click the recommendation links to find balance

Notes

  • Transcript availability: Videos must have captions enabled (auto-generated or manual). Age-restricted, private, or caption-disabled videos will fail with a clear error message.
  • API costs: Gemini 2.5 Flash has a generous free tier. One analysis uses ~2,000–5,000 tokens depending on transcript length.
  • Model: Uses gemini-2.5-flash — Google's latest fast, capable model.

Tech Stack

Layer Technology
Framework Next.js 15 (App Router)
Language TypeScript
Styling Tailwind CSS
AI Gemini 2.5 Flash via @google/generative-ai
Transcript youtube-transcript
Fonts Bebas Neue, DM Mono, Playfair Display

Project Structure

perspective-lens/
├── app/
│   ├── api/
│   │   └── analyze/
│   │       └── route.ts      ← API route (Gemini + transcript logic)
│   ├── globals.css
│   ├── layout.tsx
│   └── page.tsx
├── components/
│   ├── PerchspectiveApp.tsx ← Main client component
│   ├── Header.tsx
│   ├── VideoEmbed.tsx
│   └── BiasResults.tsx        ← Full analysis display
├── .env.local                 ← Add your API key here
└── README.md

About

finds videos of the same topic with different perspectives

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors