feat: word pronunciation supported

This commit is contained in:
Gabe Yuan
2024-03-25 18:14:12 +08:00
parent 1c77a289a6
commit a83039577c
7 changed files with 130 additions and 6 deletions

View File

@@ -0,0 +1,37 @@
import IconButton from "@mui/material/IconButton";
import VolumeUpIcon from "@mui/icons-material/VolumeUp";
import { useTextAudio } from "../../hooks/Audio";
export default function AudioBtn({ text, lan = "uk" }) {
const { error, ready, playing, play } = useTextAudio(text, lan);
if (error) {
return;
}
if (!ready) {
return (
<IconButton disabled>
<VolumeUpIcon />
</IconButton>
);
}
if (playing) {
return (
<IconButton color="primary">
<VolumeUpIcon />
</IconButton>
);
}
return (
<IconButton
onClick={() => {
play();
}}
>
<VolumeUpIcon />
</IconButton>
);
}