javascript – Web Speech Api not-allowed no voice acting

For some reason, the voice acting of the text stops happening to me. The logic is as follows – tasks are automatically created on my server according to time and data about tasks is transmitted over sockets, and at the moment when the time for the task approaches (and 5 minutes before the time) voice acting occurs. However, for some reason a not-allowed error occurred. What could be the reason? Moreover, I noticed that this happens on tasks when there is a long period of time between voiceovers. How can I fix it?

This is what my code currently looks like

voice(text) {
      const utterance = new SpeechSynthesisUtterance(text);


  utterance.onend = () => {
    const timestamp = new Date();
    console.log(`Pronunciation complete ${text} time: ${timestamp}`);
    this.$store.dispatch('saveCurNumberVoiceToLocalStorage', { text, timestamp });
  };

  utterance.onerror = (event) => {
    console.error('Pronunciation error:', event.error);
    const timestamp = new Date();
    this.$store.dispatch('logSpeechSynthesisError', { text, timestamp, error: event.error });
  };

  speechSynthesis.speak(utterance);
},

Read more here: Source link