Skip to content

Commit

Permalink
mental map web speech directum test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Karachev committed Oct 21, 2024
1 parent cb78703 commit e662b1e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion asset/mental_map_quiz/lib/MissingWordsRecognition.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ export default function MissingWordsRecognition(config) {
}
}

const DICTIONARY = {
'директом': 'Directum'
}

function editInterim(s) {
return s
.split(' ')
.map((word) => {
word = word.trim()
return DICTIONARY[word.toLowerCase()] ? DICTIONARY[word.toLowerCase()] : word
})
.join(' ')
}

recorder.onresult = function (event) {

let interimTranscript = '';
Expand All @@ -40,7 +54,8 @@ export default function MissingWordsRecognition(config) {

for (let i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
finalTranscript += event.results[i][0].transcript;
const result = editInterim(event.results[i][0].transcript)
finalTranscript += result;
} else {
interimTranscript += event.results[i][0].transcript;
}
Expand Down

0 comments on commit e662b1e

Please sign in to comment.