A newer version of the Gradio SDK is available: 6.12.0
metadata
title: Ese-ui
app_file: app.py
sdk: gradio
sdk_version: 5.32.1
Ese - AI Legal Assistant for Ghana
Ese is an AI-powered legal assistant specialized in Ghanaian laws, featuring voice input, text-to-speech responses, and comprehensive legal document analysis.
Features
- Voice Input: Web Speech API (Chrome/Edge) + Gradio audio fallback (Safari/Mac)
- Text-to-Speech: Edge TTS with African accent options
- Legal Knowledge Base: LightRAG-powered document retrieval
- Multiple Query Modes: Mix, Local, Global, Naive search
- Responsive UI: Clean Gradio interface with speech controls
Installation
- Clone the repository:
git clone <repository-url>
cd ese-all-ui
- Install dependencies:
pip install gradio lightrag-hku openai python-dotenv loguru markdown selectolax edge-tts soundfile numpy
- Set up environment variables:
# Create .env file
OPENAI_API_KEY=your_openai_api_key_here
- Prepare legal documents:
mkdir laws_storage
# Add your legal documents (.txt, .md, .json) to laws_storage/
Usage
- Start the application:
python app.py
Open browser to
http://localhost:7860Voice Input: Click π€ Start Speaking (Chrome/Edge) or use audio recorder (Safari)
Text Input: Type questions directly
Audio Output: Select voice and enable speech output
Query Modes
- Mix (recommended): Combines local and global search
- Local: Specific entities and details
- Global: Broad concepts and themes
- Naive: Simple text matching
Voice Options
- British Female/Male
- US Female/Male
- Nigerian Female/Male
- South African Female/Male
Browser Compatibility
- Chrome/Edge: Full Web Speech API support
- Safari/Firefox: Audio file upload for transcription
- Mobile: Gradio audio recorder
Architecture
- Frontend: Gradio web interface
- RAG Engine: LightRAG with OpenAI embeddings
- LLM: GPT-4o-mini for legal analysis
- TTS: Microsoft Edge TTS
- STT: Web Speech API + file upload fallback
File Structure
βββ app.py # Main Gradio application
βββ laws_storage/ # Legal documents directory
βββ legal_assistant.log # Application logs
βββ README.md
Configuration
Environment variables in .env:
OPENAI_API_KEY=sk-... # Required: OpenAI API key
Legal Document Formats
Supported formats:
.txt- Plain text.md- Markdown.json- Structured data
Documents are automatically processed with legal metadata for better retrieval.
Performance
- Response Time: 2-5 seconds
- Audio Generation: 1-3 seconds
- Knowledge Base: Scales to thousands of documents
- Concurrent Users: Supports multiple sessions
Development
For development mode:
python app.py
# Visit http://localhost:7860 with auto-reload
Add new documents and update:
python app.py --interactive
Limitations
- Requires internet for OpenAI API calls
- Web Speech API needs microphone permissions
- Safari has limited speech recognition support
- Audio files processed locally (no cloud upload)