Giter Site home page Giter Site logo

translator's Introduction

PDF Translator

This projects reads the text content from PDF files, translates it and saves translated text as a formatted PDF file.

Two different translating options can be used:

  1. Google translate python library googletrans (can be installed via pip ). To use this option, use script python translator.py
  2. AWS Translate. This option requires you to have AWS account. You need to obtain the AWS access key and a secret access key and configure them either as environment variables or local files. To use AWS Translate: python aws_translator.py

Additional python packages that are required to install are:

  • PyPDF2
  • reportlab
  • boto3 (AWS Python SDK)

AWS charges:

AWS offer free tier to try out the AWS Translator. Free tier included 2 million characters for 12 months. Please note that after that the charges will occur and AWS will charge $15 per million characters. More info: Click Here for more info

If you get googletrans error, here is how to fix it:

Please note that there was a breaking change for googletrans. If you get error: error in result (AttributeError: 'NoneType' object has no attribute 'group') Then to fix you need to do 2 things:

  1. Change URL to URL_COM = 'translate.googleapis.com'
  2. Install the latest version of Google Translate: pip install googletrans==3.1.0a0 It fixed the issue. More information about the issue: https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group#52456197

How you can translate your own file?

  1. Change language to which you would like to translate to: LANG = "lv" (ln: 19 in translator.py & ln: 13 in aws_translator.py)
  2. Change the file name from file_name = "example.pdf". Raplace example.pdf to match the pdf file name you have. (ln: 61 in translator.py & ln: 59 in aws_translator.py)

translator's People

Contributors

akapne01 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.