File size: 3,584 Bytes
cc8640e
0a48ded
cc8640e
0a48ded
cc8640e
 
 
 
 
 
 
 
 
 
 
0a48ded
 
74fa26b
 
 
 
 
 
 
cc8640e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f445518
 
cc8640e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f445518
 
 
 
cc8640e
 
 
 
 
 
 
0a48ded
cc8640e
0a48ded
74fa26b
 
 
 
 
cc8640e
 
 
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
86
87
88
89
90
91
92
import streamlit as st
import pyttsx3
from transformers import pipeline
from PIL import Image, ImageDraw

# Set up the app
st.set_page_config(page_title="ChiliDron", layout="wide", page_icon="🎨")

# Load Hugging Face models using cache
@st.cache_resource
def load_storytelling_model():
    return pipeline("text-generation", model="gpt2")

# Load models
story_generator = load_storytelling_model()

# Initialize TTS engine
def initialize_tts():
    try:
        engine = pyttsx3.init()
        return engine
    except Exception as e:
        st.error(f"Error initializing text-to-speech engine: {e}")
        return None

# App title and description
st.title("ChiliDron")
st.subheader("A fun, interactive, and educational app for kids!")

# Sidebar navigation
st.sidebar.title("Navigate")
options = st.sidebar.radio("Go to", ["Interactive Storyteller", "Digital Art Studio", "Guided Meditation"])

# Interactive Storyteller
if options == "Interactive Storyteller":
    st.header("πŸ“ Interactive Storyteller")
    st.write("Create your own story by selecting characters and plot points!")

    character = st.selectbox("Choose a character:", ["A Brave Knight", "A Clever Princess", "A Funny Alien", "A Curious Scientist"])
    setting = st.selectbox("Choose a setting:", ["In a magical forest", "On a distant planet", "In an ancient castle", "At a science lab"])
    plot = st.selectbox("Choose a plot point:", ["Finds a mysterious map", "Discovers a secret passage", "Meets a talking animal", "Invents a cool gadget"])

    if st.button("Create Story"):
        with st.spinner("Generating your story..."):
            prompt = f"Once upon a time, {character} was {setting} when they {plot}. And then,"
            story = story_generator(prompt, max_length=200, num_return_sequences=1)
            st.success(story[0]['generated_text'])

# Digital Art Studio
# Digital Art Studio
if options == "Digital Art Studio":
    st.header("🎨 Digital Art Studio")
    st.write("Draw and create your own masterpiece!")

    # Simple canvas with PIL
    width, height = 400, 400
    canvas = Image.new('RGB', (width, height), (255, 255, 255))
    draw = ImageDraw.Draw(canvas)

    # Draw instructions
    st.write("Use the input boxes below to draw on the canvas (x, y coordinates and color)")

    # Input fields for drawing
    x = st.number_input("X Coordinate", min_value=0, max_value=width-1, step=1)
    y = st.number_input("Y Coordinate", min_value=0, max_value=height-1, step=1)
    color = st.color_picker("Pick a color", "#000000")

    if st.button("Draw"):
        draw.point((x, y), fill=color)
        st.image(canvas, caption='Your Drawing', use_column_width=True)

    # Display the drawing
    st.image(canvas, caption='Your Drawing', use_column_width=True)

# Guided Meditation for Kids
elif options == "Guided Meditation":
    st.header("πŸ§˜β€β™‚οΈ Guided Meditation for Kids")
    st.write("Relax and listen to a calming meditation.")

    meditation_text = "Close your eyes and take a deep breath. Imagine you are in a peaceful forest, with birds singing and leaves rustling in the wind."

    if st.button("Play Meditation"):
        st.spinner("Playing meditation audio...")
        tts_engine = initialize_tts()
        if tts_engine:
            tts_engine.save_to_file(meditation_text, 'meditation.mp3')
            tts_engine.runAndWait()
            st.audio('meditation.mp3', format='audio/mp3')

# Footer
st.markdown("<footer style='text-align: center; padding-top: 20px;'>Made with ❀️ for Kids by ChiliDron Team</footer>", unsafe_allow_html=True)