Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +151 -113
index.html
CHANGED
|
@@ -1,124 +1,162 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
.result-button:hover {
|
| 67 |
-
background-color: #388e3c;
|
| 68 |
-
}
|
| 69 |
-
</style>
|
| 70 |
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 71 |
</head>
|
| 72 |
<body>
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
<script>
|
| 81 |
-
let isRecording = false;
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
| 97 |
}
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
}
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
</body>
|
| 124 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Voice Recorder Interface</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
display: flex;
|
| 10 |
+
flex-direction: column;
|
| 11 |
+
justify-content: center;
|
| 12 |
+
align-items: center;
|
| 13 |
+
height: 100vh;
|
| 14 |
+
margin: 0;
|
| 15 |
+
background-color: #121212;
|
| 16 |
+
color: white;
|
| 17 |
+
}
|
| 18 |
+
.chart {
|
| 19 |
+
width: 300px;
|
| 20 |
+
height: 300px;
|
| 21 |
+
margin-bottom: 20px;
|
| 22 |
+
}
|
| 23 |
+
.record-button {
|
| 24 |
+
position: fixed;
|
| 25 |
+
bottom: 30px;
|
| 26 |
+
width: 80px;
|
| 27 |
+
height: 80px;
|
| 28 |
+
background-color: transparent;
|
| 29 |
+
border-radius: 50%;
|
| 30 |
+
border: 4px solid white;
|
| 31 |
+
display: flex;
|
| 32 |
+
justify-content: center;
|
| 33 |
+
align-items: center;
|
| 34 |
+
cursor: pointer;
|
| 35 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
|
| 36 |
+
transition: all 0.2s ease;
|
| 37 |
+
}
|
| 38 |
+
.record-icon {
|
| 39 |
+
width: 60px;
|
| 40 |
+
height: 60px;
|
| 41 |
+
background-color: #d32f2f;
|
| 42 |
+
border-radius: 50%;
|
| 43 |
+
transition: all 0.2s ease;
|
| 44 |
+
}
|
| 45 |
+
.recording .record-icon {
|
| 46 |
+
width: 40px;
|
| 47 |
+
height: 40px;
|
| 48 |
+
border-radius: 10%;
|
| 49 |
+
}
|
| 50 |
+
.result-button {
|
| 51 |
+
margin-top: 20px;
|
| 52 |
+
padding: 10px 20px;
|
| 53 |
+
background-color: #4caf50;
|
| 54 |
+
border: none;
|
| 55 |
+
border-radius: 5px;
|
| 56 |
+
color: white;
|
| 57 |
+
cursor: pointer;
|
| 58 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
|
| 59 |
+
}
|
| 60 |
+
.result-button:hover {
|
| 61 |
+
background-color: #388e3c;
|
| 62 |
+
}
|
| 63 |
+
</style>
|
| 64 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</head>
|
| 66 |
<body>
|
| 67 |
+
<div class="chart">
|
| 68 |
+
<canvas id="speechChart"></canvas>
|
| 69 |
+
</div>
|
| 70 |
+
<button class="record-button" id="recordButton" onclick="toggleRecording()">
|
| 71 |
+
<div class="record-icon" id="recordIcon"></div>
|
| 72 |
+
</button>
|
| 73 |
+
<button class="result-button" id="resultButton" onclick="showResults()">結果を表示</button>
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
<script>
|
| 76 |
+
let isRecording = false;
|
| 77 |
+
let mediaRecorder;
|
| 78 |
+
let audioChunks = [];
|
| 79 |
+
async function toggleRecording() {
|
| 80 |
+
const recordButton = document.getElementById('recordButton');
|
| 81 |
+
const recordIcon = document.getElementById('recordIcon');
|
| 82 |
+
if (!isRecording) {
|
| 83 |
+
// 録音開始
|
| 84 |
+
isRecording = true;
|
| 85 |
+
recordButton.classList.add('recording');
|
| 86 |
+
try {
|
| 87 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 88 |
+
mediaRecorder = new MediaRecorder(stream);
|
| 89 |
+
audioChunks = [];
|
| 90 |
+
mediaRecorder.ondataavailable = event => {
|
| 91 |
+
if (event.data.size > 0) {
|
| 92 |
+
audioChunks.push(event.data);
|
| 93 |
}
|
| 94 |
+
};
|
| 95 |
+
mediaRecorder.onstop = () => {
|
| 96 |
+
const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
|
| 97 |
+
const reader = new FileReader();
|
| 98 |
+
reader.onloadend = () => {
|
| 99 |
+
const base64String = reader.result.split(',')[1]; // Base64 エンコードされた音声データ
|
| 100 |
+
// サーバーへ音声データを送信
|
| 101 |
+
fetch('/upload_audio', {
|
| 102 |
+
method: 'POST',
|
| 103 |
+
headers: {
|
| 104 |
+
'Content-Type': 'application/json',
|
| 105 |
+
},
|
| 106 |
+
body: JSON.stringify({ audio_data: base64String }),
|
| 107 |
+
})
|
| 108 |
+
.then(response => response.json())
|
| 109 |
+
.then(data => {
|
| 110 |
+
alert('音声がバックエンドに送信されました。');
|
| 111 |
+
})
|
| 112 |
+
.catch(error => {
|
| 113 |
+
console.error('エラー:', error);
|
| 114 |
+
});
|
| 115 |
+
};
|
| 116 |
+
reader.readAsDataURL(audioBlob);
|
| 117 |
+
};
|
| 118 |
+
mediaRecorder.start();
|
| 119 |
+
} catch (error) {
|
| 120 |
+
console.error('マイクへのアクセスに失敗しました:', error);
|
| 121 |
+
isRecording = false;
|
| 122 |
+
recordButton.classList.remove('recording');
|
| 123 |
}
|
| 124 |
+
} else {
|
| 125 |
+
// 録音停止
|
| 126 |
+
isRecording = false;
|
| 127 |
+
recordButton.classList.remove('recording');
|
| 128 |
+
if (mediaRecorder && mediaRecorder.state !== 'inactive') {
|
| 129 |
+
mediaRecorder.stop();
|
| 130 |
}
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
function showResults() {
|
| 134 |
+
window.location.href = 'feedback.html';
|
| 135 |
+
}
|
| 136 |
+
// Chart.js の初期化
|
| 137 |
+
const ctx = document.getElementById('speechChart').getContext('2d');
|
| 138 |
+
const speechChart = new Chart(ctx, {
|
| 139 |
+
type: 'doughnut',
|
| 140 |
+
data: {
|
| 141 |
+
labels: ['自分', '他の人'],
|
| 142 |
+
datasets: [{
|
| 143 |
+
data: [30, 70],
|
| 144 |
+
backgroundColor: ['#4caf50', '#757575'],
|
| 145 |
+
}],
|
| 146 |
+
},
|
| 147 |
+
options: {
|
| 148 |
+
responsive: true,
|
| 149 |
+
plugins: {
|
| 150 |
+
legend: {
|
| 151 |
+
display: true,
|
| 152 |
+
position: 'bottom',
|
| 153 |
+
labels: {
|
| 154 |
+
color: 'white'
|
| 155 |
}
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
});
|
| 160 |
+
</script>
|
| 161 |
</body>
|
| 162 |
</html>
|