thak123's picture
Update app.py
cbf082a
raw
history blame
3.85 kB
import gradio as gr
# # Define a list of word and translation pairs
word_translations = [
{"word":"kupovati",
"image_url":"",
"translation":"buy",
"link":"https://sh.wiktionary.org/wiki/kupovati"
},
{"word":"misliti",
"image_url":"",
"translation":"to think",
"link":"https://sh.wiktionary.org/wiki/misliti"
},
{"word":"sjediti",
"image_url":"",
"translation":"sit",
"link":"https://sh.wiktionary.org/wiki/sjediti"
},
{"word":"jesti",
"image_url":"",
"translation":"to eat",
"link":"https://sh.wiktionary.org/wiki/jesti"
},
{"word":"biti",
"image_url":"",
"translation":"be",
"link":"https://sh.wiktionary.org/wiki/biti"
},
{"word":"voziti se",
"image_url":"",
"translation":"to drive",
"link":"https://sh.wiktionary.org/wiki/voziti"
},
{"word":"letjeti",
"image_url":"",
"translation":"fly",
"link":"https://sh.wiktionary.org/wiki/letjeti"
},
{"word":"živjeti",
"image_url":"",
"translation":"to live",
"link":"https://sh.wiktionary.org/wiki/"
},
{"word":"trčati",
"image_url":"",
"translation":"run",
"link":"https://sh.wiktionary.org/wiki/trčati"
},
{"word":"obožavati",
"image_url":"",
"translation":"worship",
"link":"https://sh.wiktionary.org/wiki/obožavati"
},
{"word":"uživati",
"image_url":"",
"translation":"to enjoy",
"link":"https://sh.wiktionary.org/wiki/uživati"
},
{"word":"buditi se",
"image_url":"",
"translation":"Wake up",
"link":"https://sh.wiktionary.org/wiki/buditi"
},
{"word":"skuhati",
"image_url":"",
"translation":"cook",
"link":"https://sh.wiktionary.org/wiki/skuhati"
},
{"word":"slušati",
"image_url":"",
"translation":"listen",
"link":"https://sh.wiktionary.org/wiki/slušati"
},
{"word":"opuštati",
"image_url":"",
"translation":"relax",
"link":"https://sh.wiktionary.org/wiki/opuštati"
},
{"word":"doručkovati",
"image_url":"",
"translation":"have breakfast",
"link":"https://sh.wiktionary.org/wiki/doručkovati"
},
{"word":"ne biti",
"image_url":"",
"translation":"not to be",
"link":"https://sh.wiktionary.org/wiki/biti"
},
{"word":"slaviti",
"image_url":"",
"translation":"celebrate",
"link":"https://sh.wiktionary.org/wiki/slaviti"
},
{"word":"željeti",
"image_url":"",
"translation":"want",
"link":"https://sh.wiktionary.org/wiki/željeti"
},
{
"word":"ne voljeti",
"image_url":"",
"translation":"dislike",
"link":"https://sh.wiktionary.org/wiki/voljeti"
},
# {
# "word": "željeti",
# "image_url": "https://example.com/image1.jpg",
# "translation": "want",
# "link": "https://sh.wiktionary.org/wiki/%C5%BEeljeti"
# },
# {
# "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)
display_html = f"Word: {word_translation['word']}<br>"
display_html += f"Translation: {word_translation['translation']}<br>"
display_html += f"<br><img src='{word_translation['image_url']}' width='200'><br>"
display_html += f"<br><iframe src='{word_translation['link']}' width=\'100%\' height=\'500px\'></iframe>"
return display_html
# Create a Gradio interface
iface = gr.Interface(
fn=display_word,
live=True,
title="Practise Words Croatian Verbs App",
description="Click 'Next' to view the next word and translation.",
inputs=[],
outputs=["html"],
layout="vertical"
)
# Start the Gradio interface
iface.launch()