Spaces:
Runtime error
Runtime error
HuggingFace-SK
commited on
Commit
·
5c494db
1
Parent(s):
5ad985e
commit
Browse files- templates/browser-detect.html +53 -20
templates/browser-detect.html
CHANGED
|
@@ -62,6 +62,39 @@
|
|
| 62 |
|
| 63 |
|
| 64 |
<script type="module">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
import { HandLandmarker, FilesetResolver } from "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0";
|
| 67 |
let handLandmarker = undefined;
|
|
@@ -170,7 +203,7 @@
|
|
| 170 |
last_letter_time = current_time
|
| 171 |
word_list.push(current_result)
|
| 172 |
console.log(word_list)
|
| 173 |
-
document.getElementById("text").innerText=word_list.join('')
|
| 174 |
}
|
| 175 |
}
|
| 176 |
else {
|
|
@@ -179,25 +212,25 @@ document.getElementById("text").innerText=word_list.join('')
|
|
| 179 |
}
|
| 180 |
}
|
| 181 |
else {
|
| 182 |
-
if (30 > calculateCanvasBrightness(canvasElement)){
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
last_letter_time = current_time
|
| 192 |
-
word_list.pop()
|
| 193 |
-
console.log(word_list)
|
| 194 |
-
document.getElementById("text").innerText=word_list.join('')
|
| 195 |
}
|
| 196 |
-
}
|
| 197 |
-
else {
|
| 198 |
-
last_letter_time = current_time
|
| 199 |
-
}
|
| 200 |
-
}else{last_letter_time = Math.round(Date.now())}
|
| 201 |
}
|
| 202 |
|
| 203 |
canvasCtx.restore();
|
|
@@ -268,7 +301,7 @@ document.getElementById("text").innerText=word_list.join('')
|
|
| 268 |
});
|
| 269 |
drawLandmarks(canvasCtx, landmarks, { color: "#FF0000", lineWidth: 2 });
|
| 270 |
}*/
|
| 271 |
-
|
| 272 |
const landmarks = results.landmarks;
|
| 273 |
if (landmarks[0]) {
|
| 274 |
var hand = landmarks[0]
|
|
@@ -389,7 +422,7 @@ document.getElementById("text").innerText=word_list.join('')
|
|
| 389 |
last_letter_time = current_time
|
| 390 |
word_list.push(current_result)
|
| 391 |
console.log(word_list)
|
| 392 |
-
document.getElementById("text").innerText=word_list.join('')
|
| 393 |
}
|
| 394 |
}
|
| 395 |
else {
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
<script type="module">
|
| 65 |
+
var synthesis = window.speechSynthesis;
|
| 66 |
+
|
| 67 |
+
if ('speechSynthesis' in window) {
|
| 68 |
+
var synthesis = window.speechSynthesis;
|
| 69 |
+
} else {
|
| 70 |
+
console.log('Text-to-speech not supported.');
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
if ('speechSynthesis' in window) {
|
| 74 |
+
var synthesis = window.speechSynthesis;
|
| 75 |
+
|
| 76 |
+
// Regex to match all English language tags e.g en, en-US, en-GB
|
| 77 |
+
var langRegex = /^en(-[a-z]{2})?$/i;
|
| 78 |
+
|
| 79 |
+
// Get the available voices and filter the list to only have English speakers
|
| 80 |
+
var voices = synthesis
|
| 81 |
+
.getVoices()
|
| 82 |
+
.filter((voice) => langRegex.test(voice.lang));
|
| 83 |
+
|
| 84 |
+
// Log the properties of the voices in the list
|
| 85 |
+
voices.forEach(function (voice) {
|
| 86 |
+
console.log({
|
| 87 |
+
name: voice.name,
|
| 88 |
+
lang: voice.lang,
|
| 89 |
+
uri: voice.voiceURI,
|
| 90 |
+
local: voice.localService,
|
| 91 |
+
default: voice.default,
|
| 92 |
+
});
|
| 93 |
+
});
|
| 94 |
+
} else {
|
| 95 |
+
console.log('Text-to-speech not supported.');
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
|
| 99 |
import { HandLandmarker, FilesetResolver } from "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0";
|
| 100 |
let handLandmarker = undefined;
|
|
|
|
| 203 |
last_letter_time = current_time
|
| 204 |
word_list.push(current_result)
|
| 205 |
console.log(word_list)
|
| 206 |
+
document.getElementById("text").innerText = word_list.join('')
|
| 207 |
}
|
| 208 |
}
|
| 209 |
else {
|
|
|
|
| 212 |
}
|
| 213 |
}
|
| 214 |
else {
|
| 215 |
+
if (30 > calculateCanvasBrightness(canvasElement)) {
|
| 216 |
+
|
| 217 |
+
var current_result = "<"
|
| 218 |
+
var previous_result = document.getElementById("predicted_result").innerText
|
| 219 |
+
document.getElementById("predicted_result").innerText = current_result
|
| 220 |
+
var current_time = Math.round(Date.now())
|
| 221 |
+
console.log(current_time - last_letter_time)
|
| 222 |
+
if (previous_result == current_result) {
|
| 223 |
+
if (current_time - last_letter_time > 1000) {
|
| 224 |
+
last_letter_time = current_time
|
| 225 |
+
word_list.pop()
|
| 226 |
+
console.log(word_list)
|
| 227 |
+
document.getElementById("text").innerText = word_list.join('')
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
else {
|
| 231 |
last_letter_time = current_time
|
|
|
|
|
|
|
|
|
|
| 232 |
}
|
| 233 |
+
} else { last_letter_time = Math.round(Date.now()) }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
}
|
| 235 |
|
| 236 |
canvasCtx.restore();
|
|
|
|
| 301 |
});
|
| 302 |
drawLandmarks(canvasCtx, landmarks, { color: "#FF0000", lineWidth: 2 });
|
| 303 |
}*/
|
| 304 |
+
// console.log(results)
|
| 305 |
const landmarks = results.landmarks;
|
| 306 |
if (landmarks[0]) {
|
| 307 |
var hand = landmarks[0]
|
|
|
|
| 422 |
last_letter_time = current_time
|
| 423 |
word_list.push(current_result)
|
| 424 |
console.log(word_list)
|
| 425 |
+
document.getElementById("text").innerText = word_list.join('')
|
| 426 |
}
|
| 427 |
}
|
| 428 |
else {
|