Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,7 +74,11 @@ html_code = """
|
|
| 74 |
});
|
| 75 |
|
| 76 |
function greetUser() {
|
| 77 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
speechSynthesis.speak(utterance);
|
| 79 |
utterance.onend = () => {
|
| 80 |
status.textContent = "Listening...";
|
|
@@ -98,11 +102,10 @@ html_code = """
|
|
| 98 |
const result = await fetch("/process-audio", { method: "POST", body: formData });
|
| 99 |
const data = await result.json();
|
| 100 |
|
|
|
|
|
|
|
|
|
|
| 101 |
const utterance = new SpeechSynthesisUtterance(data.response);
|
| 102 |
-
utterance.onend = () => {
|
| 103 |
-
response.textContent = data.response; // Show text after speech ends
|
| 104 |
-
response.style.display = "block"; // Ensure text is shown after speech
|
| 105 |
-
};
|
| 106 |
speechSynthesis.speak(utterance);
|
| 107 |
|
| 108 |
} catch (error) {
|
|
|
|
| 74 |
});
|
| 75 |
|
| 76 |
function greetUser() {
|
| 77 |
+
const responseText = "Hi. Welcome to Biryani Hub. Can I show you the menu?";
|
| 78 |
+
// Display the text immediately before speaking
|
| 79 |
+
response.textContent = responseText;
|
| 80 |
+
response.style.display = "block"; // Ensure text is shown
|
| 81 |
+
const utterance = new SpeechSynthesisUtterance(responseText);
|
| 82 |
speechSynthesis.speak(utterance);
|
| 83 |
utterance.onend = () => {
|
| 84 |
status.textContent = "Listening...";
|
|
|
|
| 102 |
const result = await fetch("/process-audio", { method: "POST", body: formData });
|
| 103 |
const data = await result.json();
|
| 104 |
|
| 105 |
+
// Display the text immediately before speaking
|
| 106 |
+
response.textContent = data.response;
|
| 107 |
+
response.style.display = "block"; // Show the text response before speech starts
|
| 108 |
const utterance = new SpeechSynthesisUtterance(data.response);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
speechSynthesis.speak(utterance);
|
| 110 |
|
| 111 |
} catch (error) {
|