Maybe this is useful for others. Tested with twilio-client 1.13.1.
const audio = document.createElement('audio');
audio.setAttribute('src', your_audio_url);
document.body.appendChild(audio);
const ctx = new AudioContext();
const src = new MediaElementAudioSourceNode(ctx, { mediaElement: audio });
const dst = new MediaStreamAudioDestinationNode(ctx);
src.connect(dst);
your_twilio_device.activeConnection().mediaStream.setInputTracksFromStream(dst.stream);
audio.addEventListener('ended', () => your_twilio_device.disconnectAll());
audio.play();
Maybe this is useful for others. Tested with twilio-client 1.13.1.