tom-s / speak-tts

76 stars 19 forks source link

Speech stops after talking for 15 min . #22

Closed chandansaibdb closed 4 years ago

chandansaibdb commented 4 years ago

i wanted to get a speech response from my chatbot, i am able to get speech for the response i get. but when the response is longer, it stops all of a sudden, any idea how to fix this issue?

tom-s commented 4 years ago

I think there is a browser 36k word limit or something like that. I advise you split the text into smaller chunks and play them one after another. The promise based API of speak-tts will allow you to do it easily.

chandansaibdb commented 4 years ago

Thank you for the quick response, but my text count is less than 200.

This is my code: My response contains the text that I want to speak. where do i have to change? it stops for words less than 200 also. what i have observed is it stops after reading for 15 seconds. const speech = new Speech();

speech
  .speak({
    text: response,
    //queue: false,
    listeners: {
      onstart: () => {
        console.log("Start utterance");
      },
      onend: () => {
        console.log("End utterance");
      },
      onresume: () => {
        console.log("Resume utterance");
      },
      onboundary: event => {
        console.log(
          event.name +
            " boundary reached after " +
            event.elapsedTime +
            " milliseconds."
        );
      }
    }
  })
  .then(() => {
    console.log("Success !");
  })
  .catch(e => {
    console.error("An error occurred :", e);
  });
chandansaibdb commented 4 years ago

Hello. Awaiting for your response.!

tom-s commented 4 years ago

Have you tried directly with the speech Synthesis API ? if you experience the same issue, it means this is an API bug (something I can't fix), if not it means the issue comes from the library.

chandansaibdb commented 4 years ago

Can u give me example? How to use

tom-s commented 4 years ago

You can try your long text with this and see if it works or not: https://codepen.io/matt-west/pen/wGzuJ

chandansaibdb commented 4 years ago

No it is not working . it breaks in middle. it hardly spoke for 15 seconds and less than 200 characters.

tom-s commented 4 years ago

Well then it's not a library issue. You'd have to split the text yourself and send shorter texts one after another.

chandansaibdb commented 4 years ago

Hey, you had suggested me to break my long text into chunks. how do i do that?