CoolFace
Apppublic

AItool/EU_Euskera_Translator

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
language_detection.py13 linesDownload Raw Back to root
1import pycld2 as cld2
2from langdetect import detect
3
4def detect_language(input_text):
5    if not input_text:
6        return "unknown"
7    _, _, details = cld2.detect(input_text)
8    detected_language = details[0][0].lower()
9    if detected_language == "unknown":
10        language_code = detect(input_text)
11        return language_code
12    else:
13        return detected_language