CoolFace
Apppublic

Alpha108/GenerativeEngineOptimization

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
lang_utils.py16 linesDownload Raw Back to utils
1# utils/lang_utils.py2from langdetect import detect3from deep_translator import GoogleTranslator4 5def detect_language(text: str) -> str:6    try:7        return detect(text)8    except Exception:9        return "unknown"10 11def translate_text(text: str, target_lang: str = "en") -> str:12    try:13        return GoogleTranslator(source='auto', target=target_lang).translate(text)14    except Exception as e:15        return f"Translation failed: {e}"16