Semantic sentiment analysis of YouTube comments — powered by RoBERTa, Zero-Shot Classification, and Gemini 2.0 Flash expert reporting.
| Feature | Details |
|---|---|
| Comment Fetching | YouTube Data API v3 — up to 500 comments per run |
| Sentiment Analysis | RoBERTa (cardiffnlp/twitter-roberta-base-sentiment-latest) — 99%+ accuracy |
| Semantic Clustering | Zero-Shot Classification (BART MNLI) into 3 audience segments |
| Interactive Dashboard | Plotly charts: sentiment pie, cluster bar, cross-matrix, activity timeline |
| 🤖 Expert AI Report | Gemini 2.0 Flash — dynamic analyst role + 3 business opportunity recommendations |
| Export | Full CSV + summary CSV + expert report .md download |
| Demo Mode | Run with built-in sample data — no API keys required |
After sentiment analysis is complete, the app sends a structured data digest to Gemini 2.0 Flash, which assumes a dynamic expert role based on the dominant comment cluster:
| Dominant Cluster | Analyst Role Assigned |
|---|---|
| 🪖 Military/Hawkish | Senior Geopolitical & Defense Policy Analyst |
| 💰 Economic/Domestic | Senior Economic Analyst (Consumer Sentiment) |
| 🗳️ Electoral/Party | Senior Political Communications Strategist |
| Other | Senior Social Media Intelligence Analyst |
The report includes:
- Executive Summary — dominant mood and key signal
- Cluster-by-Cluster Analysis — tone, themes, notable examples
- Audience Intent & Behavior Signals — what this audience is ready to do
- Risk & Opportunity Signals — narratives gaining or losing momentum
- Top 3 Business Opportunities — specific, data-grounded recommendations
- Fork this repo to your GitHub account
- Go to share.streamlit.io
- Connect your GitHub account and select this repo
- Set
app.pyas the main file → click Deploy
⏱️ First run: ~5 min to download NLP models (~2 GB). Subsequent runs use cache.
- Go to console.cloud.google.com
- Create a new project
- Enable YouTube Data API v3
- Create credentials → API Key
- Paste into the sidebar
- Go to aistudio.google.com/app/apikey
- Sign in with your Google account
- Click Create API Key
- Paste into the sidebar under Expert Analysis
Free tier limits: 15 requests/min · 1,500 requests/day — more than enough for analysis sessions.
git clone https://github.com/GreatFooliao111/youtube-comment-intelligence.git
cd youtube-comment-intelligence
pip install -r requirements.txt
streamlit run app.pyYouTube Data API v3
│
▼
Comment Fetcher
(up to 500 comments)
│
▼
Text Cleaner
(URLs, mentions, noise removal)
│
├──────────────────────────┐
▼ ▼
RoBERTa Sentiment BART Zero-Shot
(Positive/Negative/ Cluster Classifier
Neutral + score) (Military / Economic
/ Electoral)
│ │
└──────────┬───────────────┘
▼
Streamlit Dashboard
(Charts · Tables · CSV Export)
│
▼
Gemini 2.0 Flash
Expert Analyst Report
(Dynamic Role · Business Opportunities)
| Layer | Technology |
|---|---|
| UI & Dashboard | Streamlit |
| Sentiment Model | cardiffnlp/twitter-roberta-base-sentiment-latest (HuggingFace) |
| Cluster Classifier | facebook/bart-large-mnli (Zero-Shot, HuggingFace) |
| Expert Report | Google Gemini 2.0 Flash (google-generativeai) |
| Charts | Plotly Express |
| Data | YouTube Data API v3 (google-api-python-client) |
MIT — free to use, modify, and deploy.