A web-based application that extracts key details from multiple news articles related to a given company, performs sentiment analysis, conducts a comparative analysis, and generates a text-to-speech (TTS) output in Hindi. The tool should allow users to input a company name and receive a structured sentiment report along with an audio output.
Frontend: Gradio
Backend: Flask (APIs)
NLP Models: Hugging Face transformers (Sentiment Analysis)
Text-to-Speech: gTTS (Hindi Speech)
News Extraction: NewsAPI
Python 3.8+
pip
Clone this repository locally. In a terminal, run the following command:
$ git clone https://github.com/shareefmx/News-Summarization.git
$ cd news-summarization-tts
Open the cloned repository in your VS code.
Open the terminal and install the package.
pip install gradio
pip install flask
pip install tensorflow
pip install torch torchvision torchaudio
pip install deep-translator
setup with virtual environments(.venv file) and install.
python -m venv env
source env/bin/activate
pip install -r requirements.txt
OR
pip install requests beautifulsoup4 newspaper3k transformers torch gradio streamlit gTTS
Run the python file. In a terminal, run the following command:
$ python app.py
Running on local URL and click [ Ctrl + click ] the url(Access the interface at http://127.0.0.1:7860/).
Approach: Uses the description field from NewsAPI as a summary.
Why? Avoids unnecessary processing and ensures real-time performance.
Model: Hugging Face's distilbert-base-uncased-finetuned-sst-2-english
How it Works?
Takes the news summary as input.
Classifies it into Positive, Negative, or Neutral sentiment.
Model: gTTS (Google Text-to-Speech)
Language: Hindi (lang="hi")
English text is translated to Hindi using deep_translator.
Hindi text is converted into speech using gTTS.
| Endpoint | Method | Description | Example |
|---|---|---|---|
/news?company=Tesla |
GET |
Fetches news articles for a company | http://127.0.0.1:5000/news?company=Tesla |
/sentiment |
POST |
Performs sentiment analysis on text | curl -X POST -H "Content-Type: application/json" -d '{"text": "Tesla is performing well"}' http://127.0.0.1:5000/sentiment |
/tts |
POST |
Converts text to Hindi speech | curl -X POST -H "Content-Type: application/json" -d '{"text": "Tesla is growing fast"}' http://127.0.0.1:5000/tts |
| API | Purpose | Integration Details |
|---|---|---|
| NewsAPI | Fetches latest news articles related to a company | Requires an API key from NewsAPI |
| Google Translator API (deep_translator) | Translates English summaries into Hindi | Used to generate Hindi text before Text-to-Speech |
| gTTS (Google Text-to-Speech) | Converts Hindi text into speech | Generates output.mp3 from Hindi-translated text |
| Flask REST API | Provides endpoints for news fetching, sentiment analysis, and TTS | API endpoints are accessible via Postman or cURL |
Test News Fetching:
GET: http://127.0.0.1:5000/news?company=Apple
POST: http://127.0.0.1:5000/sentiment
Body: { "text": "Apple is leading the market" }
POST: http://127.0.0.1:5000/tts
Body: { "text": "Apple has recorded high sales this quarter" }
NewsAPI provides at least 10 relevant articles per company.
Sentiment analysis works reliably for short news summaries.
Google Translator API provides accurate Hindi translations.
NewsAPI's free tier has a daily request limit (100 requests/day).
TTS is limited to short summaries (long texts may cause delays).
Translation quality may not be perfect for complex sentences.
Local Host :- http://127.0.0.1:7860/
Hugging Face Spaces Link :- https://huggingface.co/spaces/shareefmx/News-Summarization
youtube :- https://www.youtube.com/watch?v=hMs82sSt-So
Email: shareefmottath@gmail.com
GitHub: https://github.com/shareefmx/
Huggingface :- https://huggingface.co/spaces/shareefmx/