I try to use aws amplify predictions.
The example is on this site on the end:
https://docs.amplify.aws/lib/predictions/transcribe/q/platform/js/#set-up-the-backend
let buff = await file?.arrayBuffer()
await Predictions.convert({
transcription: {
source: {
bytes: buff
}
}
}).then(({ transcription: { fullText } }) => console.log({ fullText }))
It says
you can transcribe a PCM Audio byte buffer to Text, such as a recording from microphone.
But this example does not work.
file is an mp3 file.
When i pass it into bytes my result is ab empty string ""
I guess i got it.
let buffer = await file.arrayBuffer()
let context = new AudioContext()
context.decodeAudioData(buffer, async res => {
let output = res.getChannelData(0)
await Predictions.convert({
transcription: {
source: {
bytes: output
}
}
}).then(({ transcription: { fullText } }) => console.log({ fullText }))
})
You need to use AudioContext. You decode your buffer and then get the channelData and pass this into your transcription