//合成成功下载
// 假设这是你的Base64编码的WAV音频数据
const base64AudioString = ress.data.data;
const fileName = ress.data.name; // 自定义文件名
// 定义转换和下载函数
function downloadBase64AsWav(base64AudioString, fileName) {
// 将Base64字符串转换为Blob
const binaryString = window.atob(base64AudioString);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'audio/wav' });
// 下载Blob为WAV文件
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
// 调用函数下载WAV文件
downloadBase64AsWav(base64AudioString, fileName);
10-26
355
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-04
7829
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-27
3195
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交