Spaces:
Running
Running
buletomato25
commited on
Commit
·
a776d5a
1
Parent(s):
27d15cb
addreset
Browse files- __pycache__/analyze.cpython-310.pyc +0 -0
- __pycache__/process.cpython-310.pyc +0 -0
- __pycache__/transcription.cpython-310.pyc +0 -0
- app.py +10 -0
- static/process.js +258 -248
- templates/feedback.html +72 -32
- templates/reset.html +41 -0
- templates/talkDetail.html +1 -1
__pycache__/analyze.cpython-310.pyc
CHANGED
Binary files a/__pycache__/analyze.cpython-310.pyc and b/__pycache__/analyze.cpython-310.pyc differ
|
|
__pycache__/process.cpython-310.pyc
CHANGED
Binary files a/__pycache__/process.cpython-310.pyc and b/__pycache__/process.cpython-310.pyc differ
|
|
__pycache__/transcription.cpython-310.pyc
CHANGED
Binary files a/__pycache__/transcription.cpython-310.pyc and b/__pycache__/transcription.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -48,6 +48,16 @@ def userregister():
|
|
48 |
def confirm():
|
49 |
return jsonify({'members': users}), 200
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# 書き起こし作成エンドポイント
|
52 |
@app.route('/transcription',methods =['GET','POST'])
|
53 |
def transcription():
|
|
|
48 |
def confirm():
|
49 |
return jsonify({'members': users}), 200
|
50 |
|
51 |
+
#リセット画面(テンプレート: reset.html)
|
52 |
+
@app.route('/reset_html', methods=['GET', 'POST'])
|
53 |
+
def reset_html():
|
54 |
+
return render_template('reset.html')
|
55 |
+
#メンバー削除
|
56 |
+
@app.route('/reset_member', methods=['GET', 'POST'])
|
57 |
+
def reset():
|
58 |
+
users.clear()
|
59 |
+
return render_template('index.html', users = users)
|
60 |
+
|
61 |
# 書き起こし作成エンドポイント
|
62 |
@app.route('/transcription',methods =['GET','POST'])
|
63 |
def transcription():
|
static/process.js
CHANGED
@@ -1,255 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
let baseMemberColors = ["#4caf50", "#007bff", "#ffc107", "#dc3545", "#28a745", "#9c27b0", "#ff9800"];
|
13 |
-
// Chart.js の初期化
|
14 |
-
const ctx = document.getElementById("speechChart").getContext("2d");
|
15 |
-
const speechChart = new Chart(ctx, {
|
16 |
-
type: "doughnut",
|
17 |
-
data: {
|
18 |
-
labels: members,
|
19 |
-
datasets: [
|
20 |
-
{
|
21 |
-
data: voiceData,
|
22 |
-
backgroundColor: getMemberColors(members.length),
|
23 |
-
},
|
24 |
-
],
|
25 |
-
},
|
26 |
-
options: {
|
27 |
-
responsive: true,
|
28 |
-
plugins: {
|
29 |
-
legend: {
|
30 |
-
display: true,
|
31 |
-
position: "bottom",
|
32 |
-
labels: { color: "white" },
|
33 |
-
},
|
34 |
-
},
|
35 |
-
},
|
36 |
-
});
|
37 |
-
// サーバーからメンバー情報を取得してチャートを更新する関数
|
38 |
-
async function updateChartFrom() {
|
39 |
-
try {
|
40 |
-
const response = await fetch("/confirm");
|
41 |
-
if (!response.ok) {
|
42 |
-
throw new Error(`HTTP error! status: ${response.status}`);
|
43 |
-
}
|
44 |
-
const data = await response.json();
|
45 |
-
if (!data || !data.members || !Array.isArray(data.members)) {
|
46 |
-
console.error("Invalid member data received:", data);
|
47 |
-
members = ["member1"];
|
48 |
-
voiceData = [50, 50];
|
49 |
-
updateChart();
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
members = data.members;
|
53 |
-
voiceData = [];
|
54 |
-
for (let i = 0; i < members.length; i++) {
|
55 |
-
voiceData.push(100 / members.length);
|
56 |
-
}
|
57 |
-
updateChart();
|
58 |
-
} catch (error) {
|
59 |
-
console.error("Failed to fetch member data:", error);
|
60 |
-
members = ["member1"];
|
61 |
-
voiceData = [50, 50];
|
62 |
-
updateChart();
|
63 |
-
}
|
64 |
-
}
|
65 |
-
function updateChart() {
|
66 |
-
// 一人モードの場合は、ユーザーとグレー(無音)の比率をチャートに表示
|
67 |
-
if (members.length === 1) {
|
68 |
-
const userName = members[0];
|
69 |
-
speechChart.data.labels = [userName, "無音"];
|
70 |
-
speechChart.data.datasets[0].backgroundColor = ["#4caf50", "#757575"];
|
71 |
-
} else {
|
72 |
-
// 複数メンバーの場合は通常通りの処理
|
73 |
-
speechChart.data.labels = members;
|
74 |
-
speechChart.data.datasets[0].backgroundColor = getMemberColors(members.length);
|
75 |
-
}
|
76 |
-
speechChart.data.datasets[0].data = voiceData;
|
77 |
-
speechChart.update();
|
78 |
-
}
|
79 |
-
// メニューの表示・非表示
|
80 |
-
function toggleMenu(event) {
|
81 |
-
event.stopPropagation();
|
82 |
-
const menu = document.getElementById("menu");
|
83 |
-
menu.classList.toggle("open");
|
84 |
-
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
!menu.contains(event.target) &&
|
91 |
-
!event.target.closest("#menuButton")
|
92 |
-
) {
|
93 |
-
menu.classList.remove("open");
|
94 |
-
}
|
95 |
-
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
mediaRecorder = new MediaRecorder(stream);
|
114 |
-
audioChunks = [];
|
115 |
-
mediaRecorder.ondataavailable = (event) => {
|
116 |
-
if (event.data.size > 0) {
|
117 |
-
audioChunks.push(event.data);
|
118 |
-
}
|
119 |
-
};
|
120 |
-
mediaRecorder.onstop = () => {
|
121 |
-
sendAudioChunks([...audioChunks]);
|
122 |
-
audioChunks = [];
|
123 |
-
};
|
124 |
-
mediaRecorder.start();
|
125 |
-
// 5秒ごとに録音を停止して送信するインターバルを設定
|
126 |
-
recordingInterval = setInterval(() => {
|
127 |
-
if (mediaRecorder && mediaRecorder.state === "recording") {
|
128 |
-
mediaRecorder.stop();
|
129 |
-
mediaRecorder.start();
|
130 |
-
}
|
131 |
-
}, RECORDING_INTERVAL_MS);
|
132 |
-
} catch (error) {
|
133 |
-
console.error("マイクへのアクセスに失敗しました:", error);
|
134 |
-
isRecording = false;
|
135 |
-
recordButton.classList.remove("recording");
|
136 |
-
}
|
137 |
-
} else {
|
138 |
-
// 録音停止
|
139 |
-
isRecording = false;
|
140 |
-
recordButton.classList.remove("recording");
|
141 |
-
if (mediaRecorder && mediaRecorder.state === "recording") {
|
142 |
-
mediaRecorder.stop();
|
143 |
-
}
|
144 |
-
clearInterval(recordingInterval);
|
145 |
-
count_voice = 0;
|
146 |
-
//before_rate = [];
|
147 |
}
|
148 |
-
}
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
headers: { "Content-Type": "application/json" },
|
160 |
-
body: JSON.stringify({ audio_data: base64String, name: name }),
|
161 |
-
})
|
162 |
-
.then((response) => response.json())
|
163 |
-
.then((data) => {
|
164 |
-
if (data.error) {
|
165 |
-
alert("エラー: " + data.error);
|
166 |
-
console.error(data.details);
|
167 |
-
} else if (data.rate !== undefined) {
|
168 |
-
updateChartData(data.rate);
|
169 |
-
} else if (data.rates !== undefined) {
|
170 |
-
updateChartData(data.rates);
|
171 |
-
}
|
172 |
-
})
|
173 |
-
.catch((error) => {
|
174 |
-
console.error("エラー:", error);
|
175 |
-
});
|
176 |
-
};
|
177 |
-
reader.readAsDataURL(audioBlob);
|
178 |
-
}
|
179 |
-
function getMemberColors(memberCount) {
|
180 |
-
// 一人モードの場合は特別な処理をしない(updateChartで処理するため)
|
181 |
-
if (memberCount <= 1) {
|
182 |
-
return ["#4caf50", "#757575"];
|
183 |
-
} else {
|
184 |
-
let colors = [];
|
185 |
-
for (let i = 0; i < memberCount; i++) {
|
186 |
-
colors.push(baseMemberColors[i % baseMemberColors.length]);
|
187 |
-
}
|
188 |
-
return colors;
|
189 |
}
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
tmp_rate = (newRate[i] + before_rate[i] * count_voice) / (count_voice + 1);
|
231 |
-
}
|
232 |
-
averagedRates[i] = tmp_rate;
|
233 |
-
}
|
234 |
-
// before_rateを更新
|
235 |
-
before_rate = averagedRates;
|
236 |
-
//グラフに反映
|
237 |
-
speechChart.data.datasets[0].data = averagedRates;
|
238 |
-
count_voice++;
|
239 |
-
speechChart.data.datasets[0].backgroundColor = getMemberColors(
|
240 |
-
members.length
|
241 |
-
);
|
242 |
}
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let isRecording = false;
|
2 |
+
let mediaRecorder;
|
3 |
+
let audioChunks = [];
|
4 |
+
let recordingInterval;
|
5 |
+
let count_voice = 0;
|
6 |
+
let before_rate = [];
|
7 |
+
const RECORDING_INTERVAL_MS = 1000; // 5秒
|
8 |
+
// メンバーとチャートの初期化
|
9 |
+
let members = [];
|
10 |
+
let voiceData = [];
|
11 |
+
let baseMemberColors = [
|
12 |
+
"#4caf50",
|
13 |
+
"#007bff",
|
14 |
+
"#ffc107",
|
15 |
+
"#dc3545",
|
16 |
+
"#28a745",
|
17 |
+
"#9c27b0",
|
18 |
+
"#ff9800",
|
19 |
+
];
|
20 |
+
// Chart.js の初期化
|
21 |
+
const ctx = document.getElementById("speechChart").getContext("2d");
|
22 |
+
const speechChart = new Chart(ctx, {
|
23 |
+
type: "doughnut",
|
24 |
+
data: {
|
25 |
+
labels: members,
|
26 |
+
datasets: [
|
27 |
+
{
|
28 |
+
data: voiceData,
|
29 |
+
backgroundColor: getMemberColors(members.length),
|
30 |
+
},
|
31 |
+
],
|
32 |
+
},
|
33 |
+
options: {
|
34 |
+
responsive: true,
|
35 |
+
plugins: {
|
36 |
+
legend: {
|
37 |
+
display: true,
|
38 |
+
position: "bottom",
|
39 |
+
labels: { color: "white" },
|
40 |
+
},
|
41 |
+
},
|
42 |
+
},
|
43 |
+
});
|
44 |
+
// サーバーからメンバー情報を取得してチャートを更新する関数
|
45 |
+
async function updateChartFrom() {
|
46 |
+
try {
|
47 |
+
const response = await fetch("/confirm");
|
48 |
+
if (!response.ok) {
|
49 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
50 |
+
}
|
51 |
+
const data = await response.json();
|
52 |
+
if (!data || !data.members || !Array.isArray(data.members)) {
|
53 |
+
console.error("Invalid member data received:", data);
|
54 |
+
members = ["member1"];
|
55 |
+
voiceData = [50, 50];
|
56 |
+
updateChart();
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
members = data.members;
|
60 |
+
voiceData = [];
|
61 |
+
for (let i = 0; i < members.length; i++) {
|
62 |
+
voiceData.push(100 / members.length);
|
63 |
+
}
|
64 |
+
updateChart();
|
65 |
+
} catch (error) {
|
66 |
+
console.error("Failed to fetch member data:", error);
|
67 |
+
members = ["member1"];
|
68 |
+
voiceData = [50, 50];
|
69 |
+
updateChart();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
function updateChart() {
|
73 |
+
// 一人モードの場合は、ユーザーとグレー(無音)の比率をチャートに表示
|
74 |
+
if (members.length === 1) {
|
75 |
+
const userName = members[0];
|
76 |
+
speechChart.data.labels = [userName, "無音"];
|
77 |
+
speechChart.data.datasets[0].backgroundColor = ["#4caf50", "#757575"];
|
78 |
+
} else {
|
79 |
+
// 複数メンバーの場合は通常通りの処理
|
80 |
+
speechChart.data.labels = members;
|
81 |
+
speechChart.data.datasets[0].backgroundColor = getMemberColors(
|
82 |
+
members.length
|
83 |
+
);
|
84 |
+
}
|
85 |
+
speechChart.data.datasets[0].data = voiceData;
|
86 |
+
speechChart.update();
|
87 |
+
}
|
88 |
+
// メニューの表示・非表示
|
89 |
+
function toggleMenu(event) {
|
90 |
+
event.stopPropagation();
|
91 |
+
const menu = document.getElementById("menu");
|
92 |
+
menu.classList.toggle("open");
|
93 |
+
}
|
94 |
|
95 |
+
function closeMenu(event) {
|
96 |
+
const menu = document.getElementById("menu");
|
97 |
+
if (
|
98 |
+
menu.classList.contains("open") &&
|
99 |
+
!menu.contains(event.target) &&
|
100 |
+
!event.target.closest("#menuButton")
|
101 |
+
) {
|
102 |
+
menu.classList.remove("open");
|
103 |
+
}
|
104 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
+
// リセットボタンの処理
|
107 |
+
function resetAction() {
|
108 |
+
window.location.href = "reset_html";
|
109 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
+
// ページ読み込み時にチャート情報を更新
|
112 |
+
updateChartFrom();
|
113 |
+
// 録音ボタンの録音開始/停止処理
|
114 |
+
async function toggleRecording() {
|
115 |
+
const recordButton = document.getElementById("recordButton");
|
116 |
+
if (!isRecording) {
|
117 |
+
// 録音開始
|
118 |
+
isRecording = true;
|
119 |
+
recordButton.classList.add("recording");
|
120 |
+
try {
|
121 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
122 |
+
mediaRecorder = new MediaRecorder(stream);
|
123 |
+
audioChunks = [];
|
124 |
+
mediaRecorder.ondataavailable = (event) => {
|
125 |
+
if (event.data.size > 0) {
|
126 |
+
audioChunks.push(event.data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
+
};
|
129 |
+
mediaRecorder.onstop = () => {
|
130 |
+
sendAudioChunks([...audioChunks]);
|
131 |
+
audioChunks = [];
|
132 |
+
};
|
133 |
+
mediaRecorder.start();
|
134 |
+
// 5秒ごとに録音を停止して送信するインターバルを設定
|
135 |
+
recordingInterval = setInterval(() => {
|
136 |
+
if (mediaRecorder && mediaRecorder.state === "recording") {
|
137 |
+
mediaRecorder.stop();
|
138 |
+
mediaRecorder.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
+
}, RECORDING_INTERVAL_MS);
|
141 |
+
} catch (error) {
|
142 |
+
console.error("マイクへのアクセスに失敗しました:", error);
|
143 |
+
isRecording = false;
|
144 |
+
recordButton.classList.remove("recording");
|
145 |
+
}
|
146 |
+
} else {
|
147 |
+
// 録音停止
|
148 |
+
isRecording = false;
|
149 |
+
recordButton.classList.remove("recording");
|
150 |
+
if (mediaRecorder && mediaRecorder.state === "recording") {
|
151 |
+
mediaRecorder.stop();
|
152 |
+
}
|
153 |
+
clearInterval(recordingInterval);
|
154 |
+
count_voice = 0;
|
155 |
+
//before_rate = [];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
function sendAudioChunks(chunks) {
|
159 |
+
const audioBlob = new Blob(chunks, { type: "audio/wav" });
|
160 |
+
const reader = new FileReader();
|
161 |
+
reader.onloadend = () => {
|
162 |
+
const base64String = reader.result.split(",")[1];
|
163 |
+
const form = document.getElementById("recordForm");
|
164 |
+
const nameInput = form.querySelector('input[name="name"]');
|
165 |
+
const name = nameInput ? nameInput.value : "unknown";
|
166 |
+
fetch("/upload_audio", {
|
167 |
+
method: "POST",
|
168 |
+
headers: { "Content-Type": "application/json" },
|
169 |
+
body: JSON.stringify({ audio_data: base64String, name: name }),
|
170 |
+
})
|
171 |
+
.then((response) => response.json())
|
172 |
+
.then((data) => {
|
173 |
+
if (data.error) {
|
174 |
+
alert("エラー: " + data.error);
|
175 |
+
console.error(data.details);
|
176 |
+
} else if (data.rate !== undefined) {
|
177 |
+
updateChartData(data.rate);
|
178 |
+
} else if (data.rates !== undefined) {
|
179 |
+
updateChartData(data.rates);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
181 |
+
})
|
182 |
+
.catch((error) => {
|
183 |
+
console.error("エラー:", error);
|
184 |
+
});
|
185 |
+
};
|
186 |
+
reader.readAsDataURL(audioBlob);
|
187 |
+
}
|
188 |
+
function getMemberColors(memberCount) {
|
189 |
+
// 一人モードの場合は特別な処理をしない(updateChartで処理するため)
|
190 |
+
if (memberCount <= 1) {
|
191 |
+
return ["#4caf50", "#757575"];
|
192 |
+
} else {
|
193 |
+
let colors = [];
|
194 |
+
for (let i = 0; i < memberCount; i++) {
|
195 |
+
colors.push(baseMemberColors[i % baseMemberColors.length]);
|
196 |
+
}
|
197 |
+
return colors;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
function updateChartData(newRate) {
|
201 |
+
// 一人モードの時の処理
|
202 |
+
if (members.length === 1) {
|
203 |
+
if (count_voice === 0) {
|
204 |
+
speechChart.data.datasets[0].data = [newRate, 100 - newRate];
|
205 |
+
before_rate = [newRate];
|
206 |
+
} else {
|
207 |
+
// 一人モードでは、過去のデータと現在のデータを加重平均する
|
208 |
+
let tmp_rate =
|
209 |
+
(newRate + before_rate[0] * count_voice) / (count_voice + 1);
|
210 |
+
speechChart.data.datasets[0].data = [tmp_rate, 100 - tmp_rate];
|
211 |
+
before_rate = [tmp_rate];
|
212 |
+
}
|
213 |
+
count_voice++;
|
214 |
+
// 一人モードでは常に緑色とグレーの組み合わせを使用
|
215 |
+
speechChart.data.labels = [members[0], "無音"];
|
216 |
+
speechChart.data.datasets[0].backgroundColor = ["#4caf50", "#757575"];
|
217 |
+
} else {
|
218 |
+
console.log(before_rate);
|
219 |
+
// 複数人モードの処理
|
220 |
+
if (!Array.isArray(newRate)) {
|
221 |
+
console.error("newRate is not an array:", newRate);
|
222 |
+
return;
|
223 |
+
}
|
224 |
+
if (newRate.length !== members.length) {
|
225 |
+
console.error(
|
226 |
+
"newRate length does not match members length:",
|
227 |
+
newRate,
|
228 |
+
members
|
229 |
+
);
|
230 |
+
return;
|
231 |
+
}
|
232 |
+
let averagedRates = new Array(newRate.length);
|
233 |
+
for (let i = 0; i < newRate.length; i++) {
|
234 |
+
let tmp_rate;
|
235 |
+
if (count_voice === 0) {
|
236 |
+
// 初回はそのまま
|
237 |
+
tmp_rate = newRate[i];
|
238 |
+
} else {
|
239 |
+
// 2回目以降は、過去の平均値と現在の値を加重平均する
|
240 |
+
tmp_rate =
|
241 |
+
(newRate[i] + before_rate[i] * count_voice) / (count_voice + 1);
|
242 |
}
|
243 |
+
averagedRates[i] = tmp_rate;
|
244 |
+
}
|
245 |
+
// before_rateを更新
|
246 |
+
before_rate = averagedRates;
|
247 |
+
//グラフに反映
|
248 |
+
speechChart.data.datasets[0].data = averagedRates;
|
249 |
+
count_voice++;
|
250 |
+
speechChart.data.datasets[0].backgroundColor = getMemberColors(
|
251 |
+
members.length
|
252 |
+
);
|
253 |
+
}
|
254 |
+
speechChart.update();
|
255 |
+
}
|
256 |
+
function showTalkdetail() {
|
257 |
+
window.location.href = "talk_detail";
|
258 |
+
}
|
259 |
+
function showResults() {
|
260 |
+
window.location.href = "feedback";
|
261 |
+
}
|
262 |
+
function showUserRegister() {
|
263 |
+
fetch("/reset");
|
264 |
+
window.location.href = "userregister";
|
265 |
+
}
|
templates/feedback.html
CHANGED
@@ -19,51 +19,76 @@
|
|
19 |
return "素晴らしい";
|
20 |
}
|
21 |
|
22 |
-
async function getTranscription(){
|
23 |
-
try{
|
24 |
-
const response = await fetch(
|
25 |
-
if(!response.ok){
|
26 |
-
throw new Error(
|
27 |
}
|
28 |
const data = await response.json;
|
29 |
const results = data.response;
|
30 |
-
}catch(error){
|
31 |
-
console.error("Failed to fetch transcription",error);
|
32 |
}
|
33 |
}
|
34 |
|
35 |
async function getAnalysis() {
|
36 |
try {
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
} catch (error) {
|
60 |
-
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
|
65 |
window.onload = getAnalysis();
|
66 |
-
|
67 |
function showSampleData() {
|
68 |
const level = 73;
|
69 |
const percentages = [80, 50, 60, 100, 30];
|
@@ -79,7 +104,7 @@
|
|
79 |
barElements[i].style.width = `${percentages[i]}%`;
|
80 |
labelElements[i].innerText = labels[i];
|
81 |
}
|
82 |
-
}
|
83 |
|
84 |
function showRecorder() {
|
85 |
window.location.href = "index";
|
@@ -93,9 +118,23 @@
|
|
93 |
class="flex items-center justify-center min-h-screen bg-gray-900 text-white"
|
94 |
>
|
95 |
<div class="p-8 bg-gray-800 rounded-2xl shadow-xl text-center w-96">
|
96 |
-
<div class="text-3xl font-bold mb-4" id="level">話者Lv
|
97 |
-
<div class="text-xl font-semibold mb-6" id="
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
<div class="space-y-2">
|
100 |
<div class="bar-container flex items-center">
|
101 |
<span class="bar-label w-20 mr-2"></span>
|
@@ -128,6 +167,7 @@
|
|
128 |
</div>
|
129 |
</div>
|
130 |
</div>
|
|
|
131 |
|
132 |
<div class="flex justify-center space-x-4 mt-6">
|
133 |
<button
|
|
|
19 |
return "素晴らしい";
|
20 |
}
|
21 |
|
22 |
+
async function getTranscription() {
|
23 |
+
try {
|
24 |
+
const response = await fetch("/transcription");
|
25 |
+
if (!response.ok) {
|
26 |
+
throw new Error("HTTP error! status: ${response.status}");
|
27 |
}
|
28 |
const data = await response.json;
|
29 |
const results = data.response;
|
30 |
+
} catch (error) {
|
31 |
+
console.error("Failed to fetch transcription", error);
|
32 |
}
|
33 |
}
|
34 |
|
35 |
async function getAnalysis() {
|
36 |
try {
|
37 |
+
await getTranscription();
|
38 |
|
39 |
+
const response = await fetch("/analyze");
|
40 |
+
if (!response.ok) {
|
41 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
42 |
+
}
|
43 |
|
44 |
+
const data = await response.json();
|
45 |
+
const results = data.results;
|
46 |
+
const analysis = results.deepseek_analysis;
|
47 |
|
48 |
+
// 変数に格納
|
49 |
+
const conversationLevel = analysis.conversationLevel;
|
50 |
+
const harassmentPresent = analysis.harassmentPresent;
|
51 |
+
const harassmentType = analysis.harassmentType;
|
52 |
+
const repetition = analysis.repetition;
|
53 |
+
const pleasantConversation = analysis.pleasantConversation;
|
54 |
+
const blameOrHarassment = analysis.blameOrHarassment;
|
55 |
|
56 |
+
// コンソールに表示
|
57 |
+
console.log(
|
58 |
+
conversationLevel,
|
59 |
+
harassmentPresent,
|
60 |
+
harassmentType,
|
61 |
+
repetition,
|
62 |
+
pleasantConversation,
|
63 |
+
blameOrHarassment
|
64 |
+
);
|
65 |
|
66 |
+
// DOMに表示
|
67 |
+
document.getElementById(
|
68 |
+
"level"
|
69 |
+
).innerText = `会話レベル: ${conversationLevel}`;
|
70 |
+
document.getElementById(
|
71 |
+
"Harassment_bool"
|
72 |
+
).innerText = `ハラスメントの有無: ${harassmentPresent}`;
|
73 |
+
document.getElementById(
|
74 |
+
"Harassment_type"
|
75 |
+
).innerText = `ハラスメントの種類: ${harassmentType}`;
|
76 |
+
document.getElementById(
|
77 |
+
"Harassment_loop"
|
78 |
+
).innerText = `繰り返しの程度: ${repetition}`;
|
79 |
+
document.getElementById(
|
80 |
+
"Harassment_comfort"
|
81 |
+
).innerText = `会話の心地よさ: ${pleasantConversation}`;
|
82 |
+
document.getElementById(
|
83 |
+
"Harassment_volume"
|
84 |
+
).innerText = `非難またはハラスメントの程度: ${blameOrHarassment}`;
|
85 |
} catch (error) {
|
86 |
+
console.error("Failed to fetch analysis data:", error);
|
87 |
}
|
88 |
+
}
|
|
|
89 |
|
90 |
window.onload = getAnalysis();
|
91 |
+
|
92 |
function showSampleData() {
|
93 |
const level = 73;
|
94 |
const percentages = [80, 50, 60, 100, 30];
|
|
|
104 |
barElements[i].style.width = `${percentages[i]}%`;
|
105 |
labelElements[i].innerText = labels[i];
|
106 |
}
|
107 |
+
}
|
108 |
|
109 |
function showRecorder() {
|
110 |
window.location.href = "index";
|
|
|
118 |
class="flex items-center justify-center min-h-screen bg-gray-900 text-white"
|
119 |
>
|
120 |
<div class="p-8 bg-gray-800 rounded-2xl shadow-xl text-center w-96">
|
121 |
+
<div class="text-3xl font-bold mb-4" id="level">話者Lv:</div>
|
122 |
+
<div class="text-xl font-semibold mb-6" id="Harassment_bool">
|
123 |
+
素晴らしい
|
124 |
+
</div>
|
125 |
+
<div class="text-xl font-semibold mb-6" id="Harassment_type">
|
126 |
+
素晴らしい
|
127 |
+
</div>
|
128 |
+
<div class="text-xl font-semibold mb-6" id="Harassment_loop">
|
129 |
+
素晴らしい
|
130 |
+
</div>
|
131 |
+
<div class="text-xl font-semibold mb-6" id="Harassment_comfort">
|
132 |
+
素晴らしい
|
133 |
+
</div>
|
134 |
+
<div class="text-xl font-semibold mb-6" id="Harassment_volume">
|
135 |
+
素晴らしい
|
136 |
+
</div>
|
137 |
+
<!--
|
138 |
<div class="space-y-2">
|
139 |
<div class="bar-container flex items-center">
|
140 |
<span class="bar-label w-20 mr-2"></span>
|
|
|
167 |
</div>
|
168 |
</div>
|
169 |
</div>
|
170 |
+
-->
|
171 |
|
172 |
<div class="flex justify-center space-x-4 mt-6">
|
173 |
<button
|
templates/reset.html
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="ja" class="dark">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>リセット画面</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
</head>
|
9 |
+
<body
|
10 |
+
class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 min-h-screen flex items-center justify-center"
|
11 |
+
>
|
12 |
+
<div
|
13 |
+
class="container mx-auto p-6 bg-white dark:bg-gray-800 shadow-lg rounded-2xl"
|
14 |
+
>
|
15 |
+
<h2 class="text-2xl font-semibold mb-4">メンバーを消去しますか?</h2>
|
16 |
+
|
17 |
+
<div class="flex justify-center gap-4">
|
18 |
+
<button
|
19 |
+
class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
20 |
+
onclick="showReset()"
|
21 |
+
>
|
22 |
+
メンバーを消去
|
23 |
+
</button>
|
24 |
+
<button
|
25 |
+
class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
26 |
+
onclick="showRecorder()"
|
27 |
+
>
|
28 |
+
録音画面を表示
|
29 |
+
</button>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
<script>
|
33 |
+
function showRecorder() {
|
34 |
+
window.location.href = "/index";
|
35 |
+
}
|
36 |
+
function showReset() {
|
37 |
+
window.location.href = "/reset_member";
|
38 |
+
}
|
39 |
+
</script>
|
40 |
+
</body>
|
41 |
+
</html>
|
templates/talkDetail.html
CHANGED
@@ -39,7 +39,7 @@
|
|
39 |
const transcriptionElement = document.getElementById("transcription");
|
40 |
|
41 |
try {
|
42 |
-
const response = await fetch("/
|
43 |
if (!response.ok) throw new Error("データ取得に失敗しました。");
|
44 |
|
45 |
const data = await response.json();
|
|
|
39 |
const transcriptionElement = document.getElementById("transcription");
|
40 |
|
41 |
try {
|
42 |
+
const response = await fetch("/transcription");
|
43 |
if (!response.ok) throw new Error("データ取得に失敗しました。");
|
44 |
|
45 |
const data = await response.json();
|