Ese-ui / README.md
Daniel-B's picture
Upload folder using huggingface_hub
3745774 verified

A newer version of the Gradio SDK is available: 6.12.0

Upgrade
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

  1. Clone the repository:
git clone <repository-url>
cd ese-all-ui
  1. Install dependencies:
pip install gradio lightrag-hku openai python-dotenv loguru markdown selectolax edge-tts soundfile numpy
  1. Set up environment variables:
# Create .env file
OPENAI_API_KEY=your_openai_api_key_here
  1. Prepare legal documents:
mkdir laws_storage
# Add your legal documents (.txt, .md, .json) to laws_storage/

Usage

  1. Start the application:
python app.py
  1. Open browser to http://localhost:7860

  2. Voice Input: Click 🎀 Start Speaking (Chrome/Edge) or use audio recorder (Safari)

  3. Text Input: Type questions directly

  4. 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)