This project is a real-time sentiment analysis tool for YouTube Live Chats, built with a Python FastAPI backend and a custom-trained machine learning model, and a TypeScript-based Chrome extension for the front end. It is designed to provide content creators and moderators with instant insights into the sentiment of their live chat audience.
- Real-time Analysis: Monitors and analyzes YouTube live chat messages as they are posted.
- Interactive Dashboard: A web-based interface provides a dashboard with charts and key statistics for sentiment distribution.
- Confidence Scores: Each sentiment prediction includes a confidence score, giving users a better understanding of the model's certainty.
- Auto-start: The analysis automatically begins when a user navigates to a YouTube live stream page.
- Customizable: The Chrome extension is configurable, allowing users to specify the API server URL and other analysis settings.
The project is divided into two main components: a server and a chrome_extension.
The server directory contains the backend of the application.
- Framework: Built using FastAPI for high performance and easy API creation.
- Machine Learning: Hosts a custom-trained sentiment analysis model. The model is trained and managed using MLflow for experiment tracking, versioning, and easy deployment.
- Tokenizer: A custom tokenizer is used to preprocess text data for the model.
The chrome_extension directory holds the user-facing part of the application.
- Languages: Developed using TypeScript to ensure a robust and maintainable codebase.
- Functionality: It injects a content script into YouTube live stream pages to capture chat messages and send them to the FastAPI server for analysis. The results are then displayed on an interactive dashboard.
- Python 3.8+
- Node.js and npm
- Google Chrome browser
- MLflow (
pip install mlflow)
Navigate to the server directory and install the required Python dependencies:
pip install -r requirements.txtNavigate to the chrome_extension directory and install the Node.js packages:
npm installAfter installation, build the extension:
npm run buildThis will create a dist directory.
From the server directory, run the FastAPI application:
uvicorn main:app --reloadThe server will start at http://127.0.0.1:8000.
- Open Google Chrome and navigate to
chrome://extensions/. - Enable "Developer mode" in the top-right corner.
- Click "Load unpacked" and select the
distfolder from yourchrome_extensiondirectory. - The extension icon will appear in your browser toolbar.
- Go to a YouTube live stream with an active chat.
- Click the extension icon to open the popup.
- The analysis should begin automatically.
The MLflow tracking server is used to manage and serve the machine learning models.
To run the MLflow UI and view your experiments:
- Navigate to the project's root directory.
- Start the MLflow UI:
mlflow server --host 127.0.0.1 --port 5000You can then access the UI in your browser at: 👉 http://127.0.0.1:5000
This project is licensed under the MIT License. See the LICENSE file for details.