Ranam Hamoud commited on
Commit
d679d88
·
1 Parent(s): abca05b

Add interpretations to linguistic metrics display

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -220,6 +220,19 @@ def build_speech_patterns_display(asr):
220
 
221
  kf = asr['kopparapu_features']
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  output += f"""
224
  <div style="background: linear-gradient(135deg, {class_bg} 0%, white 100%); border-radius: 16px; padding: 24px; margin-bottom: 20px; border: 1px solid {class_color}33;">
225
  <h3 style="margin: 0; color: {class_color}; font-size: 22px; font-weight: 700;">{classification} SPEECH</h3>
@@ -233,20 +246,24 @@ def build_speech_patterns_display(asr):
233
  <h4 style="margin: 0 0 16px 0; color: #374151; font-size: 15px; font-weight: 600;">Linguistic Metrics</h4>
234
  <div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;">
235
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
236
- <div style="font-size: 20px; font-weight: 700; color: #6b7280;">{kf['chars_per_word']:.2f}</div>
237
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Chars/Word</div>
 
238
  </div>
239
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
240
- <div style="font-size: 20px; font-weight: 700; color: #6b7280;">{kf['words_per_sec']:.2f}</div>
241
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Words/Sec</div>
 
242
  </div>
243
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
244
- <div style="font-size: 20px; font-weight: 700; color: #6b7280;">{kf['filler_rate']*100:.1f}%</div>
245
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Filler Rate</div>
 
246
  </div>
247
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
248
- <div style="font-size: 20px; font-weight: 700; color: #6b7280;">{kf['repetition_count']}</div>
249
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Repetitions</div>
 
250
  </div>
251
  </div>
252
  </div>
 
220
 
221
  kf = asr['kopparapu_features']
222
 
223
+ # interpret linguistic metrics
224
+ cpw = kf['chars_per_word']
225
+ cpw_interp = 'Complex vocabulary' if cpw > 5.5 else 'Simple vocabulary' if cpw < 4.5 else 'Average'
226
+
227
+ wps = kf['words_per_sec']
228
+ wps_interp = 'Fast pace' if wps > 3 else 'Slow pace' if wps < 2 else 'Normal pace'
229
+
230
+ fr = kf['filler_rate'] * 100
231
+ fr_interp = 'High (spontaneous)' if fr > 5 else 'Low (scripted)' if fr < 2 else 'Moderate'
232
+
233
+ rep = kf['repetition_count']
234
+ rep_interp = 'Multiple (thinking aloud)' if rep > 3 else 'None (prepared)' if rep == 0 else 'Few'
235
+
236
  output += f"""
237
  <div style="background: linear-gradient(135deg, {class_bg} 0%, white 100%); border-radius: 16px; padding: 24px; margin-bottom: 20px; border: 1px solid {class_color}33;">
238
  <h3 style="margin: 0; color: {class_color}; font-size: 22px; font-weight: 700;">{classification} SPEECH</h3>
 
246
  <h4 style="margin: 0 0 16px 0; color: #374151; font-size: 15px; font-weight: 600;">Linguistic Metrics</h4>
247
  <div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;">
248
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
249
+ <div style="font-size: 20px; font-weight: 700; color: #374151;">{cpw:.2f}</div>
250
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Chars/Word</div>
251
+ <div style="font-size: 10px; color: #9ca3af; margin-top: 2px;">{cpw_interp}</div>
252
  </div>
253
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
254
+ <div style="font-size: 20px; font-weight: 700; color: #374151;">{wps:.2f}</div>
255
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Words/Sec</div>
256
+ <div style="font-size: 10px; color: #9ca3af; margin-top: 2px;">{wps_interp}</div>
257
  </div>
258
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
259
+ <div style="font-size: 20px; font-weight: 700; color: #374151;">{fr:.1f}%</div>
260
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Filler Rate</div>
261
+ <div style="font-size: 10px; color: #9ca3af; margin-top: 2px;">{fr_interp}</div>
262
  </div>
263
  <div style="background: #f9fafb; border-radius: 10px; padding: 14px; text-align: center;">
264
+ <div style="font-size: 20px; font-weight: 700; color: #374151;">{rep}</div>
265
  <div style="font-size: 11px; color: #6b7280; margin-top: 4px;">Repetitions</div>
266
+ <div style="font-size: 10px; color: #9ca3af; margin-top: 2px;">{rep_interp}</div>
267
  </div>
268
  </div>
269
  </div>