speech-to-element
Version:
Add real-time speech to text functionality into your website with no effort
23 lines (22 loc) • 907 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreResultUtils = void 0;
class PreResultUtils {
static process(speech, newText, isFinal, onPreResult, options) {
const result = onPreResult === null || onPreResult === void 0 ? void 0 : onPreResult(newText, isFinal);
if (!result)
return false;
// this is to prevent the spans from being repopulated after service stopped
setTimeout(() => {
if (result.restart) {
speech.resetRecording(options);
}
else if (result.stop) {
speech.stop();
}
});
// removeNewText can only work reliably if stop or restart are used as otherwise the service will keep sending text
return (result.stop || result.restart) && result.removeNewText;
}
}
exports.PreResultUtils = PreResultUtils;