               source.connect(processor);
                    processor.connect(audioContext.destination); // Connect to output to hear audio during recording
                });
            }


            function arrayBufferToBase64(buffer) {
                let binary = '';
                const bytes = new Uint8Array(buffer);
                const len = bytes.byteLength;
                for (let i = 0; i < len; i++) {
                    binary += String.fromCharCode(bytes[i]);
                }
      