Skip to content

Instantly share code, notes, and snippets.

@savelee

savelee/index.js

Created Apr 8, 2020
Embed
What would you like to do?
Client - Text to Speech - Streaming
// 1)
function playOutput(arrayBuffer){
let audioContext = new AudioContext();
let outputSource;
try {
if(arrayBuffer.byteLength > 0){
// 2)
audioContext.decodeAudioData(arrayBuffer,
function(buffer){
// 3)
audioContext.resume();
outputSource = audioContext.createBufferSource();
outputSource.connect(audioContext.destination);
outputSource.buffer = buffer;
outputSource.start(0);
},
function(){
console.log(arguments);
});
}
} catch(e) {
console.log(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.