Skip to content

HariN999/Automated-Telugu-Text-Summarization-and-Speech-Generation-using-NLP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Telugu Text Summarization & Speech Generation

FastAPI React Transformers Docker Vercel

Full-stack NLP application for Telugu news summarization and speech generation.

Status: Research paper under review at ICANITS 2026.

The system supports direct Telugu text input, URL-based article extraction, extractive TF-IDF summarization, transformer-based mT5 summarization, and optional Telugu text-to-speech audio generation.

🚀 Live Demo

For the smoothest demo on free hosting, start with the TF-IDF method. Transformer requests may take longer because the model is loaded lazily.

🎬 Video Demo

Watch Demo

What the demo shows:

  • Telugu text summarization using mT5
  • URL-based article summarization
  • Runtime model selection with TF-IDF / mT5
  • Output generation through FastAPI
  • Optional Telugu MP3 audio output

Note: TTS audio output is supported, but playback may not be audible in the recording depending on screen-recording settings.

🧠 Features

  • Telugu text summarization from pasted input
  • Telugu article summarization from URLs
  • Extractive summarization with TF-IDF
  • Transformer-based abstractive summarization with mT5
  • Automatic fallback to TF-IDF if mT5/tokenizer loading fails
  • Telugu speech generation using Edge TTS
  • Latest-news workflow with RSS ingestion
  • FastAPI documentation at /docs
  • Deployed React frontend and Dockerized backend

🚀 Project Highlights

  • End-to-end working NLP system
  • Extractive and transformer-based summarization in one application
  • Runtime model selection through API payloads
  • Telugu neural speech generation with MP3 playback
  • Full-stack integration with React and FastAPI
  • Dockerized backend deployed on Render
  • Vite frontend deployed on Vercel
  • Research-backed architecture with evaluation metrics

🏗️ Architecture

Architecture

React + Vite Frontend (Vercel)
        |
        | VITE_API_URL
        v
FastAPI Backend (Render Docker)
        |
        | extract -> clean -> summarize -> optional TTS
        v
TF-IDF / Hugging Face mT5 / Edge TTS

The system follows a modular NLP pipeline:

Input text / URL
      |
      v
FastAPI Backend
      |
      v
Extract -> Clean -> Summarize -> Optional Text-to-Speech
      |
      v
JSON summary response + optional MP3 audio URL

The backend is designed to keep the API responsive even when transformer loading fails. If the mT5 tokenizer or model cannot be loaded, the summarization path logs a warning and returns a TF-IDF summary instead of crashing the API.

🧩 NLP Pipeline Components

File Purpose
backend/extract.py URL parsing and article text extraction
backend/clean.py Telugu text normalization and cleanup
backend/summarize_tfidf.py Fast extractive summarization with TF-IDF
backend/summarize_mt5.py Transformer-based abstractive summarization with mT5
backend/tts.py Telugu speech generation with Edge TTS
backend/pipeline.py End-to-end orchestration: extract -> clean -> summarize -> TTS
backend/app.py FastAPI routes, CORS, health checks, audio serving
backend/services/news_service.py Telugu RSS ingestion for latest-news mode

⚙️ Tech Stack

Layer Tools
Frontend React, Vite, React Router, Tailwind CSS, Framer Motion
Backend FastAPI, Uvicorn, Pydantic
NLP Hugging Face Transformers, PyTorch, SentencePiece, scikit-learn
Summarization TF-IDF, mT5 multilingual XLSum
Speech Edge TTS
Deployment Render Docker backend, Vercel frontend
Packaging Docker, requirements.txt, npm

📂 Project Structure

.
├── backend/
│   ├── app.py
│   ├── pipeline.py
│   ├── extract.py
│   ├── clean.py
│   ├── summarize_tfidf.py
│   ├── summarize_mt5.py
│   ├── tts.py
│   ├── services/
│   ├── data/
│   └── model/
├── frontend/
│   ├── src/
│   ├── public/
│   ├── package.json
│   └── vite.config.js
├── screenshots/
├── assets/
├── Dockerfile
├── requirements.txt
└── README.md

📸 Screenshots

Home

Home Page

Text Summarization

Text Summarization

URL Summarization

URL Summarization

Speak News

Speak News

API Docs

API Docs

🔌 API Endpoints

Method Endpoint Purpose
GET /health Lightweight health check
GET /docs FastAPI Swagger documentation
POST /summarize Summarize pasted Telugu text
POST /process-url Extract and summarize an article URL
GET /latest-news Fetch and summarize Telugu news
GET /audio/{filename} Serve generated MP3 files

