Disable recognition fixes where arbitrary text is expected

main
Isaiah Odhner 2020-05-10 23:02:14 -04:00
parent 702698b1f9
commit 6ac99f15c5
1 changed files with 7 additions and 5 deletions

View File

@ -170,11 +170,13 @@ recognition.onresult = function(event) {
console.log(`Result received: "${command}"`);
console.log('Confidence: ' + event.results[0][0].confidence);
command = command.toLowerCase();
for (const [bad, good] of Object.entries(recognitionFixes)) {
if (bad.match(/^\W|\W$/)) {
command = command.replace(new RegExp(escapeRegExp(bad), "ig"), good);
} else {
command = command.replace(new RegExp(`\\b${escapeRegExp(bad)}\\b`, "ig"), good);
if (!command.match(/^draw /i) && !(document.activeElement && document.activeElement.matches("input, textarea, [contenteditable]"))) {
for (const [bad, good] of Object.entries(recognitionFixes)) {
if (bad.match(/^\W|\W$/)) {
command = command.replace(new RegExp(escapeRegExp(bad), "ig"), good);
} else {
command = command.replace(new RegExp(`\\b${escapeRegExp(bad)}\\b`, "ig"), good);
}
}
}
console.log(`After any fixes: "${command}"`);