Update app.py
Browse files
app.py
CHANGED
@@ -60,61 +60,44 @@ body {
|
|
60 |
.avatar-container {
|
61 |
text-align: center;
|
62 |
margin-bottom: 20px;
|
|
|
|
|
63 |
}
|
64 |
.avatar-img {
|
65 |
width: 150px;
|
66 |
height: 150px;
|
67 |
border-radius: 50%;
|
68 |
-
animation: blink 3s infinite;
|
69 |
}
|
70 |
@keyframes blink {
|
71 |
0%, 100% { opacity: 1; }
|
72 |
50% { opacity: 0.7; }
|
73 |
}
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
padding: 10px 20px;
|
78 |
-
border-radius: 5px;
|
79 |
-
cursor: pointer;
|
80 |
-
border: none;
|
81 |
-
color: white;
|
82 |
-
background: linear-gradient(90deg, red, orange, yellow, green, cyan, blue, violet);
|
83 |
-
background-size: 400%;
|
84 |
-
box-shadow: 0 0 10px rgba(255, 255, 255, 0.6),
|
85 |
-
0 0 20px rgba(255, 255, 255, 0.4),
|
86 |
-
0 0 40px rgba(255, 255, 255, 0.2);
|
87 |
-
animation: neon-button 2s infinite;
|
88 |
-
transition: transform 0.3s;
|
89 |
}
|
90 |
-
|
91 |
-
transform:
|
92 |
-
|
93 |
-
0 0 40px rgba(255, 255, 255, 0.6),
|
94 |
-
0 0 60px rgba(255, 255, 255, 0.4);
|
95 |
-
}
|
96 |
-
/* Neon Animation */
|
97 |
-
@keyframes neon-button {
|
98 |
-
0% { background-position: 0%; }
|
99 |
-
100% { background-position: 400%; }
|
100 |
}
|
101 |
"""
|
102 |
|
103 |
custom_js = """
|
104 |
<script>
|
105 |
document.addEventListener('DOMContentLoaded', function () {
|
106 |
-
//
|
107 |
-
const
|
108 |
-
|
109 |
|
110 |
-
//
|
111 |
const avatarImg = document.createElement('img');
|
112 |
avatarImg.src = 'https://th.bing.com/th/id/OIP.zeeoSeLcH19kuQ1ABNOGCwHaHU?rs=1&pid=ImgDetMain';
|
113 |
avatarImg.alt = "AI Assistant Avatar";
|
114 |
avatarImg.classList.add('avatar-img');
|
115 |
-
|
116 |
-
|
117 |
-
// Greeting Text
|
118 |
const messageText = document.createElement('h2');
|
119 |
const currentHour = new Date().getHours();
|
120 |
let greeting = "Welcome!";
|
@@ -122,10 +105,26 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
122 |
else if (currentHour < 18) greeting = "Good Afternoon!";
|
123 |
else greeting = "Good Evening!";
|
124 |
messageText.textContent = greeting + " I'm your AI assistant. Let's design something amazing!";
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
-
//
|
128 |
-
document.
|
|
|
|
|
|
|
|
|
|
|
129 |
});
|
130 |
</script>
|
131 |
"""
|
|
|
60 |
.avatar-container {
|
61 |
text-align: center;
|
62 |
margin-bottom: 20px;
|
63 |
+
position: relative;
|
64 |
+
animation: head-move 3s infinite;
|
65 |
}
|
66 |
.avatar-img {
|
67 |
width: 150px;
|
68 |
height: 150px;
|
69 |
border-radius: 50%;
|
70 |
+
animation: blink 3s infinite, scale 5s infinite;
|
71 |
}
|
72 |
@keyframes blink {
|
73 |
0%, 100% { opacity: 1; }
|
74 |
50% { opacity: 0.7; }
|
75 |
}
|
76 |
+
@keyframes scale {
|
77 |
+
0%, 100% { transform: scale(1); }
|
78 |
+
50% { transform: scale(1.05); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
+
@keyframes head-move {
|
81 |
+
0%, 100% { transform: translateX(0); }
|
82 |
+
50% { transform: translateX(5px); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
"""
|
85 |
|
86 |
custom_js = """
|
87 |
<script>
|
88 |
document.addEventListener('DOMContentLoaded', function () {
|
89 |
+
// Add AI avatar container with animation
|
90 |
+
const avatarContainer = document.createElement('div');
|
91 |
+
avatarContainer.classList.add('avatar-container');
|
92 |
|
93 |
+
// Add AI avatar image
|
94 |
const avatarImg = document.createElement('img');
|
95 |
avatarImg.src = 'https://th.bing.com/th/id/OIP.zeeoSeLcH19kuQ1ABNOGCwHaHU?rs=1&pid=ImgDetMain';
|
96 |
avatarImg.alt = "AI Assistant Avatar";
|
97 |
avatarImg.classList.add('avatar-img');
|
98 |
+
avatarContainer.appendChild(avatarImg);
|
99 |
+
|
100 |
+
// Add Greeting Text
|
101 |
const messageText = document.createElement('h2');
|
102 |
const currentHour = new Date().getHours();
|
103 |
let greeting = "Welcome!";
|
|
|
105 |
else if (currentHour < 18) greeting = "Good Afternoon!";
|
106 |
else greeting = "Good Evening!";
|
107 |
messageText.textContent = greeting + " I'm your AI assistant. Let's design something amazing!";
|
108 |
+
avatarContainer.appendChild(messageText);
|
109 |
+
|
110 |
+
// Prepend the avatar container to the body
|
111 |
+
document.body.prepend(avatarContainer);
|
112 |
+
|
113 |
+
// Function to trigger Text-to-Speech
|
114 |
+
function speakMessage(text) {
|
115 |
+
const synth = window.speechSynthesis;
|
116 |
+
const utterance = new SpeechSynthesisUtterance(text);
|
117 |
+
utterance.lang = 'en-US';
|
118 |
+
synth.speak(utterance);
|
119 |
+
}
|
120 |
|
121 |
+
// Trigger the speech when the output message is updated
|
122 |
+
document.addEventListener('gradio_event:output_update', (event) => {
|
123 |
+
const outputText = event.detail?.text || '';
|
124 |
+
if (outputText) {
|
125 |
+
speakMessage(outputText);
|
126 |
+
}
|
127 |
+
});
|
128 |
});
|
129 |
</script>
|
130 |
"""
|