// implement a voice component by speech synthesis to read the text with the voice of the user's choice import * as React from "react"; import { useState } from "react"; import { useSpeechSynthesis } from "react-speech-kit"; import { IconButton } from "./button"; import VoiceIcon from "../icons/voice.svg"; const voices = window.speechSynthesis.getVoices(); export function Voice(props: { text: string }) { const { speak } = useSpeechSynthesis(); const [voice, setVoice] = useState(null); return (
{ if (voice) { speak({ text: props.text, voice }); } }} icon={} title="Read" />
); }