Im trying to pass some audio data, natively passed to Lambda as Buffer:
{
"contentType": "audio/mpeg",
"slots": {},
"sessionAttributes": {},
"message": "Sorry, I'm not able to assist at this time",
"dialogState": "Failed",
"inputTranscript": "",
"audioStream": {
"type": "Buffer",
"data": [
73,
68,
51,
4,
...,
170
]
}
}
So my Lambda callback looks like this:
callback(null, {
headers: {
'Content-Type': 'audio/mpeg', //also tried with html/text
"Access-Control-Allow-Origin" : "*",
},
body: data.audioStream.toString('base64'),
statusCode: 200
});
Unfortunately on client site i’m receving some malformed data:
console.log(atob(data));
ID3#TSSELavf57.56.101ÿó`Ä@ùµAvÊÄ,aÁÀ@FP´1(ïÊ`¾\aÁÃÿù@@?ÁÀ@?X>ø>ÿYø>õð@?ê|à
o·»a¨÷Yìõèl¯ßá
ýCmßK##ÓHbPà?¿ðªþÚBÛ
Where is the problem?