in lex-web-ui/src/store/actions.js [655:695]
lexPostContent(context, audioBlob, offset = 0) {
context.commit('setIsLexProcessing', true);
context.commit('reapplyTokensToSessionAttributes');
const session = context.state.lex.sessionAttributes;
delete session.appContext;
console.info('audio blob size:', audioBlob.size);
let timeStart;
return context.dispatch('refreshAuthTokens')
.then(() => context.dispatch('getCredentials'))
.then(() => {
const localeId = context.state.config.lex.v2BotLocaleId
? context.state.config.lex.v2BotLocaleId.split(',')[0]
: undefined;
timeStart = performance.now();
return lexClient.postContent(
audioBlob,
localeId,
session,
context.state.lex.acceptFormat,
offset,
);
})
.then((lexResponse) => {
const timeEnd = performance.now();
console.info(
'lex postContent processing time:',
((timeEnd - timeStart) / 1000).toFixed(2),
);
context.commit('setIsLexProcessing', false);
return context.dispatch('updateLexState', lexResponse)
.then(() => (
context.dispatch('processLexContentResponse', lexResponse)
))
.then(blob => Promise.resolve(blob));
})
.catch((error) => {
context.commit('setIsLexProcessing', false);
throw error;
});
},