Skip to content

๐Ÿ”Š This project contains a script for translating text or documents from one language to another using the DeepL API, and a text-to-speech tool for converting translated text to audio using Google Text-to-Speech (gTTS).

License

Notifications You must be signed in to change notification settings

KORINZ/translator-deepl-gtts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Translation and Text-to-Speech Tool

This project contains a script for translating text or documents from one language to another using the DeepL API, and a text-to-speech tool for converting translated text to audio using Google Text-to-Speech (gTTS).

Requirements

  • Python 3.7+
  • deepl Python library
  • vlc Python library
  • gtts Python library

To install the required libraries, run:

pip install deepl vlc gtts

Usage

Translation

The translation script supports translating text, text files, and documents (.pdf, .docx, .pptx). To use the script, follow these steps:

  1. Make sure you have a valid DeepL API key.
  2. Create a config.py file in the same directory as the translation script with the following content:
DEEPL_API_KEY = "your_api_key_here"

Replace your_api_key_here with your actual DeepL API key.

  1. Run the script with the appropriate arguments:
  • For translating text:
python translate.py -t "your_text_here" target_language
  • For translating a text file:
python translate.py -f input_file_path target_language
  • For translating a document:
python translate.py -d input_document_path target_language

Replace target_language with the target language code, e.g., 'sv' for Swedish. You can also optionally specify the source language with -s source_language.

To see the full list of supported arguments, run:

python translate.py --help

Text-to-Speech

The text-to-speech script converts a given text to audio and plays it using the vlc library. To use the script, simply run:

python text_to_speech.py

The example text is hardcoded in the script. You can replace it with your desired text and language.

Example

Here's an example of using both the translation and text-to-speech scripts together:

  1. Translate a Japanese text to Swedish:
python translate.py -t "your_japanese_text_here" sv
  1. Pass the translated text to the text-to-speech script:
python text_to_speech.py

Make sure to replace the hardcoded text and language in the text_to_speech.py script with your translated text and target language.

License

This project is released under the MIT License.

About

๐Ÿ”Š This project contains a script for translating text or documents from one language to another using the DeepL API, and a text-to-speech tool for converting translated text to audio using Google Text-to-Speech (gTTS).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages