I am working on a project that is using the google cloud speech-to-text api. The result from the api returns an object that has multiple arrays of transcript and each array contains an array for each word and their properties, which is an object. I want to filter through every words in the transcript, and see if it matches another array of words I want to filter out.
Here's a simplified example if it sounds confusing.
resultFromApi = {
results:[
[{word:"hello", startTime:"00:00:00",endTime:"00:00:02"},...],
[{word:"world", startTime:"00:00:02",endTime:"00:00:04"},...]
]
}
wordsToFilter = ["hello", "there", "this", "is", "a", "test"]
My question is, is there a faster way other than something like this?
resultFromApi.results.forEach((result) => {
result.forEach((e) => {
if(wordsToFilter.includes(e.word)){
...
}
})
});
Edit: Syntax problem