mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
23 lines
390 B
Markdown
23 lines
390 B
Markdown
# `useSpeech`
|
|
|
|
React UI hook that synthesizes human voice that speaks a given string.
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import {useSpeech} from 'react-use';
|
|
|
|
const voices = window.speechSynthesis.getVoices();
|
|
|
|
const Demo = () => {
|
|
const state = useSpeech('Hello world!', { rate: 0.8, pitch: 0.5, voice: voices[0] });
|
|
|
|
return (
|
|
<pre>
|
|
{JSON.stringify(state, null, 2)}
|
|
</pre>
|
|
);
|
|
};
|
|
```
|