Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

38
Views
Text to speach automatically calls Speak Function in react-speech-kit

I'm trying to create a speech-to-text command then the server will reply as text then convert it to speech using react-speech-kit. Both function works fine, but what I wanted to do is call the Speak() function from useSpeechSynthesis automatically.

I've called the speak function on onEnd function from useSpeechRecognition like this

  const onEnd = () => {
    fetch(
      "http://api/Main?id=test&lang=kor&req=" +
        value,
      {}
    )
      .then((res) => res.json())
      .then(
        (result) => {
          setResponse(result.res);
          speak(result.res);
          console.log(result);
        },
        (error) => {
          console.log(error);
        }
      );
    // You could do something here after speaking has finished
  };

But it doesn't speak for itself after the value has been passed.

Does anyone know how to make it automatic?

EDIT

I was wrong to call speak function like that, it should've be like this speak({text:result.res}); It is working now, TTS automatically calls, but it calls over and over again, not once, anyone knows how to fix it?

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.