File size: 3,348 Bytes
e47c379 09f752a e47c379 |
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Speech Grammar Checker</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f1f3f8;
margin: 0;
padding: 0;
}
header {
background: #4a90e2;
color: white;
padding: 1em 2em;
text-align: center;
font-size: 1.5em;
}
.container {
max-width: 700px;
margin: 2em auto;
background: white;
padding: 2em;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
textarea {
width: 100%;
height: 120px;
padding: 1em;
font-size: 1em;
border: 1px solid #ccc;
border-radius: 8px;
resize: vertical;
}
button {
background: #4a90e2;
color: white;
padding: 0.75em 1.5em;
border: none;
font-size: 1em;
margin-top: 1em;
border-radius: 6px;
cursor: pointer;
}
button:hover {
background: #3c7dcf;
}
.result {
margin-top: 1.5em;
background: #f9f9f9;
border-left: 4px solid #4a90e2;
padding: 1em;
border-radius: 5px;
font-size: 1em;
white-space: pre-wrap;
}
footer {
margin-top: 3em;
text-align: center;
color: #888;
font-size: 0.9em;
}
</style>
</head>
<body>
<header>π£οΈ Speech Grammar Checker</header>
<div class="container">
<label for="speechInput"><strong>Paste your speech or sentence below:</strong></label>
<textarea id="speechInput" placeholder="Enter your sentence..."></textarea>
<button onclick="checkGrammar()">Check Grammar</button>
<div class="result" id="resultBox" style="display: none;">
<strong>Result:</strong>
<div id="resultText"></div>
</div>
</div>
<footer>
Made with β€οΈ using Hugging Face API | Rookus.ai
</footer>
<script>
async function checkGrammar() {
const inputText = document.getElementById("speechInput").value.trim();
const resultBox = document.getElementById("resultBox");
const resultText = document.getElementById("resultText");
if (!inputText) {
resultText.innerText = "β Please enter some text to check.";
resultBox.style.display = "block";
return;
}
resultText.innerText = "β³ Checking grammar...";
resultBox.style.display = "block";
try {
const response = await fetch("https://gaur3009-speech-grammar.hf.space/run/predict", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: [null, inputText],
fn_index: 2
})
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
const prediction = data?.data?.[0];
const confidence = data?.data?.[1];
if (prediction !== undefined) {
resultText.innerText = `β
Corrected: ${prediction}\nπ Confidence: ${confidence}%`;
} else {
resultText.innerText = "β οΈ Unexpected API response format.";
}
} catch (error) {
resultText.innerText = "β Error connecting to grammar checker API.";
console.error(error);
}
}
</script>
</body>
</html> |