Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit 6899705

Browse files
author
TBalo
committed
added functions to Send-text-to-NodeServer, convert-text-to-Audio
1 parent 6828fcc commit 6899705

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

index.html

+2
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ <h2 class=" footer-col-title">contact information</h2>
10451045
<!-- For img gen -->
10461046
<script src="js/Teacher.js"></script>
10471047
<script src="js/GenImage.js"></script>
1048+
<script src="sendText.js"></script>
1049+
10481050
</body>
10491051

10501052
</html>

sendText.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
document.addEventListener("DOMContentLoaded", () => {
2+
const askButton = document.getElementById("ask");
3+
const questionInput = document.getElementById("question");
4+
5+
askButton.addEventListener("click", () => {
6+
const text = questionInput.value;
7+
if (text.trim() !== "") {
8+
// Send the user's input to the server
9+
sendTextToServer(text);
10+
} else {
11+
alert("Please enter a question.");
12+
}
13+
});
14+
15+
function sendTextToServer(text) {
16+
fetch("/synthesize", {
17+
method: "POST",
18+
headers: {
19+
"Content-Type": "application/json",
20+
},
21+
body: JSON.stringify({ text: text }),
22+
})
23+
.then((response) => response.text())
24+
.then((data) => {
25+
console.log(data); // Log the server's response
26+
})
27+
.catch((error) => {
28+
console.error("Error:", error);
29+
});
30+
}
31+
});
32+

0 commit comments

Comments
 (0)