Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
Is it possible to make the voice in html TTS not change everytime it's used?

I want make an AI voice assistant in an html website, however, I also want it to only speak out of one voice, whenever I run the code for it (below) I always have the voice changing. I want the voice to be static and not changing.

const btn = document.querySelector('.talk');
const content = document.querySelector('.content');

//
const hru = ['I am fine', "I feel fine"];

const hello = ['Hi', 'Hello', 'Hey'];

const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();

recognition.onstart = function () {
    console.log('Voice is activated, you can use the microphone');

};


recognition.onresult = function(event){
    const current = event.resultIndex;

    const transcript = event.results[current][0].transcript;
    content.textContent = transcript;
    readOutLoud(transcript)
};

// add the listener to the btn

btn.addEventListener('click', () =>{
    recognition.start();
});

function readOutLoud(message){
    const speech = new SpeechSynthesisUtterance();

    speech.text = 'What did you say?';

    if(message.includes('how are you')){
        const finalhru = hru[Math.floor(Math.random() * hru.length)];
        speech.text = finalhru; 
    }
    
        if(message.includes('hello', 'hi', 'hey')){
        const finalhello = hello[Math.floor(Math.random() * hello.length)];
        speech.text = finalhello; 
    }

    speech.volume = 1;
    speech.rate = 1;
    speech.pitch = 1;

    window.speechSynthesis.speak(speech)
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda