- NLP
- Transformers
- BART
- Legal Tech
Automated Summarization and Audio Generation of Legal Documents Using Transformer Models
A BART-based pipeline that turns dense legal PDFs into short abstracts and audio narrations.

Abstract
This paper presents a web-based application that automates the summarization of legal documents and generates audio narrations of these summaries. Using transformer-based models, the application accepts PDF and DOCX files and produces concise summaries in text, PDF, and audio formats. The tool aims to help legal professionals, students, and laypersons efficiently understand lengthy legal texts.
Introduction
The legal field routinely involves long, dense documents. Automating their summarization enhances productivity by producing fast, structured insight into cases and statutes. This project leverages state-of-the-art transformer models to generate coherent summaries of legal documents and delivers them through a simple interface that lets users interact with the summary as text or as an audio narration.
Related work
Text summarization has long been a focus in NLP research. Traditional methods are extractive— key sentences are selected from the original text. Extractive approaches often miss overarching themes. Abstractive summarization, enabled by transformer models like BART (Bidirectional and Auto-Regressive Transformers), generates novel sentences that encapsulate the core ideas of the source text. Prior work has applied such models to general text summarization; the legal domain has remained relatively unexplored.
Methodology
System architecture
The application is built in Python and composes several libraries:
- Gradio— provides a user-friendly web interface.
- NLTK— assists in text-processing tasks.
- Transformers (Hugging Face) — uses the
facebook/bart-large-cnnmodel for summarization. - FPDF and ReportLab— generate PDF documents of the summaries.
- gTTS— converts text summaries into speech.
- pdfminer— extracts text from PDF files.
- python-docx— handles DOCX file processing.
Data processing pipeline
- File upload and conversion. Users upload PDF or DOCX files. DOCX files are converted to PDF using ReportLab to standardize the text- extraction step.
- Text extraction. Text is extracted from PDFs using pdfminer, then cleaned and prepared for summarization.
- Text summarization. The BART transformer model summarizes the text. A
min_lengthparameter lets users control the summary’s length. - Output generation.Three artifacts — a text summary rendered in the interface, a PDF summary generated with FPDF, and an audio summary produced with gTTS.
User interface
The Gradio interface consists of:
- An option to summarize a pre-uploaded sample document (Marbury v. Madison).
- A text input field for custom text (optional).
- A file upload button for PDF or DOCX files.
- A slider to adjust the minimum summary length.
- Outputs displaying the audio summary, the text summary, and a downloadable PDF.
Experiments and results
Case study: Marbury v. Madison
To evaluate the application, the landmark case Marbury v. Madisonwas used as a test document. The summarization successfully produced a concise summary that captured the essential aspects of the case — demonstrating the model’s capability to handle complex legal language.
In the landmark case of Marbury v. Madison, the Supreme Court established the principle of judicial review, asserting its power to declare acts of Congress unconstitutional. William Marbury petitioned the Court to compel Secretary of State James Madison to deliver his commission as Justice of the Peace. The Court held that while Marbury had a right to his commission, the provision of the Judiciary Act allowing the Court to issue such writs exceeded the authority allotted under Article III of the Constitution.
Performance metrics
While quantitative measures like ROUGE are standard for evaluating summarization models, the legal domain’s specificity calls for qualitative assessment. Legal experts reviewed the summaries and found them coherent and contextually accurate.
Discussion
The application demonstrates the feasibility of using transformer models to summarize legal documents. However, BART was not specifically trained on legal texts, which can affect the nuanced understanding the domain requires. Future work involves fine-tuning the model on a dedicated legal corpus to sharpen accuracy.
Limitations
- Model limitations. Summaries may omit critical legal nuances.
- Text length.Documents that exceed the model’s maximum token limit require additional preprocessing.
- Audio quality. gTTS depends on internet connectivity and can mispronounce legal terminology.
Future work
- Model enhancement. Fine-tune the transformer on a legal dataset.
- Feature expansion. Multi-language support and extraction of key legal entities.
- User interface. Enhance the web interface for better user experience and accessibility.
Conclusion
This project integrates advanced NLP techniques into a user-friendly application for summarizing and narrating legal documents. By streamlining comprehension of complex legal texts, the tool holds significant potential for both educational and professional use.
References
- Lewis, M., Liu, Y., Goyal, N., et al. (2019). BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension. arXiv:1910.13461
- Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv:1810.04805
- Klein, G., Kim, Y., Deng, Y., et al. (2017). OpenNMT: Open-Source Toolkit for Neural Machine Translation. arXiv:1701.02810