Skip to content

microsoft/read_for_you

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Read for You

An intelligent PDF reading and recognition system that supports OCR recognition, Text-to-Speech (TTS), and AI conversation features for PDF documents.

License Python Vue Django

🌟 Project Overview

Read for You is a full-stack web application designed to provide users with an intelligent PDF reading experience. The system integrates Azure Document Intelligence for OCR recognition, supports multilingual text extraction, and provides text-to-speech functionality to help users read documents more conveniently.

Core Features

  • πŸ“„ PDF Upload & Management: Support for PDF file upload, preview, and categorized management
  • πŸ” Intelligent OCR Recognition: Document recognition powered by Azure Document Intelligence
  • πŸ—£οΈ Text-to-Speech (TTS): Convert recognized text to speech with multilingual support
  • πŸ€– AI Chat Assistant: Integrated AI chat functionality to assist with document understanding
  • 🌐 Multilingual Support: Support for Chinese, English, and other languages
  • πŸ’Ύ Cloud Storage Integration: File storage using Azure Blob Storage
  • πŸ“± Responsive Design: Optimized for desktop and mobile devices

πŸ—οΈ Technology Stack

Backend Technologies

  • Framework: Django 4.2.16
  • Core Dependencies:
    • django-cors-headers: Cross-origin request handling
    • PyPDF2: PDF file processing
    • azure-storage-blob: Azure Blob Storage integration
    • requests: HTTP request handling
    • python-dotenv: Environment variable management

Frontend Technologies

  • Framework: Vue 3.5+
  • Build Tool: Vite 7.1+
  • Core Dependencies:
    • pdfjs-dist: PDF rendering
    • pdf-lib: PDF manipulation
    • @echogarden/fvad-wasm: Voice activity detection
    • @azure/static-web-apps-cli: Azure Static Web Apps deployment

Cloud Services

  • Azure Document Intelligence: OCR document recognition
  • Azure Blob Storage: File storage
  • Azure App Service: Backend deployment
  • Azure Static Web Apps: Frontend deployment

πŸ“ Project Structure

ReadForYou_Web/
β”œβ”€β”€ backend/                    # Django backend
β”‚   β”œβ”€β”€ manage.py              # Django management script
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   β”œβ”€β”€ db.sqlite3            # SQLite database
β”‚   β”œβ”€β”€ read_for_you/         # Main application
β”‚   β”‚   β”œβ”€β”€ settings.py       # Django settings
β”‚   β”‚   β”œβ”€β”€ urls.py           # URL routing
β”‚   β”‚   β”œβ”€β”€ views.py          # View functions
β”‚   β”‚   β”œβ”€β”€ constants.py      # Constants configuration
β”‚   β”‚   β”œβ”€β”€ Services/         # Service layer
β”‚   β”‚   β”‚   β”œβ”€β”€ AzureBlobService.py    # Azure Blob service
β”‚   β”‚   β”‚   β”œβ”€β”€ PDFService.py          # PDF processing service
β”‚   β”‚   β”‚   β”œβ”€β”€ ProcessingService.py   # Processing service
β”‚   β”‚   β”‚   └── RecognitionServices.py # Recognition service
β”‚   β”‚   └── static/           # Static files
β”‚   └── scripts/              # Utility scripts
β”‚       └── traverse_books.py # Book traversal script
β”‚
└── frontend/                  # Vue frontend
    β”œβ”€β”€ package.json          # Node.js dependencies
    β”œβ”€β”€ vite.config.js        # Vite configuration
    β”œβ”€β”€ index.html            # Entry HTML
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ App.vue           # Main app component
    β”‚   β”œβ”€β”€ main.js           # Application entry
    β”‚   β”œβ”€β”€ constants.js      # Constants configuration
    β”‚   β”œβ”€β”€ components/       # Vue components
    β”‚   β”‚   β”œβ”€β”€ IndexPage.vue      # Home page
    β”‚   β”‚   β”œβ”€β”€ ReadingPage.vue    # Reading page
    β”‚   β”‚   β”œβ”€β”€ TopNav.vue         # Top navigation
    β”‚   β”‚   └── AIChat/            # AI chat components
    β”‚   └── utils/            # Utility functions
    β”‚       β”œβ”€β”€ i18n.js            # Internationalization
    β”‚       β”œβ”€β”€ PDFService.js      # PDF service
    β”‚       β”œβ”€β”€ TTS.js             # TTS service
    β”‚       β”œβ”€β”€ TTSManager.js      # TTS manager
    β”‚       β”œβ”€β”€ TTSPlayer.js       # TTS player
    β”‚       └── IndexedDBService.js # Local storage
    └── public/               # Public resources

