generated from AIzooLab/JamalM2S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voice_integration.js
25 lines (20 loc) · 949 Bytes
/
voice_integration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
document.getElementById("submit-button").addEventListener("click", async () => {
const userInput = document.getElementById("user-input").value;
const responseContainer = document.getElementById("response");
const response = await fetch("/chat", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `user_input=${userInput}`
});
const data = await response.json();
responseContainer.innerText = `ChatBot: ${data.response}`;
});
document.getElementById("voice-button").addEventListener("click", async () => {
const responseContainer = document.getElementById("response");
const response = await fetch("/voice-interaction", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" }
});
const data = await response.json();
responseContainer.innerText = `ChatBot: ${data.response}`;
});