Spaces:
Running
Running
Update templates/interface.html
Browse files- templates/interface.html +33 -0
templates/interface.html
CHANGED
@@ -131,6 +131,39 @@
|
|
131 |
// Initialize the speaker options based on the default selected model
|
132 |
loadSpeakers();
|
133 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
<!-- Move the JavaScript code outside the conditional block -->
|
135 |
|
136 |
</body>
|
|
|
131 |
// Initialize the speaker options based on the default selected model
|
132 |
loadSpeakers();
|
133 |
</script>
|
134 |
+
<script>
|
135 |
+
// Function to send the request
|
136 |
+
function sendRequest() {
|
137 |
+
var xhr = new XMLHttpRequest();
|
138 |
+
xhr.open("POST", "https://gregniuki-pipertts.hf.space/", true);
|
139 |
+
xhr.setRequestHeader("Content-Type", "application/json");
|
140 |
+
|
141 |
+
// Use the injected authorization token
|
142 |
+
var token = authToken;
|
143 |
+
xhr.setRequestHeader("Authorization", token);
|
144 |
+
|
145 |
+
// Access input data by element ID
|
146 |
+
var textInput = document.getElementById("text_input").value;
|
147 |
+
|
148 |
+
// Define your request payload
|
149 |
+
var data = JSON.stringify({ data: [textInput] });
|
150 |
+
|
151 |
+
// Define the callback function to handle the response
|
152 |
+
xhr.onload = function () {
|
153 |
+
if (xhr.status === 200) {
|
154 |
+
// Handle the successful response here
|
155 |
+
var response = xhr.responseText;
|
156 |
+
console.log(response);
|
157 |
+
}
|
158 |
+
};
|
159 |
+
|
160 |
+
// Send the request
|
161 |
+
xhr.send(data);
|
162 |
+
}
|
163 |
+
|
164 |
+
// Event listener to trigger the request when the button is clicked
|
165 |
+
document.getElementById("synthesize_button").addEventListener("click", sendRequest);
|
166 |
+
</script>
|
167 |
<!-- Move the JavaScript code outside the conditional block -->
|
168 |
|
169 |
</body>
|