This commit is contained in:
yumoqing 2024-08-09 16:47:25 +08:00
parent c9e0956498
commit 678c3b46e0

View File

@ -84,7 +84,7 @@ bricks.VadText = class extends bricks.VBox {
w.open();
}
}
function arrayBufferToBase64(wavBuffer) {
arrayBufferToBase64(wavBuffer) {
let binary = '';
const bytes = new Uint8Array(wavBuffer);
for (let i = 0; i < bytes.byteLength; i++) {
@ -92,7 +92,7 @@ bricks.VadText = class extends bricks.VBox {
}
return btoa(binary);
}
function floatArrayToWAV(floatArray, sampleRate = 22000) {
floatArrayToWAV(floatArray, sampleRate = 22000) {
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const buffer = audioCtx.createBuffer(1, floatArray.length, sampleRate);
buffer.getChannelData(0).set(floatArray);