Update app.py
Browse files
app.py
CHANGED
|
@@ -29,15 +29,15 @@ login(token=HF_HUB_TOKEN)
|
|
| 29 |
|
| 30 |
|
| 31 |
# # Function to detect language
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
|
| 43 |
# Function to generate a response
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
# # Function to detect language
|
| 32 |
+
def detect_language(user_input):
|
| 33 |
+
try:
|
| 34 |
+
# lang = detect(user_input)
|
| 35 |
+
lang, _ = langid.classify(user_input) # langid.classify returns a tuple (language, confidence)
|
| 36 |
+
print(f"Detected language: {lang}, ", f"current time: {current_time_gmt()}")
|
| 37 |
+
return "hebrew" if lang == "he" else "english" if lang == "en" else "unsupported"
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"Language detection error: {e}")
|
| 40 |
+
return "unsupported"
|
| 41 |
|
| 42 |
|
| 43 |
# Function to generate a response
|