Update index.html
Browse files- index.html +22 -9
index.html
CHANGED
@@ -100,15 +100,28 @@
|
|
100 |
resultBox.style.display = "block";
|
101 |
|
102 |
try {
|
103 |
-
const response = await fetch("https://gaur3009-speech-grammar.hf.space/predict", {
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
})
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
} catch (error) {
|
114 |
resultText.innerText = "❌ Error connecting to grammar checker API.";
|
|
|
100 |
resultBox.style.display = "block";
|
101 |
|
102 |
try {
|
103 |
+
const response = await fetch("https://gaur3009-speech-grammar.hf.space/run/predict", {
|
104 |
+
method: "POST",
|
105 |
+
headers: { "Content-Type": "application/json" },
|
106 |
+
body: JSON.stringify({
|
107 |
+
data: [null, inputText],
|
108 |
+
fn_index: 2
|
109 |
+
})
|
110 |
+
});
|
111 |
+
|
112 |
+
if (!response.ok) {
|
113 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
114 |
+
}
|
115 |
+
|
116 |
+
const data = await response.json();
|
117 |
+
const prediction = data?.data?.[0];
|
118 |
+
const confidence = data?.data?.[1];
|
119 |
+
|
120 |
+
if (prediction !== undefined) {
|
121 |
+
resultText.innerText = `✅ Corrected: ${prediction}\n🔍 Confidence: ${confidence}%`;
|
122 |
+
} else {
|
123 |
+
resultText.innerText = "⚠️ Unexpected API response format.";
|
124 |
+
}
|
125 |
|
126 |
} catch (error) {
|
127 |
resultText.innerText = "❌ Error connecting to grammar checker API.";
|