import gradio as gr # Define a list of word and translation pairs word_translations = [ {"word": "Hello", "translation": "Hola"}, {"word": "Goodbye", "translation": "AdiĆ³s"}, {"word": "Thank you", "translation": "Gracias"}, {"word": "Please", "translation": "Por favor"} ] # Initialize an index to keep track of the current word current_index = 0 # Function to display the current word and translation def display_word(): global current_index word_translation = word_translations[current_index] current_index = (current_index + 1) % len(word_translations) return f"Word: {word_translation['word']}
Translation: {word_translation['translation']}" # Create a Gradio interface iface = gr.Interface( fn=display_word, live=True, title="Word Translation App", description="Click 'Next' to view the next word and translation.", inputs=[], outputs=["html"], layout="vertical" ) # Start the Gradio interface iface.launch()