This application captures a specified region of your screen, performs Optical Character Recognition (OCR) on it, and translates any recognized text into English. It is designed to translate in-game chat from Dota 2 in real-time.
This version uses a hybrid approach:
- Local OCR: Text recognition is handled locally using the Tesseract OCR engine. This is fast, free, and has no usage limits.
- Cloud Translation: The recognized text is translated using the Google Cloud Translation API to ensure high-quality translations.
There are three main steps to get the application running: installing Tesseract, setting up the Python environment, and configuring Google Cloud.
This application depends on Tesseract OCR engine. You must install it on your system.
- Platform: Windows
- Installer: You can find the official Tesseract installers from the University of Mannheim.
- Instructions:
- Download and run the installer for your system (e.g.,
tesseract-ocr-w64-setup-v5.x.x.exe). - Important: During installation, make sure to select the language packs for the languages you expect to encounter. At a minimum, for Dota 2 it is recommended to install:
- English (
eng) - Russian (
rus) - Spanish (
spa) - Portuguese (
por) - Simplified Chinese (
chi_sim)
- English (
- Note the installation path. The default is usually
C:\Program Files\Tesseract-OCR. If you install it here, the application should find it automatically. If you choose a different path, you may need to editocr_service.pyand set the path manually at the top of the file.
- Download and run the installer for your system (e.g.,
Clone this repository and install the required Python packages.
# Clone the repository
git clone <repository-url>
cd Dota2ChatTranslater
# It is recommended to use a virtual environment
python -m venv venv
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtSince translation is handled by Google Cloud, you still need a Google Cloud Project to use the Translation API.
- Create a Google Cloud Project: Follow the instructions on the Google Cloud Console.
- Enable the "Cloud Translation API": In your project, go to the API Library and enable it.
- Create Credentials:
- Go to "Credentials" in the "APIs & Services" section.
- Create a new credential of type "OAuth 2.0 Client ID".
- Select "Desktop app" as the application type.
- Download the JSON file containing your credentials.
- Place Credentials File: Rename the downloaded file to
client_secret.jsonand place it in the root directory of this project. - Set Project ID:
- Run the application.
- Go to
Settings -> Google Cloud. - Paste your Google Cloud Project ID into the entry box and click "Save Project ID".
SECURITY WARNING: The client_secret.json file contains credentials for your Google Cloud Project. NEVER commit this file to a public version control repository (like GitHub). Always ensure it's listed in your .gitignore to prevent accidental exposure.
Execute the run.bat script or run the main python file:
python main.py- Authorize Google Cloud: On first run (or after saving a new Project ID), click the "Authorize" button in the Settings menu. This will open a browser window asking you to log in with your Google account and grant permission.
- Select Chat Region:
- In the app's settings, click "Select Region".
- Your screen will dim. Click and drag to draw a box around the area where chat messages appear in Dota 2.
- Translate:
- Once the region is set and Google Cloud is authorized, you can press your configured hotkey (default is
<f8>) to capture the chat region. - The application will process the image, and any translated text will appear in the main window.
- Once the region is set and Google Cloud is authorized, you can press your configured hotkey (default is
- Settings: You can change the hotkey, theme, and text font size from the Settings menu.