Spaces:
Runtime error
Runtime error
File size: 1,323 Bytes
6954df4 905bb30 6954df4 3e9b5c9 6954df4 3e9b5c9 6954df4 3e9b5c9 6954df4 3e9b5c9 6954df4 905bb30 6954df4 905bb30 6954df4 bf87ba6 905bb30 6954df4 905bb30 |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import gradio as gr
# # Define a list of word and translation pairs
word_translations = [
{
"word": "Hello",
"image_url": "https://example.com/image1.jpg",
"translation": "Hola",
"link": "https://www.google.com/"
},
{
"word": "World",
"image_url": "https://example.com/image2.jpg",
"translation": "Mundo",
"link": "https://en.wikipedia.org/wiki/World"
},
{
"word": "Goodbye",
"image_url": "https://example.com/image3.jpg",
"translation": "Adiós",
"link": "https://en.wikipedia.org/wiki/Bat"
}
]
# 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']}<br>Translation: {word_translation['translation']} <iframe src='{item['link']}' width=\'100%\' height=\'500px\'></iframe>"
# 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()
|