LiveTranslator finds and translates texts from images within the region or window using OCR and overlays the translated texts.
- Python, Pip, Pipenv
-
Clone the repository:
git clone <repository-url> cd LiveTranslator
-
Run the environment setup script:
python setup_env.py
-
Install the dependencies:
pipenv install
-
Use the virtual environment:
pipenv shell
-
Exit/Deactivate the virtual environment:
exit
Use the following command to translate text from images:
python3 scripts/main.py translate --src <path_to_image> --print --print-boxes --from <lang> --to <lang> --translator <translator>
--src
(Required): Specify the path to the image file to be translated.--print
(Optional): Print extracted texts to the console.--print-boxes
(Optional): Draw bounding boxes around the detected text in the image.--from
(Optional): Specify the source language for OCR (e.g., "eng", "jpn"). If not specified, it's auto-detected.--to
(Optional): Specify the target language for translation (default is "eng").--show
(Optional): Show the final translated image.--translator
(Optional): Choose the translation service (default is "google"). Options:google
,deepl
.
Use the following command to run the application's GUI:
python3 scripts/main.py gui
The LiveTranslator GUI allows users to capture and translate text from specific windows or regions of their screen. The main features include:
-
Select Capture Mode:
Capture in Intervals
: Capture the selected window/region at regular intervals.Capture and Wait
: Capture the selected window/region once and wait until the translated window is closed.
-
Set Capture Interval:
- Set the interval (in seconds) for capturing the screen in
Capture in Intervals
mode.
- Set the interval (in seconds) for capturing the screen in
-
Select Source and Target Languages:
- Choose from supported languages (e.g., English, Japanese, French) for OCR and translation.
-
Select Capture Type:
Window
: Capture a specific window.Region
: Capture a user-defined region of the screen.
-
Window List:
- Refresh and select from a list of currently open windows for capturing.
-
Region Selection:
- Manually select a region of the screen for capturing and translation.
-
Start and Stop Capture:
- Start capturing the selected window/region and translating the text.
- Stop the capture process.
-
Status Display:
- A status label displays the current state of the capture process, with tooltips for additional information.
Use the following command to run tests:
python3 tests/run_tests.py <modules>
modules
(Optional): Paths to specific test modules or classes. Leaving empty will run all tests-v, --verbosity
(Optional): Verbosity level for test output.- 0: Minimal output
- 1: Normal output (default)
- 2: Detailed output
- 3: Debug-level output
--failfast
(Optional): Stop running tests on the first failure.--buffer
(Optional): Buffer stdout and stderr during test execution.
- If you encounter issues, you can remove the virtual environment and reinstall dependencies:
pipenv --rm pipenv --python 3.9 pipenv install
To translate text from an image using the Google Translator, run:
python3 scripts/main.py translate --src path/to/your/image.png --print --print-boxes --from eng --to jpn --translator google --show
To run the application GUI, use:
python3 scripts/main.py gui