Package Exports
- react-stt
- react-stt/dist/index.es.js
- react-stt/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-stt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React-STT
This package lets you convert speech to text in a react app.
Instalation
npm i react-sttAttributes
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;