Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,16 @@ import tempfile
|
|
27 |
model__name = "Helsinki-NLP/opus-mt-en-hi"
|
28 |
|
29 |
|
30 |
-
|
31 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
32 |
-
model = model.to(device)
|
33 |
|
34 |
|
35 |
model_name = "SweUmaVarsh/m2m100-en-sa-translation"
|
36 |
tokenizer = M2M100Tokenizer.from_pretrained(model_name)
|
37 |
model = M2M100ForConditionalGeneration.from_pretrained(model_name)
|
38 |
|
39 |
-
|
|
|
|
|
40 |
|
41 |
def translate_and_speak(text):
|
42 |
input_text = "en " + text
|
|
|
27 |
model__name = "Helsinki-NLP/opus-mt-en-hi"
|
28 |
|
29 |
|
30 |
+
|
|
|
|
|
31 |
|
32 |
|
33 |
model_name = "SweUmaVarsh/m2m100-en-sa-translation"
|
34 |
tokenizer = M2M100Tokenizer.from_pretrained(model_name)
|
35 |
model = M2M100ForConditionalGeneration.from_pretrained(model_name)
|
36 |
|
37 |
+
# Use GPU if available
|
38 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
39 |
+
model = model.to(device)
|
40 |
|
41 |
def translate_and_speak(text):
|
42 |
input_text = "en " + text
|