Leaving a not to look into simplifying the logic for generatePreviousTimingsUpToCurrent which used in css injection paragraph highlighting feature. To see if it can be implemented without being reliant on the actual list of words.
verbose generate previous timings up to current func
/**
* See explanation in `src/utils/dpe-to-slate/index.js` for how this function works with css injection
* to provide current paragaph's highlight.
* @param {Number} currentTime - float in seconds
*/
const generatePreviousTimingsUpToCurrent = (currentTime) => {
const lastWordStartTime = props.transcriptData.words[props.transcriptData.words.length - 1].start;
const lastWordStartTimeInt = parseInt(lastWordStartTime);
const emptyListOfTimes = Array(lastWordStartTimeInt);
const listOfTimesInt = [...emptyListOfTimes.keys()];
const listOfTimesUpToCurrentTimeInt = listOfTimesInt.splice(0, currentTime, 0);
const stringlistOfTimesUpToCurrentTimeInt = listOfTimesUpToCurrentTimeInt.join(' ');
return stringlistOfTimesUpToCurrentTimeInt;
};
simplified without using words just making a list of possible time integers up to current
function generatePreviousTimingsUpToCurrent(start) {
return new Array(parseInt(start))
.fill(1)
.map((_, i) => i + 1)
.join(' ');
}
Mostly to reduce potential issues when there's bugs on the list of words, eg missing start, end attributes etc.. Which there shouldn't be but might come from upstream issues, eg from STT converters.
To do this, it requires generatePreviousTimingsUpToCurrent untangling in the code where this is being used and replace all instances.
Leaving a not to look into simplifying the logic for
generatePreviousTimingsUpToCurrent
which used in css injection paragraph highlighting feature. To see if it can be implemented without being reliant on the actual list of words.verbose generate previous timings up to current func
One line
possible solution
simplified without using words just making a list of possible time integers up to current
Mostly to reduce potential issues when there's bugs on the list of words, eg missing start, end attributes etc.. Which there shouldn't be but might come from upstream issues, eg from STT converters.
To do this, it requires
generatePreviousTimingsUpToCurrent
untangling in the code where this is being used and replace all instances.