Skip to content

r1Way/translator_qt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English to Chinese Translator Logo

English to Chinese Translator

An English to Chinese translation tool based on llama.cpp, supporting text input translation and screen capture OCR translation functionality, using CPU for inference

中文

Project Structure

  • llama/ - Contains llama.cpp library files (.dll, .lib) and header files
    • Version: llama.cpp git hash version 9e10bd2ea
  • tessdata/ - Contains Tesseract OCR data files
    • Includes: chi_sim.traineddata (Chinese), eng.traineddata (English)
  • resource_icon/ - Application icon resources
    • Includes: nail.svg (pin icon, provided by Alibaba Cloud Icon)
  • Source code files:
    • widget.cpp - Main interface and core functionality implementation
    • configmanager.cpp - Configuration management
    • screencapture.cpp - Screen capture functionality
    • settingsdialog.cpp - Settings dialog

Technology Stack

  • Compilation Toolchain: MSVC (Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35207.1 for x86, corresponding to Visual Studio 2022 version 17.4)
  • Operating System: Windows 11
  • C++ Library Management: vcpkg
  • OCR Engine: Tesseract 5.5.2
    • Dependencies:
      • Leptonica 1.87.0 (required image processing library for Tesseract)
  • AI Model: Tencent Tencent-HY-MT1.5 (specifically HY-MT1.5-1.8B-GGUF, model file size approximately 2G)

Features

  1. Text Translation: Input English text to get Chinese translation
  2. Real-time Translation: Automatically triggers translation after input stops
  3. Screen Capture OCR: Capture screen area, automatically recognize text and translate
  4. Global Hotkey: Support setting global hotkey to quickly start OCR functionality
  5. Window Stay-on-Top: Can keep the window on top
  6. Configuration Management: Support custom model path, hotkey and other settings

System Requirements

  • Memory: At least 8GB RAM (CPU inference)

Inference Performance

Taking one of my tests as an example, performance reference using CPU inference:

First Inference

  • First Token Time: 3999.03 ms
  • Total Generated Tokens: 29
  • Average Throughput: 13.9494 tokens/sec
  • Average Time per Token: 69.2159 ms

Subsequent Inferences

  • First Token Time: 1233.4 ms
  • Total Generated Tokens: 37
  • Average Throughput: 19.1257 tokens/sec
  • Average Time per Token: 50.8727 ms

Quick Start

  1. Ensure Visual Studio 2022 17.4 or higher is installed
  2. Install necessary dependencies using vcpkg
  3. Compile the project
  4. Run the generated executable
  5. Configure model path in settings

Developer Notes

For developers, please note the following path configurations:

  • vcpkg path in CMakeLists.txt: Need to modify to your local installation path for tesseract and other packages (I used absolute paths)
  • ggml related library and header file paths: Please modify the corresponding path configurations according to your actual installation location

Usage Instructions

  1. Text Translation: Enter English text in the input box, the system will automatically translate or click the "Translate" button to manually trigger
  2. OCR Translation: Use the global hotkey (default is Ctrl+Shift+O) to start screen capture, select the area to be recognized, the system will automatically recognize text and translate
  3. Settings: Click the "Settings" button to configure model path, hotkey and other options

Notes

  • The first run requires loading the model, which may have a longer initialization time
  • OCR functionality depends on the training data in the tessdata folder
  • Translation quality depends on the quality of the model used

License

This project is open source under the Tencent HY Community License Agreement.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors