1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00

feat: 会話の割合表示機能追加

This commit is contained in:
kohei 2018-11-19 16:41:05 +09:00
parent 5c28ad7fa0
commit 535ab0cd42
2 changed files with 31 additions and 0 deletions

29
components/percentage.jsx Normal file
View file

@ -0,0 +1,29 @@
import { Component } from "react";
export default class extends Component {
render() {
const leftActivity = this.props.activity
.filter(a => a.ch === "l")
.map(a => a.endTime - a.startTime)
.reduce((a, c) => a + c, 0);
const rightActivity = this.props.activity
.filter(a => a.ch === "r")
.map(a => a.endTime - a.startTime)
.reduce((a, c) => a + c, 0);
return (
<dl>
<dt>会話時間 (ms)</dt>
<dd>{leftActivity + rightActivity}</dd>
<dt>会話の割合</dt>
<dd>
{" "}
<meter value={leftActivity / (leftActivity + rightActivity)}>
{leftActivity / (leftActivity + rightActivity)}
</meter>{" "}
</dd>
</dl>
);
}
}

View file

@ -1,5 +1,6 @@
import { Component } from "react"; import { Component } from "react";
import * as _VAD from "vad.js/lib/vad.js"; import * as _VAD from "vad.js/lib/vad.js";
import Percentage from "./percentage";
import Kaburi from "./kaburi"; import Kaburi from "./kaburi";
export default class extends Component { export default class extends Component {
@ -109,6 +110,7 @@ export default class extends Component {
<dt></dt> <dt></dt>
<dd>{this.state.right && "発話中..."}</dd> <dd>{this.state.right && "発話中..."}</dd>
</dl> </dl>
<Percentage activity={this.state.activity} />
<Kaburi activity={this.state.activity} /> <Kaburi activity={this.state.activity} />
</div> </div>
); );