I’m calling the Azure TTS rest API, using the header X-Microsoft-OutputFormat with the value audio-24khz-160kbitrate-mono-mp3, and I don’t know how to convert and play the audio from response.
Does any know how to play the audio response when call Azure Cognitive services rest API?
Tks.
I tried to convert using blob
`
let wavFile = new Blob(res.data, {
'type': 'audio/mp3'
});
`
but without success.
2
Answers
a work around would be that you use the JavaScript azure cognitive service libraries to convert text to speech.
This way it will generate a
.wav
file which you can then play using a node-wav-player npm package to play the file .code for test to speech
The above code is from the MSDOC on text to speech using JavaScript.
The following Code which will play the
.wav
file :Please use fetch and ensure at least include following headers and payload:
Or, use async/await is more concise: