File size: 1,218 Bytes
9a4dd2c
 
 
 
b1c38c2
9a4dd2c
 
 
 
b1c38c2
9a4dd2c
b1c38c2
 
 
9a4dd2c
b1c38c2
 
 
 
 
9a4dd2c
 
 
b1c38c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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