Commit ·
517615e
1
Parent(s): 91be1f3
Add VoiceToVoice component for voice interaction with listening toggle functionality
Browse files
src/pages/voiceToVoice/assets/animation.gif
ADDED
|
src/pages/voiceToVoice/assets/img.png
ADDED
|
src/pages/voiceToVoice/index.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Box, Button } from "@mui/material";
|
| 2 |
+
import React, { useState } from "react";
|
| 3 |
+
|
| 4 |
+
const gifSrc = new URL("./assets/animation.gif", import.meta.url).href;
|
| 5 |
+
const imgSrc = new URL("./assets/img.png", import.meta.url).href;
|
| 6 |
+
|
| 7 |
+
const VoiceToVoice: React.FC = () => {
|
| 8 |
+
const [listening, setIsListening] = useState<boolean>(false);
|
| 9 |
+
|
| 10 |
+
function handleClick() {
|
| 11 |
+
setIsListening((prevState) => !prevState);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<Box
|
| 16 |
+
sx={{
|
| 17 |
+
display: "flex",
|
| 18 |
+
flexDirection: "column",
|
| 19 |
+
alignItems: "center",
|
| 20 |
+
justifyContent: "center",
|
| 21 |
+
height: "100vh",
|
| 22 |
+
width: "100vw",
|
| 23 |
+
}}
|
| 24 |
+
>
|
| 25 |
+
<Box
|
| 26 |
+
sx={{
|
| 27 |
+
width: "200px",
|
| 28 |
+
display: "flex",
|
| 29 |
+
flexDirection: "column",
|
| 30 |
+
alignItems: "center",
|
| 31 |
+
}}
|
| 32 |
+
>
|
| 33 |
+
<Box sx={{ mb: "10px" }}>
|
| 34 |
+
{listening ? (
|
| 35 |
+
<img src={gifSrc} alt="Listening animation" width={200} height={200} />
|
| 36 |
+
) : (
|
| 37 |
+
<img src={imgSrc} alt="Static image" width={200} />
|
| 38 |
+
)}
|
| 39 |
+
</Box>
|
| 40 |
+
<Button
|
| 41 |
+
onClick={handleClick}
|
| 42 |
+
variant="contained"
|
| 43 |
+
sx={{
|
| 44 |
+
width: "100%",
|
| 45 |
+
height: "30px",
|
| 46 |
+
borderRadius: "5%",
|
| 47 |
+
backgroundColor: listening ? "rgb(218, 176, 176)" : "rgb(126, 184, 203)",
|
| 48 |
+
"&:hover": {
|
| 49 |
+
backgroundColor: "rgb(199, 206, 208)",
|
| 50 |
+
transition: "background-color 0.3s ease",
|
| 51 |
+
},
|
| 52 |
+
}}
|
| 53 |
+
>
|
| 54 |
+
{listening ? "STOP" : "SPEAK"}
|
| 55 |
+
</Button>
|
| 56 |
+
</Box>
|
| 57 |
+
</Box>
|
| 58 |
+
);
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
export default VoiceToVoice;
|