const voices = speechSynthesis.getVoices(),
  frVoice = voices.filter((currentVoice) => currentVoice.lang === 'fr-FR')[0];

( ! frVoice ) && console.error('No voice detected !!! Speech synthesis will not work.');

const webspeechapi = {
  utterance: null,
  intervalId: null,

  initUtterance: function(text) {
    let utterance = new SpeechSynthesisUtterance();
    utterance.voice = frVoice; // Note: some voices don't support altering params
    utterance.voiceURI = 'native';
    utterance.volume = 1; // 0 to 1
    utterance.rate = 1; // 0.1 to 10
    utterance.pitch = 1; //0 to 2
    utterance.lang = 'fr';
    utterance.text = text;


    return utterance;
  },

  cancel: function() {
    speechSynthesis.cancel();
    if (this.intervalId) window.clearInterval(this.intervalId);
  },

  speak: function(text) {
    this.cancel();
    return new Promise((resolve, reject) => {
      // we set a timeout to make work cancel/speak 
      // in electron+chromium, tts doesn't work when we 'swipe' quickly
      // see https://github.com/makinacorpus/accessimap-lecteur-der/issues/21
      // we set to 150ms the timeout before speaking
      this.intervalId = window.setTimeout(() => {
        this.utterance = this.initUtterance(text);
        speechSynthesis.speak(this.utterance);
        this.utterance.onend = () => {
          resolve();
        };
      }, 150);
    });
    
  }
};

module.exports = webspeechapi;

@@ -683,24 +683,116 @@
 unction() %7B%0A
+    if (this.promise) %7B%0A      console.log(this.promise)%0A      this.promise.resolve();%0A    %7D%0A
     speechSy
@@ -1455,29 +1455,171 @@
     
-%7D, 150);%0A    %7D
+  this.utterance.onpause = () =%3E %7B%0A          resolve();%0A        %7D;%0A        this.utterance.onresume = () =%3E %7B%0A          resolve();%0A        %7D;%0A      %7D, 150
 );%0A    
+%7D);
 %0A  %7D

Add onpause and onresume event on tts