Skip to content

πŸ“– A blazing tool for book translations, powered by local LLM. Translates your books and documents with impressive quality using a unique two-stage approach.

License

Notifications You must be signed in to change notification settings

KazKozDev/book-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Book Translator

Book Translator

Python 3.7+ License: MIT Flask React Tailwind CSS PRs Welcome

Book Translator is a powerful application for translating books and large text documents (.txt files) between multiple languages using a two-stage translation process: Google Translate for initial translation and Ollama AI models for literary refinement. It works with plain text format only and combines a Flask backend with a React frontend to provide a smooth and efficient translation experience.

Key Features

  • πŸ”„ Two-stage translation process:
    • Stage 1: Fast initial translation using Google Translate
    • Stage 2: Literary refinement using Ollama AI models
  • 🌍 Support for multiple languages including English, Russian, German, French, Spanish, Italian, Chinese, and Japanese
  • πŸ€– Integration with Ollama AI models for high-quality refinements
  • πŸš€ Real-time translation progress tracking for both stages
  • πŸ“š Translation history and status monitoring
  • πŸ’Ύ Efficient caching system for improved performance
  • πŸ”„ Automatic error recovery and retry mechanisms
  • πŸ“Š Real-time metrics and system monitoring
  • πŸ“± Modern, responsive UI with React and Tailwind CSS

Demo

Experience the translation process in modern, user-friendly interface:

Book Translator Demo

Translation Process

The application uses a sophisticated two-stage translation approach:

Stage 1: Initial Translation

  • Uses Google Translate API for fast initial translation
  • Handles large volumes of text efficiently
  • Provides basic translation quality
  • Progress tracking for initial translation stage

Stage 2: Literary Refinement

  • Uses Ollama AI models to refine the initial translation
  • Improves literary quality and natural language flow
  • Maintains context and style
  • Separate progress tracking for refinement stage

Prerequisites

  • Python 3.7+
  • Ollama installed and running
  • Node.js (for development)

Quick Start

  1. Clone the repository
git clone https://github.com/kazkozdev/book-translator.git
cd book-translator
  1. Install dependencies
pip install -r requirements.txt
  1. Pull required Ollama model
ollama pull gemma2:27b
  1. Start the application
python translator.py
  1. Access the application
  • Open http://localhost:5001 in your browser

Architecture

book-translator/
β”œβ”€β”€ translator.py        # Flask backend
β”œβ”€β”€ static/             # Frontend files
β”œβ”€β”€ uploads/            # Temporary uploads
β”œβ”€β”€ translations/       # Completed translations
β”œβ”€β”€ logs/              # Application logs
β”œβ”€β”€ translations.db     # Main database
└── cache.db           # Cache database

API Reference

Translation Endpoints

  • POST /translate - Start translation process (both stages)
  • GET /translations - Get history
  • GET /translations/<id> - Get translation details including stage progress
  • GET /download/<id> - Download refined translation
  • POST /retry-translation/<id> - Retry failed translation

System Endpoints

  • GET /models - List available Ollama models
  • GET /metrics - System metrics
  • GET /health - Service health check
  • GET /failed-translations - List failed translations

Contributing

We welcome contributions! Here's how:

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

License

MIT License - see LICENSE file


Made with ❀️
⭐ Star us on GitHub!

About

πŸ“– A blazing tool for book translations, powered by local LLM. Translates your books and documents with impressive quality using a unique two-stage approach.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published