πŸš€ Quick Start

Prerequisites

  • Python: 3.9 or higher
  • Node.js: 16.0 or higher
  • npm: 8.0 or higher

Backend Setup

  1. Clone the repository
git clone https://github.com/junyingshao_microsoft/ReadForYou.git
cd ReadForYou_Web/backend
  1. Create virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment variables

Create a .env file and configure the following environment variables:

# Azure Blob Storage
AZURE_STORAGE_CONNECTION_STRING=your_connection_string
AZURE_STORAGE_CONTAINER_NAME=your_container_name

# Azure Document Intelligence
DOCUMENT_INTELLIGENCE_ENDPOINT=your_endpoint
DOCUMENT_INTELLIGENCE_KEY=your_key
  1. Database migration
python manage.py migrate
  1. Run development server
python manage.py runserver

The backend service will start at http://127.0.0.1:8000.

Frontend Setup

  1. Navigate to frontend directory
cd frontend
  1. Install dependencies
npm install
  1. Configure API endpoint

Edit the src/constants.js file to configure the backend API address:

export const API_BASE_URL = 'http://127.0.0.1:8000';
  1. Run development server
npm run dev

The frontend service will start at http://localhost:5173.

  1. Build for production
npm run build

πŸ”§ API Documentation

1. PDF Recognition API

Endpoint: POST /recognition

Description: Upload PDF file and perform OCR recognition

Parameters:

  • file: PDF file (multipart/form-data)
  • pageNum: Page range (e.g., "1-3" or "1,3,5")
  • language: Language code (URL parameter, e.g., "zh-CN")

Response Example:

{
  "status": "success",
  "data": {
    "text": "Recognized text content",
    "pdf": "data:application/pdf;base64,..."
  }
}

2. Get Cover Images

Endpoint: GET /getCoverImages

Description: Get all book cover image URLs

Response Example:

{
  "success": true,
  "count": 10,
  "images": [
    {
      "url": "https://...",
      "name": "book_cover_1.jpg"
    }
  ]
}

3. Get Stored Data

Endpoint: GET /getStoragedData

Description: Retrieve files from Azure Blob Storage

Parameters:

  • prefix: File path prefix
  • type: File type (pdf, jpg, png, etc.)

4. Get Book Metadata

Endpoint: GET /getBookMetadata

Description: Get metadata information for a specific book

Parameters:

  • prefix: Book path prefix

🌐 Deployment

Production Deployment

Backend Deployment (Azure App Service):

Frontend Deployment (Azure Static Web Apps):

  • Build static files using npm run build
  • Deploy via Azure Static Web Apps CLI

Server Information:

πŸ“ Main Modules

PDF Service (PDFService)

  • extractPDF: Extract PDF pages based on page range
  • normalizePageRange: Normalize page range format

Azure Blob Service (AzureBlobService)

  • uploadFile: Upload files to Azure Blob Storage
  • downloadFile: Download files from Azure Blob Storage
  • getAllCoverImages: Get all cover images

Recognition Service (RecognitionServices)

  • Integrated with Azure Document Intelligence API
  • Support for synchronous and asynchronous recognition
  • Multilingual document recognition

Processing Service (ProcessingService)

  • Coordinate PDF processing and recognition workflow
  • Handle formatting and storage of recognition results

🀝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details

πŸ“ž Contact

  • Project Maintainer: junyingshao_microsoft
  • Repository: ReadForYou

πŸ“š Documentation

For more detailed project design documentation, please visit: Read for You Project Design

πŸ™ Acknowledgments

  • Azure Document Intelligence
  • Azure Blob Storage
  • Vue.js Community
  • Django Community

⭐ If this project helps you, please give us a Star!

1

About

read_for_you project from intern junhao.leng

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •