muboboev commited on
Commit
d2036ee
·
verified ·
1 Parent(s): 80f35e8

Подэтап 4.2 — AI-анализ эмоций

Browse files

Подключить Whisper для распознавания речи.

Интегрировать Emotion API (TensorFlow / DeepFace).

Рассчитывать Confidence Score (0–100).

components/emotion-analysis.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class EmotionAnalysis extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ :host {
7
+ display: block;
8
+ margin: 1rem 0;
9
+ }
10
+ .container {
11
+ background: rgba(15, 23, 42, 0.7);
12
+ border: 1px solid rgba(255, 255, 255, 0.1);
13
+ border-radius: 0.5rem;
14
+ padding: 1rem;
15
+ }
16
+ .metrics {
17
+ display: grid;
18
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
19
+ gap: 1rem;
20
+ margin-top: 1rem;
21
+ }
22
+ .metric {
23
+ text-align: center;
24
+ }
25
+ .metric-value {
26
+ font-size: 1.2rem;
27
+ font-weight: bold;
28
+ color: #7c3aed;
29
+ }
30
+ .metric-label {
31
+ font-size: 0.8rem;
32
+ color: #94a3b8;
33
+ }
34
+ .confidence-score {
35
+ font-size: 1.5rem;
36
+ font-weight: bold;
37
+ text-align: center;
38
+ margin: 1rem 0;
39
+ background: linear-gradient(90deg, #7c3aed 0%, #2563eb 100%);
40
+ -webkit-background-clip: text;
41
+ background-clip: text;
42
+ color: transparent;
43
+ }
44
+ </style>
45
+ <div class="container">
46
+ <h3>Emotion Analysis</h3>
47
+ <div class="confidence-score">
48
+ Confidence Score: <span id="score">0</span>/100
49
+ </div>
50
+ <div class="metrics">
51
+ <div class="metric">
52
+ <div class="metric-value" id="confidence">0%</div>
53
+ <div class="metric-label">Confidence</div>
54
+ </div>
55
+ <div class="metric">
56
+ <div class="metric-value" id="clarity">0%</div>
57
+ <div class="metric-label">Clarity</div>
58
+ </div>
59
+ <div class="metric">
60
+ <div class="metric-value" id="fluency">0%</div>
61
+ <div class="metric-label">Fluency</div>
62
+ </div>
63
+ <div class="metric">
64
+ <div class="metric-value" id="emotional">0%</div>
65
+ <div class="metric-label">Emotional Impact</div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ `;
70
+ }
71
+
72
+ updateAnalysis(data) {
73
+ if (!this.shadowRoot) return;
74
+
75
+ const { confidence, clarity, fluency, emotionalImpact, confidenceScore } = data;
76
+ this.shadowRoot.getElementById('score').textContent = confidenceScore;
77
+ this.shadowRoot.getElementById('confidence').textContent = `${confidence}%`;
78
+ this.shadowRoot.getElementById('clarity').textContent = `${clarity}%`;
79
+ this.shadowRoot.getElementById('fluency').textContent = `${fluency}%`;
80
+ this.shadowRoot.getElementById('emotional').textContent = `${emotionalImpact}%`;
81
+ }
82
+ }
83
+
84
+ customElements.define('emotion-analysis', EmotionAnalysis);
components/speak-brave-player.js CHANGED
@@ -1,6 +1,18 @@
1
  class SpeakBravePlayer extends HTMLElement {
2
  connectedCallback() {
3
- this.attachShadow({ mode: 'open' });
 
 
 
 
 
 
 
 
 
 
 
 
4
  this.shadowRoot.innerHTML = `
5
  <style>
6
  :host {
@@ -136,17 +148,24 @@ class SpeakBravePlayer extends HTMLElement {
136
  </svg>
137
  Start Recording
138
  </button>
 
 
 
 
 
 
139
  </div>
140
-
141
- <div class="reflection-card">
142
  <h3>Reflection</h3>
143
  <p>How did this challenge make you feel? What did you learn about yourself?</p>
144
  <textarea class="reflection-textarea" placeholder="Write your reflection here..."></textarea>
145
  <button class="submit-btn">Submit Reflection</button>
146
  </div>
 
 
147
  </div>
148
  `;
149
- }
150
  }
151
 
152
  customElements.define('speak-brave-player', SpeakBravePlayer);
 
1
  class SpeakBravePlayer extends HTMLElement {
2
  connectedCallback() {
3
+ this.attachShadow({ mode: 'open'
4
+ // Add event listeners
5
+ this.shadowRoot.getElementById('analyzeBtn').addEventListener('click', async () => {
6
+ const audioBlob = await getRecordingBlob(); // Get recorded audio
7
+ const videoBlob = await getVideoBlob(); // Get recorded video
8
+
9
+ const analysis = await analyzeEmotion(audioBlob, videoBlob);
10
+ if (analysis) {
11
+ this.shadowRoot.getElementById('analysis').updateAnalysis(analysis);
12
+ }
13
+ });
14
+ }
15
+ );
16
  this.shadowRoot.innerHTML = `
17
  <style>
18
  :host {
 
148
  </svg>
149
  Start Recording
150
  </button>
151
+ <button id="analyzeBtn" class="record-btn" style="margin-top: 1rem; background: #2563eb;">
152
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
153
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
154
+ </svg>
155
+ Analyze Emotion
156
+ </button>
157
  </div>
158
+ <div class="reflection-card">
 
159
  <h3>Reflection</h3>
160
  <p>How did this challenge make you feel? What did you learn about yourself?</p>
161
  <textarea class="reflection-textarea" placeholder="Write your reflection here..."></textarea>
162
  <button class="submit-btn">Submit Reflection</button>
163
  </div>
164
+
165
+ <emotion-analysis id="analysis"></emotion-analysis>
166
  </div>
167
  `;
168
+ }
169
  }
170
 
171
  customElements.define('speak-brave-player', SpeakBravePlayer);
learning-engine.html CHANGED
@@ -190,13 +190,23 @@
190
  "timeSpent": 150,
191
  "attempts": 4
192
  },
193
- "speakBraveScore": {
194
- "confidence": 85,
195
- "clarity": 80,
196
- "fluency": 75,
197
- "emotionalImpact": 90
198
- },
199
- "confidence": 85,
 
 
 
 
 
 
 
 
 
 
200
  "completionStatus": "completed",
201
  "masteryPercentage": 78.75
202
  }
 
190
  "timeSpent": 150,
191
  "attempts": 4
192
  },
193
+ "speakBraveScore": {
194
+ "confidence": 85,
195
+ "clarity": 80,
196
+ "fluency": 75,
197
+ "emotionalImpact": 90,
198
+ "transcript": "I believe in my ability to speak English confidently...",
199
+ "emotions": [
200
+ {"emotion": "happy", "score": 0.85},
201
+ {"emotion": "neutral", "score": 0.12},
202
+ {"emotion": "sad", "score": 0.03}
203
+ ],
204
+ "facialExpressions": [
205
+ {"expression": "smile", "intensity": 0.8},
206
+ {"expression": "eyeContact", "intensity": 0.7}
207
+ ]
208
+ },
209
+ "confidence": 85,
210
  "completionStatus": "completed",
211
  "masteryPercentage": 78.75
212
  }
progress-report.html CHANGED
@@ -8,7 +8,8 @@
8
  <script src="https://cdn.tailwindcss.com"></script>
9
  <script src="https://unpkg.com/feather-icons"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
11
- <style>
 
12
  @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
13
 
14
  body {
 
8
  <script src="https://cdn.tailwindcss.com"></script>
9
  <script src="https://unpkg.com/feather-icons"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
11
+ <script src="components/emotion-analysis.js"></script>
12
+ <style>
13
  @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
14
 
15
  body {