Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Send audio file over microphone using javascript

I want to send a audio file to a server (in my case discord) easly as if it was comming from the microphone

I found this code at Send sound through microphone in javascript and modified it to try to fit my use case, but I still cannot get it to work.

navigator.mediaDevices.getUserMedia = () => {
    const audioContext = new AudioContext();

    return fetch('http://127.0.0.1:8000/enemey.ogg',{mode: 'no-cors'})
        .then((response) => response.arrayBuffer())
        .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer))
        .then((audioBuffer) => {
            const audioBufferSourceNode = audioContext.createBufferSource();
            const mediaStreamAudioDestinationNode = audioContext.createMediaStreamDestination();

            audioBufferSourceNode.buffer = audioBuffer;
            // Maybe it makes sense to loop the buffer.
            audioBufferSourceNode.loop = true;

            audioBufferSourceNode.start();

            audioBufferSourceNode.connect(mediaStreamAudioDestinationNode);

            return mediaStreamAudioDestinationNode.stream;
        });
};

any Ideas? I cannot find a fix for this, and the error is

[AudioActionCreators] unknown getUserMedia error: EncodingError

by discord

(all of this is done with the console, not a external program)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!