How to Listen to a Specific Word in React
In this lesson, we will see how to listen to a specific word in React. Sometimes, when working on a project, such as a dictionary, you want to listen to a particular word, so how can we do that?
Listen to the specific word using React
To do that we use the SpeechSynthesis interface of the Web Speech API see the example below:
import React from 'react'
export default function SayHello() { const synth = window.speechSynthesis
return ( <button onClick={() => synth.speak(new SpeechSynthesisUtterance("Hello world"))} > Say hello world </button> )}