import gradio as gr # Function to translate a word into Pig Latin def to_pig_latin(word): # If the word starts with a vowel, add 'way' to the end if word[0].lower() in 'aeiou': return word + "way" # Otherwise, move the first consonant cluster to the end, then add 'ay' else: first_vowel = next((i for i, char in enumerate(word) if char.lower() in 'aeiou'), len(word)) return word[first_vowel:] + word[:first_vowel] + "ay" # Function to translate a sentence into Pig Latin def translate_text(text): words = text.split() pig_latin_words = [to_pig_latin(word) for word in words] return ' '.join(pig_latin_words) # Set up Gradio interface gr.Interface(fn=translate_text, inputs="text", outputs="text", title="Pig Latin Translator").launch()