Spaces:
Sleeping
Sleeping
File size: 2,023 Bytes
7a80877 985775e 7a80877 985775e 7a80877 985775e 1de08b2 eaf779a 1de08b2 985775e |
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 |
# app.py ββ Streamlit front-end for 3-10-year-olds
# Drop this file into your Hugging Face Space root.
import streamlit as st
from func import img2text, text2story, story2audio # our back-end utilities
st.set_page_config(
page_title="Magic Story Maker",
page_icon="π§Έ",
layout="centered"
)
# ------------- UI -------------
st.markdown(
"""
<h1 style='text-align:center; color:#ff914d;'>πΌοΈ β π β π</h1>
<h2 style='text-align:center; color:#ffcc00;'>Turn your picture into a talking story!</h2>
""",
unsafe_allow_html=True
)
uploaded = st.file_uploader(
"π **Choose a colourful picture (JPG / PNG)**",
type=["jpg", "jpeg", "png"],
accept_multiple_files=False
)
if uploaded:
st.image(uploaded, caption="Nice choice!", use_column_width=True)
with st.spinner("π Looking at your picture..."):
caption = img2text(uploaded) # β picture β caption
st.success("Here's what I see:")
st.markdown(f"> **_{caption}_**")
with st.spinner("πͺ Writing a fun story..."):
story = text2story(caption) # β‘ caption β story
st.success("Story ready! Read along below:")
st.markdown(
f"""
<div style="
padding:1rem; /* comfy spacing */
border-radius:10px; /* soft rounded corners */
font-size:20px; /* kid-friendly large text */
line-height:1.6; /* more breathing room */
color:#000000; /* fixed dark font β visible on any theme */
">
{story}
</div>
""",
unsafe_allow_html=True
)
with st.spinner("π€ Recording the story..."):
wav_path = story2audio(story) # β’ story β audio
st.audio(wav_path, format="audio/wav")
st.balloons()
else:
st.markdown(
"<p style='text-align:center; font-size:18px;'>"
"Upload a picture and let's make some magic!</p>",
unsafe_allow_html=True
)
|