🔊 Speech System

  • Implemented using Edge TTS
  • Uses a Telugu neural voice for MP3 generation
  • Generated audio is written to backend/data/
  • Audio files are served by FastAPI through /audio/{filename}
  • On free hosting, generated files may not persist after restarts

🛠️ Local Setup

Backend

python -m venv myenv
source myenv/bin/activate
pip install -r requirements.txt

cd backend
uvicorn app:app --reload --host 0.0.0.0 --port 8000

Backend runs at:

http://localhost:8000

Frontend

cd frontend
npm install
npm run dev

Frontend runs at:

http://localhost:5173

For local frontend-to-backend communication, create frontend/.env:

VITE_API_URL=http://localhost:8000

🐳 Docker Backend

Build the backend image from the project root:

docker build -t telugu-news-api .

Run locally:

docker run --rm \
  --name telugu-news-api \
  -p 10000:10000 \
  -e PORT=10000 \
  -e CORS_ORIGIN_REGEX='https://.*\.vercel\.app' \
  telugu-news-api

Test:

curl http://localhost:10000/health

🌐 Deployment

Backend: Render

Use the existing Dockerfile.

Recommended environment variables:

PORT=10000
DEBUG=false
CORS_ORIGIN_REGEX=https://.*\.vercel\.app
CORS_ORIGINS=https://automated-telugu-text-summarization.vercel.app

Frontend: Vercel

Set the frontend root directory to:

frontend

Build settings:

Install Command: npm ci
Build Command: npm run build
Output Directory: dist

Environment variable:

VITE_API_URL=https://automated-telugu-text-summarization-and-s2gz.onrender.com

⚠️ Deployment Notes

  • Render free tier can cold start after inactivity.
  • First mT5 request may be slow because Hugging Face models are loaded lazily.
  • TF-IDF is recommended for fast demos and health checks.
  • backend/model/ is intentionally excluded from Docker builds to keep the image small.
  • If the local fine-tuned model is missing, the app falls back to the public Hugging Face mT5 base model.
  • backend/data/ is used for generated audio files. On free hosting, local filesystem writes may not persist across restarts.
  • mT5/T5 tokenizers use SentencePiece. sentencepiece is a required dependency; tiktoken is included only as a defensive fallback for tokenizer conversion edge cases.

📦 Model Notes

The experimental fine-tuned mT5 model is not required for deployment and is excluded from Docker.

Runtime behavior:

  1. Try local fine-tuned model if present.
  2. Fall back to csebuetnlp/mT5_multilingual_XLSum if local model is absent.
  3. Fall back to TF-IDF if mT5/tokenizer loading fails.

To use a local fine-tuned model during development, place it in:

backend/model/mt5-telugu-news-finetuned/

Then restart the backend server.

📊 Evaluation Snapshot

Model ROUGE-1 ROUGE-2 ROUGE-L BERTScore
TF-IDF 0.0324 0.0034 0.0320 0.6728
mT5 Base 0.0436 0.0022 0.0427 0.7239
mT5 Fine-Tuned 0.0404 0.0019 0.0400 0.7229

Key insight: fine-tuning did not improve performance in this experiment because the dataset was limited and the pre-trained multilingual model already covered a similar distribution.

🧠 Key Learnings

  • Pre-trained multilingual models can outperform fine-tuned models when fine-tuning data is limited.
  • BERTScore is often more informative than ROUGE for morphologically rich languages like Telugu.
  • Fine-tuning large transformer models requires significantly more data and compute for stable gains.
  • Extractive methods can show misleading ROUGE behavior because lexical overlap does not always equal semantic quality.
  • Production deployments need graceful fallbacks because hosted model loading can fail due to memory, cold starts, or tokenizer issues.

👥 Team Contributions

Contributor Focus Area
Hariharan Backend API, NLP pipeline, model integration, evaluation
Vishnu React frontend, UI integration, user workflows
Vivek Testing, integration, debugging
Sanjeev Data preparation, text cleaning, experimentation support

🔮 Future Enhancements

  • Larger Telugu summarization dataset
  • Parameter-efficient fine-tuning with LoRA
  • Long-context summarization
  • Persistent object storage for generated audio
  • GPU-backed inference deployment
  • Multilingual expansion for other Indian languages

📄 Research Context

This project demonstrates a practical low-resource Indian-language NLP system using a production-style full-stack architecture: React frontend, FastAPI backend, Docker deployment, Hugging Face Transformers, and graceful fallback behavior for constrained hosting environments.

Releases

No releases published

Packages

 
 
 

Contributors