Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +6 -7
static/index.html
CHANGED
@@ -147,9 +147,7 @@
|
|
147 |
const botMessage = data.response;
|
148 |
addMessage("Bot", botMessage, "bot-message");
|
149 |
chatHistoryArray.push({ sender: "Bot", message: botMessage });
|
150 |
-
|
151 |
-
playAudio(data.audioUrl);
|
152 |
-
}
|
153 |
} catch (error) {
|
154 |
botTyping.remove();
|
155 |
console.error("Error:", error);
|
@@ -158,10 +156,11 @@
|
|
158 |
}
|
159 |
}
|
160 |
|
161 |
-
// Play
|
162 |
-
function playAudio(
|
163 |
-
const
|
164 |
-
|
|
|
165 |
}
|
166 |
|
167 |
// Speech-to-Text function
|
|
|
147 |
const botMessage = data.response;
|
148 |
addMessage("Bot", botMessage, "bot-message");
|
149 |
chatHistoryArray.push({ sender: "Bot", message: botMessage });
|
150 |
+
playAudio(botMessage); // Play the bot's response as speech
|
|
|
|
|
151 |
} catch (error) {
|
152 |
botTyping.remove();
|
153 |
console.error("Error:", error);
|
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
// Play speech using SpeechSynthesis API
|
160 |
+
function playAudio(text) {
|
161 |
+
const utterance = new SpeechSynthesisUtterance(text);
|
162 |
+
utterance.lang = currentLanguage; // Ensure language is set correctly
|
163 |
+
window.speechSynthesis.speak(utterance);
|
164 |
}
|
165 |
|
166 |
// Speech-to-Text function
|