Spaces:
Sleeping
Sleeping
import gradio as gr | |
from src.translation.translate import translate | |
LANGS = ["arabic", "english"] # Define a list of supported languages | |
if __name__ == "__main__": | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=translate, # Specify the translation function as the main function | |
inputs=[ | |
gr.components.Textbox(label="Text"), # Add a textbox input for entering text | |
gr.components.Dropdown(label="Source Language", choices=LANGS), # Add a dropdown for selecting source language | |
gr.components.Dropdown(label="Target Language", choices=LANGS), # Add a dropdown for selecting target language | |
], | |
outputs=["text"], # Define the output type as text | |
examples=[["I'm ready", "english", "arabic"]], # Provide an example input for demonstration | |
cache_examples=False, # Disable caching of examples | |
title="arabic2english", # Set the title of the interface | |
description="This is a translator app for arabic and english. Currently supports only english to arabic." # Add a description of the interface | |
) | |
# Launch the interface | |
iface.launch(share=True) # Launch the interface and enable sharing |