aws stt: calculate transcript-level confidence based on word confidence scores

This commit is contained in:
Dave Horton
2023-11-30 10:38:33 -05:00
parent 8ad947c0fd
commit 6043921067

View File

@@ -369,7 +369,12 @@ const normalizeMicrosoft = (evt, channel, language) => {
const normalizeAws = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
const alternatives = evt.Transcript?.Results[0]?.Alternatives.map((alt) => {
return {transcript: alt.Transcript};
const items = alt.Items.filter((item) => item.Type === 'pronunciation' && 'Confidence' in item);
const confidence = items.reduce((acc, item) => acc + item.Confidence, 0) / alt.Items.length;
return {
transcript: alt.Transcript,
confidence
};
});
return {
language_code: language,