Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -105,84 +105,26 @@ def transcribe_and_chat(audio):
|
|
105 |
|
106 |
def create_demo():
|
107 |
with gr.Blocks(css="""
|
108 |
-
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
#audio-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
}
|
117 |
-
|
118 |
-
#chat-output {
|
119 |
-
background-color: #023047;
|
120 |
-
color: #ffffff;
|
121 |
-
border-radius: 10px;
|
122 |
-
box-shadow: 0px 0px 15px #8ecae6;
|
123 |
-
}
|
124 |
-
|
125 |
-
#audio-output {
|
126 |
-
border: 2px solid #8ecae6;
|
127 |
-
box-shadow: 0px 0px 15px #8ecae6;
|
128 |
-
border-radius: 10px;
|
129 |
-
}
|
130 |
-
|
131 |
-
#clear-button {
|
132 |
-
background-color: #fb8500;
|
133 |
-
color: white;
|
134 |
-
font-size: 16px;
|
135 |
-
border-radius: 5px;
|
136 |
-
box-shadow: 0px 0px 15px #fb8500;
|
137 |
-
}
|
138 |
-
|
139 |
-
#voice-volume {
|
140 |
-
background-color: #219ebc;
|
141 |
-
border-radius: 5px;
|
142 |
-
box-shadow: 0px 0px 15px #219ebc;
|
143 |
-
}
|
144 |
-
|
145 |
-
button {
|
146 |
-
font-size: 16px;
|
147 |
-
font-family: 'Poppins', sans-serif;
|
148 |
-
padding: 10px;
|
149 |
-
}
|
150 |
-
|
151 |
-
audio {
|
152 |
-
background-color: #ffb703;
|
153 |
-
border-radius: 10px;
|
154 |
-
}
|
155 |
-
|
156 |
-
h1 {
|
157 |
-
text-align: center;
|
158 |
-
color: #023047;
|
159 |
-
font-size: 28px;
|
160 |
-
font-weight: bold;
|
161 |
-
text-shadow: 0px 0px 15px #023047;
|
162 |
-
}
|
163 |
-
|
164 |
-
p {
|
165 |
-
text-align: center;
|
166 |
-
color: #8ecae6;
|
167 |
-
font-size: 18px;
|
168 |
-
}
|
169 |
-
|
170 |
@media (max-width: 768px) {
|
171 |
-
#audio-input, #
|
172 |
-
|
173 |
-
padding: 8px;
|
174 |
-
}
|
175 |
-
|
176 |
-
button {
|
177 |
-
font-size: 14px;
|
178 |
-
}
|
179 |
}
|
180 |
""") as demo:
|
181 |
gr.Markdown(
|
182 |
"""
|
183 |
-
<
|
184 |
-
<p>Talk to your personal AI! Record your voice, and get a response in both text and audio.</p>
|
185 |
-
<p>Powered by advanced AI models for real-time interaction.</p>
|
186 |
""",
|
187 |
elem_id="header"
|
188 |
)
|
@@ -257,13 +199,22 @@ def create_demo():
|
|
257 |
});
|
258 |
|
259 |
document.addEventListener('gradioUpdated', function(event) {
|
260 |
-
playAssistantAudio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
});
|
262 |
}
|
263 |
""")
|
264 |
|
265 |
return demo
|
266 |
|
267 |
-
#
|
268 |
-
|
269 |
-
demo
|
|
|
|
105 |
|
106 |
def create_demo():
|
107 |
with gr.Blocks(css="""
|
108 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap');
|
109 |
+
body { font-family: 'Poppins', sans-serif; margin: 0; padding: 0; box-sizing: border-box;}
|
110 |
+
#audio-input {border: 2px solid #ffb703; padding: 10px;}
|
111 |
+
#chat-output {background-color: #023047; color: #ffffff; font-size: 1.2em;}
|
112 |
+
#audio-output {border: 2px solid #8ecae6;}
|
113 |
+
#clear-button {background-color: #fb8500; color: white;}
|
114 |
+
#voice-volume {background-color: #219ebc;}
|
115 |
+
button {font-size: 16px;}
|
116 |
+
audio {background-color: #ffb703; border-radius: 10px;}
|
117 |
+
footer {display: none;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
@media (max-width: 768px) {
|
119 |
+
#audio-input, #chat-output, #audio-output { width: 100%; }
|
120 |
+
button { width: 100%; }
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
""") as demo:
|
123 |
gr.Markdown(
|
124 |
"""
|
125 |
+
<div style='text-align:center; color:#023047; font-size: 28px; font-weight: bold;'>🗣️ AI Voice Assistant</div>
|
126 |
+
<p style='text-align:center; color:#8ecae6; font-size: 18px;'>Talk to your personal AI! Record your voice, and get a response in both text and audio.</p>
|
127 |
+
<p style='text-align:center; color:#8ecae6;'>Powered by advanced AI models for real-time interaction.</p>
|
128 |
""",
|
129 |
elem_id="header"
|
130 |
)
|
|
|
199 |
});
|
200 |
|
201 |
document.addEventListener('gradioUpdated', function(event) {
|
202 |
+
setTimeout(playAssistantAudio, 100);
|
203 |
+
});
|
204 |
+
|
205 |
+
// Prevent audio from stopping when switching tabs
|
206 |
+
document.addEventListener("visibilitychange", function() {
|
207 |
+
var audioElements = document.querySelectorAll('audio');
|
208 |
+
audioElements.forEach(function(audio) {
|
209 |
+
audio.play();
|
210 |
+
});
|
211 |
});
|
212 |
}
|
213 |
""")
|
214 |
|
215 |
return demo
|
216 |
|
217 |
+
# Launch the Gradio app
|
218 |
+
if __name__ == "__main__":
|
219 |
+
demo = create_demo()
|
220 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|