0

I'm making a database query and need to pronounce a text when the row is equal to 'llamar.' However, sometimes it doesn't play, or when it's playing, it cuts off and starts playing again. The text is returned to me by the SQL Server procedure 'P_registrar_turnos'. Is there a better way to handle this?

This is my code:

  setInterval(function () {
    llamarTurno();  
  }, 5000);


  function textoPorVoz(texto,funcion) {
    // +
    responsiveVoice.setDefaultVoice('Spanish Latin American Female');

    // +
    responsiveVoice.speak(texto, 'Spanish Latin American Female', {
      pitch: 1,
      rate: 1,
      onend: funcion
    });
  }

  function llamarTurno() {
      peticionActual = peticion({
        ruta: './ejecutarPeticion?procedimiento=p_traer_turnos',
        parametros: {
          renglon: 'LLAMAR'
        },
        funcion: {
          antesEnviarPeticion: function antesEnviarPeticion(peticion, configuracion) {},
          peticionExitosa: function peticionExitosa(respuesta, estado, peticion1) {

            textoPorVoz(" " + respuesta[0].texto, function() { 
              AsignarTurno(respuesta[0].id_turno);
              });
            
        }
      }
      });
    }

   function AsignarTurno(id_turno) {

    peticionActual = peticion({
      tipo: 'GET',
      ruta: './ejecutarPeticion?procedimiento=p_registrar_asignacion_turno',
      parametros: {
        renglon: 'ASIGNADO',
        id_turno_asignado: id_turno
        }
        ,
      funcion: {
      peticionExitosa: function peticionExitosa(respuesta,estado,peticion) {

        }
      }
      })

    }

Jxstinn
  • 1
  • 1
  • 1
    Not really sure how SQL Server plays any part in your issue... I assume you can query the database OK... in which case the issue lies elsewhere. – Dale K May 31 '23 at 07:42

0 Answers0