Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -165,10 +165,27 @@ def create_demo():
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
});
|
171 |
|
|
|
|
|
|
|
|
|
|
|
172 |
document.addEventListener('gradioUpdated', function(event) {
|
173 |
setTimeout(playAssistantAudio, 100);
|
174 |
});
|
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
+
// Automatically play the assistant's audio when it's loaded
|
169 |
+
const audioOutputObserver = new MutationObserver((mutations) => {
|
170 |
+
mutations.forEach((mutation) => {
|
171 |
+
if (mutation.type === 'childList') {
|
172 |
+
const addedNodes = mutation.addedNodes;
|
173 |
+
addedNodes.forEach((node) => {
|
174 |
+
if (node.tagName === 'AUDIO') {
|
175 |
+
setTimeout(() => {
|
176 |
+
node.play();
|
177 |
+
}, 100);
|
178 |
+
}
|
179 |
+
});
|
180 |
+
}
|
181 |
+
});
|
182 |
});
|
183 |
|
184 |
+
const audioOutputElement = document.querySelector('#audio-output');
|
185 |
+
if (audioOutputElement) {
|
186 |
+
audioOutputObserver.observe(audioOutputElement, { childList: true, subtree: true });
|
187 |
+
}
|
188 |
+
|
189 |
document.addEventListener('gradioUpdated', function(event) {
|
190 |
setTimeout(playAssistantAudio, 100);
|
191 |
});
|