Spaces:
Build error
Build error
File size: 3,220 Bytes
0746322 | 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | import gradio as gr
# Mapping English to various ancient-style Unicode characters
HIEROGLYPHS = {
'a': 'π', 'b': 'π', 'c': 'π‘', 'd': 'π§', 'e': 'π',
'f': 'π', 'g': 'πΌ', 'h': 'π', 'i': 'π', 'j': 'π',
'k': 'π‘', 'l': 'π', 'm': 'π
', 'n': 'π', 'o': 'π',
'p': 'πͺ', 'q': 'π', 'r': 'π', 's': 'π΄', 't': 'π',
'u': 'π
±', 'v': 'π', 'w': 'π
±', 'x': 'π‘π΄', 'y': 'π',
'z': 'π', ' ': ' '
}
RUNES = {
'a': 'α¨', 'b': 'α', 'c': 'α²', 'd': 'α', 'e': 'α',
'f': 'α ', 'g': 'α·', 'h': 'αΊ', 'i': 'α', 'j': 'α',
'k': 'α²', 'l': 'α', 'm': 'α', 'n': 'αΎ', 'o': 'α',
'p': 'α', 'q': 'α²αΉ', 'r': 'α±', 's': 'α', 't': 'α',
'u': 'α’', 'v': 'αΉ', 'w': 'αΉ', 'x': 'α²α', 'y': 'α',
'z': 'α', ' ': ' α« '
}
CUNEIFORM = {
'a': 'π', 'b': 'π', 'c': 'π', 'd': 'π²', 'e': 'π',
'f': 'π«', 'g': 'π΅', 'h': 'π©', 'i': 'πΏ', 'j': 'π',
'k': 'π ', 'l': 'π·', 'm': 'π ', 'n': 'πΎ', 'o': 'π',
'p': 'πΊ', 'q': 'πͺ', 'r': 'π', 's': 'π', 't': 'π',
'u': 'π', 'v': 'π', 'w': 'πΏ', 'x': 'π', 'y': 'π
',
'z': 'π£', ' ': ' '
}
SCRIPTS = {
"Egyptian Hieroglyphs π": HIEROGLYPHS,
"Elder Futhark Runes α ": RUNES,
"Sumerian Cuneiform π": CUNEIFORM,
}
SCRIPT_INFO = {
"Egyptian Hieroglyphs π": "Egyptian hieroglyphs were used from ~3200 BCE to 400 CE. They are one of the earliest writing systems, combining logographic and alphabetic elements.",
"Elder Futhark Runes α ": "Elder Futhark runes were used by Germanic peoples from the 2nd to 8th centuries CE. Each rune had a name and magical significance.",
"Sumerian Cuneiform π": "Cuneiform is one of the earliest writing systems, developed in Sumer around 3400 BCE. It was written on clay tablets with a reed stylus.",
}
def translate(text, script_name):
if not text:
return "", ""
script = SCRIPTS[script_name]
translated = []
for char in text.lower():
translated.append(script.get(char, char))
result = ''.join(translated)
# Build character breakdown
breakdown = "### Character Breakdown\n\n"
breakdown += "| Latin | Ancient | \n|---|---|\n"
seen = set()
for char in text.lower():
if char not in seen and char in script:
seen.add(char)
breakdown += f"| {char.upper()} | {script[char]} |\n"
info = f"### About {script_name}\n\n{SCRIPT_INFO[script_name]}"
return result, f"{info}\n\n{breakdown}"
demo = gr.Interface(
fn=translate,
inputs=[
gr.Textbox(label="Enter English Text", lines=3,
placeholder="Type something like 'Hello World'..."),
gr.Radio(list(SCRIPTS.keys()), value="Egyptian Hieroglyphs π",
label="Choose Ancient Script"),
],
outputs=[
gr.Textbox(label="Ancient Translation", lines=3),
gr.Markdown(label="Details"),
],
title="π Ancient Script Translator",
description="Convert modern English into ancient writing systems.",
theme=gr.themes.Soft(),
)
if __name__ == "__main__":
demo.launch() |