'How to transmit real-time audio data through js/browser?

In a project, I need to process audio data acquired by a microphone which is displayed in a edge device(with limited computer capacity). And to improve the performance, I want to place the data process program on a powerful computer(server), and transmit real-time audio data captured by the microphone to the server. For some reasons, I need to do these through browser. My question is, it seems that there are no good ways to transmit streaming data via browser. Can post effectively do this job?

Here are my code and thought:

    ...
    let audiodata = [];
    let recorder = new MediaRecorder(stream);
        let senddata = setInterval(()=>{
            /*transmit data*/
            $.ajax({
                type: "POST",
                data: audiodata,
                ...
            });
            /*clear audiodata*/
            audiodata = [];
        }, 1000);

        let stopped = new Promise((resolve, reject) => {
            recorder.onstop = function(){
                window.clearInterval(senddata);
                resolve();
            };
            recorder.onerror = event => reject(event.name);
        });
        
    ...


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source