Skip to content

Commit

Permalink
delete: stop button :neckbeard:
Browse files Browse the repository at this point in the history
  • Loading branch information
bieshan committed Jan 5, 2021
1 parent 4f06e19 commit 254b385
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Notice from "../components/notice";
import UploadButton from "../components/uploadButton";
import TagField from "../components/tagField";
import TranscriptField from "../components/transcriptField";
import {Android} from "@material-ui/icons";

const Home = () => {
// 音声認識インスタンス
Expand Down Expand Up @@ -49,10 +50,13 @@ const Home = () => {
recognizerRef.current.lang = "ja-JP";
recognizerRef.current.interimResults = true;
recognizerRef.current.continuous = true;
recognizerRef.current.onstart = () => {
setDetecting(true);
};
recognizerRef.current.onend = () => {
if (detecting) {
if (android) {
recognizerRef.current.start();
};
}
};
recognizerRef.current.onresult = event => {
[...event.results].slice(event.resultIndex).forEach(result => {
Expand Down Expand Up @@ -147,35 +151,19 @@ const Home = () => {
</Grid>
<Box m={2}>
<Grid container alignItems="center" justify="center">
<Grid item xs={3}>
<Grid item xs={2}>
<Button
variant="outlined"
disabled={detecting}
color="primary"
size="large"
onClick={() => {
setDetecting(true);
recognizerRef.current.start();
}}
>
{detecting ? "検知中..." : "検知開始"}
</Button>
</Grid>
<Grid item xs={6}/>
<Grid item xs={3}>
<Button
variant="outlined"
disabled={!detecting}
color="secondary"
size="large"
onClick={() => {
setDetecting(false);
recognizerRef.current.stop();
}}
>
{detecting ? "検知停止" : "検知待ち"}
</Button>
</Grid>
</Grid>
</Box>
</Container>
Expand Down

0 comments on commit 254b385

Please sign in to comment.