File size: 2,954 Bytes
c4ad893
 
 
 
 
 
 
 
004af27
c4ad893
35f17b0
 
 
 
c4ad893
35f17b0
 
 
 
c4ad893
00bf822
004af27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4ad893
35f17b0
 
c4ad893
004af27
35f17b0
 
004af27
35f17b0
 
 
 
 
 
 
 
 
e98fa1f
35f17b0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import streamlit as st
from transformers import pipeline
import torch

translator = pipeline("translation",
                      model="facebook/nllb-200-distilled-600M",
                      torch_dtype=torch.bfloat16)

#lang = ["Yoruba","Afrikaans", "English"]

# src = st.selectbox(
#            "Select source language",
#            options=lang
#         )

# tgt = st.selectbox(
#            "Select target language",
#            options=lang
#         )

african_languages = { "English" : "eng_Latn",
"Afrikaans": "afr_Latn",
"Bambara": "bam_Latn",
"Basque": "eus_Latn",
"Ewe": "ewe_Latn",
"Fon": "fon_Latn",
"Fula": "fuv_Latn",
"Hausa": "hau_Latn",
"Igbo": "ibo_Latn",
"Kabyle": "kab_Latn",
"Kalenjin": "kal_Latn",
"Kamba": "kam_Latn",
"Kanjobal": "ktz_Latn",
"Kikuyu": "kik_Latn",
"Kinyarwanda": "kin_Latn",
"Komi": "kom_Cyrl",
"Kongo": "kon_Latn",
"Lingala": "lin_Latn",
"Lozi": "loz_Latn",
"Lubumbashi Swahili": "lui_Latn",
"Luo": "luo_Latn",
"Machame Chaga": "cgc_Latn",
"Madurese": "mad_Latn",
"Maore Comorian": "com_Arab",
"Meru": "mer_Latn",
"Mozambican Portuguese": "pcm_Latn",
"Ngomba": "gnb_Latn",
"Nigerian Fulfude": "fuv_Latn",
"North Levelnde Arabic": "apc_Arab",
"Northern Lwo": "lwo_Latn",
"Northern Ndebele": "lin_Latn",
"Northern Sotho": "nso_Latn",
"Northern Wolof": "wol_Latn",
"Nyanja": "nya_Latn",
"Omotic - Benchnon": "bbg_Latn",
"Oromo": "gaz_Latn",
"Piedmontese": "pms_Latn",
"Rombo": "rmb_Latn",
"Runyankore": "run_Latn",
"Rwa": "rwk_Latn",
"Sena": "seh_Latn",
"Setswana": "tsn_Latn",
"Shona": "sna_Latn",
"Silozi": "loz_Latn",
"Somali": "som_Latn",
"Southern Ndebele": "nbl_Latn",
"Southern Sotho": "sot_Latn",
"Sudanese Colloquial Arabic": "apd_Arab",
"Swazi": "ssw_Latn",
"Swahili": "swh_Latn",
"Tachelhit": "shi_Tfng",
"Taita": "dtp_Latn",
"Tamasheq (Latin script)": "taq_Latn",
"Tigrigna": "tir_Ethi",
"Tswana": "tsn_Latn",
"Tumbuka": "tum_Latn",
"Tutong Murut": "ttm_Latn",
"Twii": "twi_Latn",
"Umbundu": "umb_Latn",
"Venda": "ven_Latn",
"Walloon": "wln_Latn",
"Wolof": "wol_Latn",
"Xitsonga": "tso_Latn",
"Yoruba": "yor_Latn",
"Zaramo": "zmw_Latn",
"Zulu": "zul_Latn",
}

lang = list(african_languages.keys())


st.header('African Languages Translator', divider='rainbow')



#input_text = st.text_input("Enter text to be translated")
#translated_text = translator(input_text, src_lang= lang_dict[src], tgt_lang= lang_dict[tgt])[0]["translation_text"]

translated_text = translator(st.text_input("Enter text to be translated"), src_lang= african_languages[st.selectbox(
            "Select source language",
            options=lang
      )], tgt_lang= african_languages[st.selectbox(
            "Select target language",
            options=lang
       )])[0]["translation_text"]

if st.button('Translate'):
    st.write("Translated Text:", translated_text)


# if input_text and src and tgt and st.button('Translate'):
    
#     st.write("Translated Text:", translated_text)
#     #st.text(translated_text)