I am building a react application that uses text to speech.
Here I am using Azure text to speech. The API seems to be running fine, and I get a binary file in response. While using thunder client in VS code, it gives me an option to save the file in device.
Now while doing it through React, I am trying to convert it to a blob object and create and update the URL for the Audio.
const audioBlob = new Blob([data], { type: 'audio/mpeg' });
setAudioUrl(URL.createObjectURL(audioBlob));
{audioUrl && <audio src={audioUrl} controls />}
On doing this the audio component appears but it is not playable.
Upon inspecting I found out, the source is:
src="blob:http://localhost:3000/b76837b3-6b7a-420e-a618-e29295082819"
Not sure what is wrong here.
Could anyone please help.
Thanks.
I have explained above.