Skip to content

πŸš€ DocuTranslateAI is an advanced AI-driven document translation tool that seamlessly translates DOCX and PDF files into multiple languages using Google Gemini AI. Designed for accurate, efficient, and professional document translation, it ensures context-aware and high-quality output.

Notifications You must be signed in to change notification settings

deedeeharris/AutoDocTranslate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

62 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Document Translator

Streamlit App

This Streamlit application uses Google's Gemini 2.0 Flash model to translate documents from a source language to a target language. It supports .docx files. The app provides a combined translation (showing both source and target text) and a translated-only version, both downloadable as a single ZIP archive.

Features

  • Document Translation: Translates .docx and .pdf documents using the Gemini 2.0 Flash model.
  • Language Support: Supports a wide range of languages for both source and target. See the language selection dropdown in the app for the full list.
  • Summary Generation: Generates a summary of the document in the target language.
  • Combined and Translated-Only Output: Produces two DOCX files:
    • A combined version with a table showing paragraph IDs, source text, and translated text.
    • A translated-only version containing just the translated paragraphs.
  • ZIP Download: Packages both output DOCX files into a single ZIP archive for easy download.
  • Progress Bar: Displays a progress bar during translation using tqdm.
  • Right-to-Left (RTL) Support: Correctly handles RTL languages (e.g., Hebrew, Arabic) in the output DOCX files, including table and paragraph alignment.
  • Error Handling: Includes robust error handling for API issues, invalid API keys, and file processing errors.
  • API Key Management: Securely handles the Gemini API key using Streamlit secrets (or an optional input field).
  • Streamlit UI: Provides a clean and user-friendly interface built with Streamlit.

Requirements

  • Python 3.9+
  • streamlit
  • google-generativeai
  • python-docx
  • pandas
  • tqdm
  • zipfile (part of the Python standard library)
  • A valid Google Gemini API key.

Installation

  1. Clone the repository:

    git clone https://github.com/deedeeharris/AutoDocTranslate.git
    cd AutoDocTranslate
  2. Create a virtual environment (recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set up your Gemini API Key:

    • Recommended: Using Streamlit Secrets:

      • Create a .streamlit/secrets.toml file in your project directory.

      • Add your API key to the secrets.toml file:

        GEMINI_API_KEY = "your-api-key-here"
    • Alternative (Less Secure): Using an Input Field:

      • The application includes an optional text input field in the sidebar where you can enter your API key. This is less secure than using secrets, especially if you deploy your app publicly.
  5. Run the application:

    streamlit run main.py
    

Usage

  1. Upload a Document: Use the "Choose a file" button to upload a .docx file.
  2. Select Languages: Choose the source and target languages from the dropdown menus.
  3. Translate: Click the "Translate" button.
  4. View Progress: A progress bar will show the translation progress.
  5. Download Results: Once the translation is complete, a "Download All Files (ZIP)" button will appear. Click it to download a ZIP archive containing the combined and translated DOCX files.
  6. View Summary: You can view the generated summary in the target language by expanding the "Show Summary in Target Language" section.

requirements.txt

streamlit
google-generativeai
python-docx
pandas
tqdm

Important Notes

  • API Key: You must have a valid Google Gemini API key to use this application. Obtain one from the Google AI Studio.
  • Rate Limits: Be aware of the Gemini API's rate limits. The code includes a 5-second delay between paragraph translations to help avoid exceeding these limits. You may need to adjust this delay depending on your usage and the API's current limits.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to suggest improvements or report bugs.

About

πŸš€ DocuTranslateAI is an advanced AI-driven document translation tool that seamlessly translates DOCX and PDF files into multiple languages using Google Gemini AI. Designed for accurate, efficient, and professional document translation, it ensures context-aware and high-quality output.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages