mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 00:58:34 +00:00
aws stt: calculate transcript-level confidence based on word confidence scores
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user