Akhil Koduri commited on
Commit
fb6d766
1 Parent(s): eb83112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +196 -14
app.py CHANGED
@@ -6,18 +6,200 @@ text_translator = pipeline("translation", model="facebook/nllb-200-distilled-600
6
 
7
  # Dictionary mapping destination languages to their FLORES-200 codes
8
  language_mapping = {
9
- "German": "de_DE",
10
- "Eastern Panjabi": "pa_IN",
11
- "Sanskrit": "sa_IN",
12
- "Urdu": "ur",
13
- "Tamil": "ta",
14
- "Telugu": "te",
15
- "Yue Chinese": "zh_yue",
16
- "Chinese (Simplified)": "zh",
17
- "Chinese (Traditional)": "zh",
18
- "Hindi": "hi",
19
- "French": "fr",
20
- "Spanish": "es"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  def translate_text(text, destination_language):
@@ -54,7 +236,7 @@ def translate_text(text, destination_language):
54
 
55
  def main():
56
  # Create Gradio interface
57
- demo = gr.Interface(
58
  fn=translate_text,
59
  inputs=[
60
  gr.Textbox(label="Input text to translate", lines=6, placeholder="Enter text in English..."),
@@ -68,7 +250,7 @@ def main():
68
  )
69
 
70
  # Launch the Gradio interface
71
- demo.launch()
72
 
73
  if __name__ == "__main__":
74
  main()
 
6
 
7
  # Dictionary mapping destination languages to their FLORES-200 codes
8
  language_mapping = {
9
+ "Acehnese (Arabic script)": "ace_Arab",
10
+ "Acehnese (Latin script)": "ace_Latn",
11
+ "Mesopotamian Arabic": "acm_Arab",
12
+ "Ta’izzi-Adeni Arabic": "acq_Arab",
13
+ "Tunisian Arabic": "aeb_Arab",
14
+ "Afrikaans": "afr_Latn",
15
+ "South Levantine Arabic": "ajp_Arab",
16
+ "Akan": "aka_Latn",
17
+ "Amharic": "amh_Ethi",
18
+ "North Levantine Arabic": "apc_Arab",
19
+ "Modern Standard Arabic": "arb_Arab",
20
+ "Modern Standard Arabic (Romanized)": "arb_Latn",
21
+ "Najdi Arabic": "ars_Arab",
22
+ "Moroccan Arabic": "ary_Arab",
23
+ "Egyptian Arabic": "arz_Arab",
24
+ "Assamese": "asm_Beng",
25
+ "Asturian": "ast_Latn",
26
+ "Awadhi": "awa_Deva",
27
+ "Central Aymara": "ayr_Latn",
28
+ "South Azerbaijani": "azb_Arab",
29
+ "North Azerbaijani": "azj_Latn",
30
+ "Bashkir": "bak_Cyrl",
31
+ "Bambara": "bam_Latn",
32
+ "Balinese": "ban_Latn",
33
+ "Belarusian": "bel_Cyrl",
34
+ "Bemba": "bem_Latn",
35
+ "Bengali": "ben_Beng",
36
+ "Bhojpuri": "bho_Deva",
37
+ "Banjar (Arabic script)": "bjn_Arab",
38
+ "Banjar (Latin script)": "bjn_Latn",
39
+ "Standard Tibetan": "bod_Tibt",
40
+ "Bosnian": "bos_Latn",
41
+ "Buginese": "bug_Latn",
42
+ "Bulgarian": "bul_Cyrl",
43
+ "Catalan": "cat_Latn",
44
+ "Cebuano": "ceb_Latn",
45
+ "Czech": "ces_Latn",
46
+ "Chokwe": "cjk_Latn",
47
+ "Central Kurdish": "ckb_Arab",
48
+ "Crimean Tatar": "crh_Latn",
49
+ "Welsh": "cym_Latn",
50
+ "Danish": "dan_Latn",
51
+ "German": "deu_Latn",
52
+ "Southwestern Dinka": "dik_Latn",
53
+ "Dyula": "dyu_Latn",
54
+ "Dzongkha": "dzo_Tibt",
55
+ "Greek": "ell_Grek",
56
+ "English": "eng_Latn",
57
+ "Esperanto": "epo_Latn",
58
+ "Estonian": "est_Latn",
59
+ "Basque": "eus_Latn",
60
+ "Ewe": "ewe_Latn",
61
+ "Faroese": "fao_Latn",
62
+ "Fijian": "fij_Latn",
63
+ "Finnish": "fin_Latn",
64
+ "Fon": "fon_Latn",
65
+ "French": "fra_Latn",
66
+ "Friulian": "fur_Latn",
67
+ "Nigerian Fulfulde": "fuv_Latn",
68
+ "Scottish Gaelic": "gla_Latn",
69
+ "Irish": "gle_Latn",
70
+ "Galician": "glg_Latn",
71
+ "Guarani": "grn_Latn",
72
+ "Gujarati": "guj_Gujr",
73
+ "Haitian Creole": "hat_Latn",
74
+ "Hausa": "hau_Latn",
75
+ "Hebrew": "heb_Hebr",
76
+ "Hindi": "hin_Deva",
77
+ "Chhattisgarhi": "hne_Deva",
78
+ "Croatian": "hrv_Latn",
79
+ "Hungarian": "hun_Latn",
80
+ "Armenian": "hye_Armn",
81
+ "Igbo": "ibo_Latn",
82
+ "Ilocano": "ilo_Latn",
83
+ "Indonesian": "ind_Latn",
84
+ "Icelandic": "isl_Latn",
85
+ "Italian": "ita_Latn",
86
+ "Javanese": "jav_Latn",
87
+ "Japanese": "jpn_Jpan",
88
+ "Kabyle": "kab_Latn",
89
+ "Jingpho": "kac_Latn",
90
+ "Kamba": "kam_Latn",
91
+ "Kannada": "kan_Knda",
92
+ "Kashmiri (Arabic script)": "kas_Arab",
93
+ "Kashmiri (Devanagari script)": "kas_Deva",
94
+ "Georgian": "kat_Geor",
95
+ "Central Kanuri (Arabic script)": "knc_Arab",
96
+ "Central Kanuri (Latin script)": "knc_Latn",
97
+ "Kazakh": "kaz_Cyrl",
98
+ "Kabiyè": "kbp_Latn",
99
+ "Kabuverdianu": "kea_Latn",
100
+ "Khmer": "khm_Khmr",
101
+ "Kikuyu": "kik_Latn",
102
+ "Kinyarwanda": "kin_Latn",
103
+ "Kyrgyz": "kir_Cyrl",
104
+ "Kimbundu": "kmb_Latn",
105
+ "Northern Kurdish": "kmr_Latn",
106
+ "Kikongo": "kon_Latn",
107
+ "Korean": "kor_Hang",
108
+ "Lao": "lao_Laoo",
109
+ "Ligurian": "lij_Latn",
110
+ "Limburgish": "lim_Latn",
111
+ "Lingala": "lin_Latn",
112
+ "Lithuanian": "lit_Latn",
113
+ "Lombard": "lmo_Latn",
114
+ "Latgalian": "ltg_Latn",
115
+ "Luxembourgish": "ltz_Latn",
116
+ "Luba-Kasai": "lua_Latn",
117
+ "Ganda": "lug_Latn",
118
+ "Luo": "luo_Latn",
119
+ "Mizo": "lus_Latn",
120
+ "Standard Latvian": "lvs_Latn",
121
+ "Magahi": "mag_Deva",
122
+ "Maithili": "mai_Deva",
123
+ "Malayalam": "mal_Mlym",
124
+ "Marathi": "mar_Deva",
125
+ "Minangkabau (Arabic script)": "min_Arab",
126
+ "Minangkabau (Latin script)": "min_Latn",
127
+ "Macedonian": "mkd_Cyrl",
128
+ "Plateau Malagasy": "plt_Latn",
129
+ "Maltese": "mlt_Latn",
130
+ "Meitei (Bengali script)": "mni_Beng",
131
+ "Halh Mongolian": "khk_Cyrl",
132
+ "Mossi": "mos_Latn",
133
+ "Maori": "mri_Latn",
134
+ "Burmese": "mya_Mymr",
135
+ "Dutch": "nld_Latn",
136
+ "Norwegian Nynorsk": "nno_Latn",
137
+ "Norwegian Bokmål": "nob_Latn",
138
+ "Nepali": "npi_Deva",
139
+ "Northern Sotho": "nso_Latn",
140
+ "Nuer": "nus_Latn",
141
+ "Nyanja": "nya_Latn",
142
+ "Occitan": "oci_Latn",
143
+ "West Central Oromo": "gaz_Latn",
144
+ "Odia": "ory_Orya",
145
+ "Pangasinan": "pag_Latn",
146
+ "Eastern Panjabi": "pan_Guru",
147
+ "Papiamento": "pap_Latn",
148
+ "Western Persian": "pes_Arab",
149
+ "Polish": "pol_Latn",
150
+ "Portuguese": "por_Latn",
151
+ "Dari": "prs_Arab",
152
+ "Southern Pashto": "pbt_Arab",
153
+ "Ayacucho Quechua": "quy_Latn",
154
+ "Romanian": "ron_Latn",
155
+ "Rundi": "run_Latn",
156
+ "Russian": "rus_Cyrl",
157
+ "Sango": "sag_Latn",
158
+ "Sanskrit": "san_Deva",
159
+ "Santali": "sat_Olck",
160
+ "Sicilian": "scn_Latn",
161
+ "Shan": "shn_Mymr",
162
+ "Sinhala": "sin_Sinh",
163
+ "Slovak": "slk_Latn",
164
+ "Slovenian": "slv_Latn",
165
+ "Southern Sotho": "sot_Latn",
166
+ "Albanian": "sqi_Latn",
167
+ "Serbian": "srp_Cyrl",
168
+ "Saraiki": "srk_Arab",
169
+ "Sranan Tongo": "srn_Latn",
170
+ "Southern Uzbek": "suz_Latn",
171
+ "Swedish": "swe_Latn",
172
+ "Swahili": "swa_Latn",
173
+ "Sylheti": "syl_Beng",
174
+ "Central Atlas Tamazight (Arabic script)": "tzm_Arab",
175
+ "Central Atlas Tamazight (Latin script)": "tzm_Latn",
176
+ "Tamil": "tam_Taml",
177
+ "Tatar": "tat_Cyrl",
178
+ "Telugu": "tel_Telu",
179
+ "Teso": "tes_Latn",
180
+ "Tajik": "tgk_Cyrl",
181
+ "Thai": "tha_Thai",
182
+ "Tigrinya": "tir_Ethi",
183
+ "Tongan": "ton_Latn",
184
+ "Turkish": "tur_Latn",
185
+ "Tatar (Cyrillic script)": "tat_Cyrl",
186
+ "Ukrainian": "ukr_Cyrl",
187
+ "Urdu": "urd_Arab",
188
+ "Uyghur": "uig_Arab",
189
+ "Uzbek": "uzb_Cyrl",
190
+ "Venda": "ven_Latn",
191
+ "Vietnamese": "vie_Latn",
192
+ "Volapük": "vol_Latn",
193
+ "Votic": "vot_Latn",
194
+ "Waray": "war_Latn",
195
+ "Wolof": "wol_Latn",
196
+ "Xhosa": "xho_Latn",
197
+ "Mingrelian": "xmf_Geor",
198
+ "Yoruba": "yor_Latn",
199
+ "Zhuang": "zha_Latn",
200
+ "Chinese (Simplified)": "zho_Hans",
201
+ "Traditional Chinese": "zho_Hant",
202
+ "Zulu": "zul_Latn"
203
  }
204
 
205
  def translate_text(text, destination_language):
 
236
 
237
  def main():
238
  # Create Gradio interface
239
+ interface = gr.Interface(
240
  fn=translate_text,
241
  inputs=[
242
  gr.Textbox(label="Input text to translate", lines=6, placeholder="Enter text in English..."),
 
250
  )
251
 
252
  # Launch the Gradio interface
253
+ interface.launch()
254
 
255
  if __name__ == "__main__":
256
  main()