Skip to content

mkahn5/translate-book

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

Translate a book with Google Cloud Translate API

Overview:

This script takes a text file input and by a specified delimiter (ex: ‘.’ and ‘\n’) sends the text to Google Cloud Translate API, stores translated text in memory and after the text file has been completed assembles the translated text file into an output file.

Tqdm is used to display the progress of the translation job.

Before attempting this aware of the following:

Requirements:

  • Python3
  • Google Cloud pip package
  • Google Cloud Platform Service Account key in json
  • Input file must be in .txt, so if your source is in pdf you'll need to convert

Configure your environment:

Download service account credentials and rename project-name-xxxxxx.json file to creds.json in same folder as translate-client.py.

sudo python -m pip install google-cloud --ignore-installed

Language Codes

To run:

python3 translate-client.py input.txt output.txt

$ python3 translate-client.py book.txt book-translated-2.txt
Input Text Loop: |####------| 415/1029  40% [elapsed: 08:09 left: 12:04,  0.85 iters/sec]

Special thanks to Ashish for assisting with the code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages