File size: 1,228 Bytes
1c0dfed
 
 
54a8795
e4c5728
75ab782
e4c5728
75ab782
 
 
e4c5728
75ab782
 
 
e4c5728
75ab782
 
 
aab3008
75ab782
 
c1410e2
e4c5728
75ab782
f528470
8602c1b
760f94e
 
 
75ab782
 
 
 
1c0dfed
 
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
import gradio as gr
from transformers import pipeline


def trnslt(text,Language):
  txt_inp = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-tl-en")
  if Language=="Cebuano":
    ceb1 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-ceb")
    out_ceb = gr.Series(txt_inp,ceb1)
    return out_ceb(text)
  elif Language=="Ilocano":
    ilo1 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-ilo")
    out_ilo = gr.Series(txt_inp,ilo1)
    return out_ilo(text)
  elif Language=="Hiligaynon":
    hil1 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-hil")
    out_hil = gr.Series(txt_inp,hil1)
    return out_hil(text)

iface = gr.Interface(
  fn=trnslt, 
  inputs=["text",
  gr.inputs.Radio(["Cebuano","Ilocano","Hiligaynon"],label="Translate to",optional=False)],
  outputs='text',
  examples=[["Magandang Umaga"],["Magandang gabi"],["Masarap ang Adobo"],["Kumusta Ka Na"],["Bumibili si Juan ng  manok"],["Magandang umaga"]],
  live=True,
  theme="seafoam",
  title="Basic Filipino Dialect Translator",
  article="This application uses Helsinki-NLP models models to translate native Tagalog texts to 3 dialects of the Filipino language"
  css=".footer{display:none !important}", 
)

iface.launch()