Auto translate all languages to english
This repository contains a custom node for ComfyUI that allows you to translate any input language into English, enabling seamless processing through ComfyUI. With this node, users can input text in any language, and it will be automatically translated to English before being passed to ComfyUI for further processing.
To install this node for use with ComfyUI, follow the steps below:
Navigate to the directory where the custom node is located:
cd custom_nodes\ComfyUI-Translator
Install the required dependencies using the embedded Python in ComfyUI:
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt
The installation process will install the necessary packages such as deep_translator
and langdetect
, which are required for the translation functionality.
The script relies on the following Python packages:
You can find these dependencies listed in the requirements.txt
file, and they will be installed automatically during the installation process.
langdetect
package.deep_translator
package.traceback
to log the error and proceed gracefully.from deep_translator import GoogleTranslator
from langdetect import detect
import traceback
def translate_input(text):
try:
# Detect the language of the input text
detected_language = detect(text)
print(f"Detected language: {detected_language}")
# Translate the text to English
translated_text = GoogleTranslator(source='auto', target='en').translate(text)
print(f"Translated text: {translated_text}")
return translated_text
except Exception as e:
print("An error occurred during translation:")
traceback.print_exc()
return text # Return the original text in case of failure
This example demonstrates how the node detects and translates input language, handling errors if something goes wrong.
Once installed, this node can be used within ComfyUI to allow inputs in various languages. When a non-English input is provided, it will be translated to English and then passed on for further processing by ComfyUI's workflow.
Contributions are welcome! If you would like to contribute to the development of this node, feel free to open a pull request or submit issues for bug reports or feature requests.
This project is licensed under the MIT License. See the LICENSE file for more details.