Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
how do I keep playing audio file in browser

I am trying to play audio clips of audio receieved from server through socketio. The code works but on the first audio clip recieved is played, any clip recieved afterwards are not played. I confirmed their reciept but I don't know why it only plays the first received audio file.


   socketio.on('audio_playback_results', function (data) {
        console.log("I recieved an audio playback! ",data);
        playOutput(data);
    });


    function playOutput(arrayBuffer){
        let audioContext = new AudioContext();
        let outputSource;
        try {
            if(arrayBuffer.byteLength > 0){
                console.log(arrayBuffer.byteLength);
                audioContext.decodeAudioData(arrayBuffer,
                function(buffer){
                    audioContext.resume();
                    outputSource = audioContext.createBufferSource();
                    outputSource.connect(audioContext.destination);
                    outputSource.buffer = buffer;
                    outputSource.start(0);
                },
                function(){
                    console.log(`playoutput PLAYING OUTPUT ARGUMMENT ${arguments}`);

                    // console.log(arguments);
                });
            }
        } catch(e) {

            console.log(`ERORRR PLAYING OUTPUT ${e}`);
        }
    }

i perform a text to audiobuffer on server side and then stream it back to client side.

async function textToAudioBuffer(text) {

  requestTTS.input = { text: text }; // text or SSML
    const response = await ttsClient.synthesizeSpeech(requestTTS);
    console.log("RESPONSE @ ttsClient, textToAudioBuffer() : ", response[0].audioContent)

    var results = response[0].audioContent

     io.emit('audio_playback_results', results);


  return response[0].audioContent;
}

what is causing it not to play audio clip recieved after the first one and how can I fix this ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda