Download usage.py from datasetsANDmodels/nllb-translator: direct link, hf CLI and curl.
- Browser
- Download file 637 Bytes
-
https://huggingface.co/datasetsANDmodels/nllb-translator/resolve/main/usage.py
- Command line
-
hf download hf://datasetsANDmodels/nllb-translator/usage.py
-
curl -L -o usage.py https://huggingface.co/datasetsANDmodels/nllb-translator/resolve/main/usage.py
637 Bytes
| import sys | |
| import time | |
| sr= sys.argv[1] | |
| tr=sys.argv[2] | |
| from transformers import pipeline | |
| text= "I am callig from the tax office" | |
| #text= "أنا من مكتب الضرائب"#ARB | |
| #text="Sono di ufficio fiscale." #ITA | |
| #text="Aku berhubung dari kantor pajak." #IND | |
| #text="Soy un agente de impuestos."#SPA | |
| #text="Tôi gọi từ văn phòng thuế"#VIE | |
| #text="저는 세금청에서 왔습니다."#KOR | |
| translator = pipeline(task="translation", model="nllb-translator",src_lang=sr,tgt_lang=tr) | |
| translation = translator(text)[0]['translation_text'] | |
| print(translation) | |
| #arb_Arab | |
| #eng_Latn | |
| #ita_Latn | |
| #ind_Latn | |
| #spa_Latn | |
| #vie_Latn | |
| #kor_Hang | |