Spaces:
Sleeping
Sleeping
AreesaAshfaq
commited on
Commit
•
ae981e1
1
Parent(s):
06ccd11
Update app.py
Browse files
app.py
CHANGED
@@ -19,9 +19,8 @@ language_codes = {
|
|
19 |
def translate_text(text, target_lang_code):
|
20 |
# Prepare the input and translate
|
21 |
inputs = tokenizer.encode(text, return_tensors="pt")
|
22 |
-
#
|
23 |
-
|
24 |
-
translated = model.generate(inputs, decoder_start_token_id=decoder_start_token_id)
|
25 |
translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
26 |
return translated_text
|
27 |
|
|
|
19 |
def translate_text(text, target_lang_code):
|
20 |
# Prepare the input and translate
|
21 |
inputs = tokenizer.encode(text, return_tensors="pt")
|
22 |
+
# Generate the translation
|
23 |
+
translated = model.generate(inputs, decoder_start_token_id=tokenizer.get_lang_id(target_lang_code))
|
|
|
24 |
translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
25 |
return translated_text
|
26 |
|