react-stt
v1.0.4
Published
Speech to text commponent for reactjs
Downloads
9
Maintainers
Readme
React-STT
This package lets you convert speech to text in a react app.
Instalation
npm i react-stt
Attributes
| Name | Description |
| -------------------------------- | --------------------------------------- |
| exportText
| Returns the converted text. |
| startMessage
| Start Message. Start by default |
| stopMessage
| Stop Message. Stop by default |
Example
Given below is a simple unstyled example that converts the speech and fills the input field.
import { useEffect, useState } from "react";
import SpeechTotext from "react-stt";
function App() {
const [message, setMessage] = useState(null);
useEffect(() => {
//Scrolls to the bottom of the div tag.
document.getElementById("message-box").value = message;
const div = document.getElementById("message-box");
div.scrollTop = div.scrollHeight - div.clientHeight;
}, [message]);
return (
<>
<SpeechTotext
exportText={(note) => setMessage(note)}
startMessage={"start"}
stopMessage={"stop"}
/>
<textarea id="message-box" cols="30" rows="10"></textarea>
</>
);
}
export default App;