Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,8 @@ import os
|
|
| 3 |
from fastapi import FastAPI, Request
|
| 4 |
from contextlib import asynccontextmanager
|
| 5 |
from transformers import pipeline
|
| 6 |
-
from langdetect import detect
|
|
|
|
| 7 |
from huggingface_hub import login
|
| 8 |
import socket
|
| 9 |
|
|
@@ -23,7 +24,8 @@ english_generator = pipeline("text-generation", model="distilgpt2")
|
|
| 23 |
# Function to detect language
|
| 24 |
def detect_language(user_input):
|
| 25 |
try:
|
| 26 |
-
|
|
|
|
| 27 |
print(f"Detected language: {lang}")
|
| 28 |
return "hebrew" if lang == "he" else "english" if lang == "en" else "unsupported"
|
| 29 |
except:
|
|
|
|
| 3 |
from fastapi import FastAPI, Request
|
| 4 |
from contextlib import asynccontextmanager
|
| 5 |
from transformers import pipeline
|
| 6 |
+
from langdetect import detect # to change to langid
|
| 7 |
+
import langid
|
| 8 |
from huggingface_hub import login
|
| 9 |
import socket
|
| 10 |
|
|
|
|
| 24 |
# Function to detect language
|
| 25 |
def detect_language(user_input):
|
| 26 |
try:
|
| 27 |
+
# lang = detect(user_input)
|
| 28 |
+
lang = langid.classify(user_input)
|
| 29 |
print(f"Detected language: {lang}")
|
| 30 |
return "hebrew" if lang == "he" else "english" if lang == "en" else "unsupported"
|
| 31 |
except:
|