In order to play audio from the result of an XHR request we can make use of the following code (in this case using the IBM Watson Text to Speech Service), this will make the request, store the response audio as a Blob, assign that to an Audio Element, and then play the audio.
We will need to have the following in our HTML
And then the necessary Javascript to get the audio source set on the element
Note that we may get blocked by CORS, in order to prevent this we can make use of an Express Proxy on the server side (or really any kind of proxy) which will serve our site files from a public folder, and proxy requests to /speech to https://stream.watsonplatform.net/
It may be possible to make the request on the server as well and simply pass the binary forward, however I have not gotten that to work as yet