我的文字到语音软件会在客户端产生声音。
发布于 2018-05-01 10:08:18
要将大对象临时保存到磁盘,可以使用localStorage或IndexDB。参见这里的示例,如何将blob保存到localStoarge (示例使用图像,但可以应用于任何格式,请参阅“使用blob作为responseType”部分)。
要允许用户下载它,可以使用createObjectURL保存。
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
download(arrayBuffer, 'media.mp3', 'audio/mpeg');
当然,要使用适当的格式。
https://stackoverflow.com/questions/50114089
复制相似问题