parent
147114b444
commit
7ab77e94ae
14 changed files with 244 additions and 76 deletions
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 567 B |
After Width: | Height: | Size: 984 B |
After Width: | Height: | Size: 929 B |
@ -0,0 +1,74 @@ |
||||
.vocal-modal{ |
||||
width: 100vw; |
||||
height: 100vh; |
||||
position: fixed; |
||||
top : 0px; |
||||
left: 0px; |
||||
background-color: rgba(0, 0, 0, 0.822); |
||||
align-items: center; |
||||
justify-content: center; |
||||
z-index: 1000; |
||||
&__back{ |
||||
position: fixed; |
||||
top: 20px; |
||||
left: 12px; |
||||
z-index: 200; |
||||
} |
||||
h1,h2{ |
||||
margin: 20px auto 0px; |
||||
width: fit-content; |
||||
} |
||||
h1{ |
||||
color: white; |
||||
font-family: numeralLight; |
||||
font-size: calc(100vw / 20); |
||||
} |
||||
h2{ |
||||
color: rgb(196, 196, 196); |
||||
font-family: numeralLight; |
||||
font-size: calc(100vw / 24); |
||||
position: fixed; |
||||
bottom: 70px; |
||||
left: 50%; |
||||
background-color: rgba(255, 255, 255, 0.062); |
||||
padding: 10px 15px; |
||||
border-radius: 10px; |
||||
transform: translate(-50% , 0px); |
||||
} |
||||
&__content{ |
||||
width : calc(100% - 60px); |
||||
height: 320px; |
||||
border-radius: 5px; |
||||
margin-left: auto; |
||||
margin-right: auto; |
||||
padding : 4px 10px; |
||||
&--toggle{ |
||||
width: 140px; |
||||
height: 140px; |
||||
align-items: center; |
||||
border-radius: 100px; |
||||
margin : 20px auto; |
||||
svg{ |
||||
margin : 0px auto; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
.vocal-modal__content--input .MuiFormControl-root{ |
||||
border : none !important; |
||||
} |
||||
|
||||
.vocal-modal__content--input{ |
||||
margin-top: 20px; |
||||
} |
||||
|
||||
.vocal-modal__content--input input{ |
||||
width: 100%; |
||||
border : none; |
||||
font-size: 22px; |
||||
color: #707070; |
||||
} |
@ -0,0 +1,71 @@ |
||||
import React, { useState, useEffect } from "react"; |
||||
import SpeechRecognition, { |
||||
useSpeechRecognition, |
||||
} from "react-speech-recognition"; |
||||
import { toast } from "react-toastify"; |
||||
import MicIcon from "@material-ui/icons/Mic"; |
||||
import TextField from "@material-ui/core/TextField"; |
||||
|
||||
import line1 from "../../assets/icons/line1.png"; |
||||
import line2 from "../../assets/icons/line2.png"; |
||||
import arrowLeft from "../../assets/icons/arrow-left.png"; |
||||
|
||||
import "./Vocal.scss"; |
||||
import { stat } from "fs"; |
||||
|
||||
const Vocal = (props: any) => { |
||||
const { transcript, resetTranscript } = useSpeechRecognition(); |
||||
const [flag, setFlag] = useState(false); |
||||
const [pause, setPause] = useState(false); |
||||
|
||||
const start = () => { |
||||
setPause(false); |
||||
SpeechRecognition.startListening({ language: "fa_IR" }); |
||||
setTimeout(() => { |
||||
if (true) { |
||||
SpeechRecognition.stopListening(); |
||||
setPause(true); |
||||
} |
||||
}, 5000); |
||||
}; |
||||
|
||||
useEffect(() => { |
||||
if (!flag) { |
||||
resetTranscript(); |
||||
setFlag(() => true); |
||||
start(); |
||||
} |
||||
}); |
||||
|
||||
useEffect(() => { |
||||
props.setInputValue(() => transcript); |
||||
}, [transcript]); |
||||
|
||||
return ( |
||||
<div className="vocal-modal d-flex"> |
||||
<img src={arrowLeft} className="vocal-modal__back" onClick={() => props.setVocal(false)} /> |
||||
<div className="vocal-modal__content d-flex flex-column"> |
||||
<div className="vocal-modal__content--toggle d-flex justify-content-center aling-items-center"> |
||||
<img src={line2} onClick={(e) => start()} /> |
||||
<img |
||||
src={line1} |
||||
style={{ transform: "translateX(5px)" }} |
||||
onClick={(e) => start()} |
||||
/> |
||||
</div> |
||||
<div className="vocal-modal__content--input"> |
||||
{pause ? ( |
||||
<h2> |
||||
چیزی نشنیدیم :( |
||||
<br /> |
||||
روی آیکن موج بزنید تا دوباره امتحان کنید. |
||||
</h2> |
||||
) : ( |
||||
<h1>در حال گوش کردن ...</h1> |
||||
)} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
); |
||||
}; |
||||
export default Vocal; |
@ -1 +1,2 @@ |
||||
declare module '3d-react-carousal'; |
||||
declare module '3d-react-carousal'; |
||||
declare module 'react-speech-recognition'; |
Loading…
Reference in new issue