Jerry Hill commited on
Commit
1bf4ae1
·
1 Parent(s): 2785f78

adding play detection score

Browse files
README.md CHANGED
@@ -94,7 +94,7 @@ cd hf-video-scoring
94
  conda create -n nfl-play python=3.10 -y
95
  conda activate nfl-play
96
  conda install -y -c pytorch -c conda-forge pytorch torchvision torchaudio cpuonly
97
- pip install pytorchvideo huggingface_hub ffmpeg-python transformers
98
  ```
99
 
100
  **Using pip in a virtualenv:**
@@ -136,7 +136,7 @@ python inference.py data/segment_000.mov
136
 
137
  This will:
138
  - Print the Top-5 predicted Kinetics-400 labels + probabilities for the given clip
139
- - Generate audio transcription using Wav2Vec2
140
  - Save results to `classification.json` and `transcripts.json`
141
 
142
  ### 4. Process all clips in bulk
@@ -147,11 +147,11 @@ chmod +x run_all_clips.py
147
  ```
148
 
149
  * Iterates over every `.mov`/`.mp4` in `data/`
150
- * Runs both video classification and audio transcription for each clip
151
- * Prints per-clip results to console
152
  * Saves cumulative results in:
153
  - `classification.json` (video classification scores)
154
- - `transcripts.json` (audio transcriptions)
155
  * Handles errors gracefully (empty lists/strings for failed clips)
156
 
157
  ## Complete Workflow Example
@@ -191,13 +191,39 @@ This workflow captures live NFL content, automatically segments it, and then ana
191
 
192
  ```json
193
  {
194
- "segment_001.mov": "TA N ONE THE SECOND",
195
- "segment_002.mov": "", // if failed or skipped
196
- "segment_003.mov": "SOME AUDIO TEXT"
197
  }
198
  ```
199
 
200
- ## Customization
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  * **Model choice**: in `inference.py`, set `model_name` to one of:
203
 
@@ -205,12 +231,28 @@ This workflow captures live NFL content, automatically segments it, and then ana
205
  * **Clip length**: default is 2 seconds; adjust `video.get_clip(0, 2.0)`
206
  * **Sampling & crop**: modify `preprocess()` in `inference.py` to change `num_samples` or spatial size.
207
 
 
 
 
 
 
 
 
 
 
208
  ## Troubleshooting
209
 
 
210
  * **InvalidDataError: moov atom not found**: skip the damaged clip—`run_all_clips.py` logs and continues.
211
  * **Dimension or kernel size errors**: ensure `num_samples` >= model's temporal kernel (≥13 for X3D).
212
  * **PyTorch installation**: use Conda on macOS for best compatibility.
213
 
 
 
 
 
 
 
214
  ## Next Steps
215
 
216
  * **Fine-tune** X3D on your own "start" vs "end" NFL play dataset.
 
94
  conda create -n nfl-play python=3.10 -y
95
  conda activate nfl-play
96
  conda install -y -c pytorch -c conda-forge pytorch torchvision torchaudio cpuonly
97
+ pip install pytorchvideo huggingface_hub ffmpeg-python transformers openai-whisper
98
  ```
99
 
100
  **Using pip in a virtualenv:**
 
136
 
137
  This will:
138
  - Print the Top-5 predicted Kinetics-400 labels + probabilities for the given clip
139
+ - Generate high-quality audio transcription using Whisper-Medium with NFL sports vocabulary
140
  - Save results to `classification.json` and `transcripts.json`
141
 
142
  ### 4. Process all clips in bulk
 
147
  ```
148
 
149
  * Iterates over every `.mov`/`.mp4` in `data/`
150
+ * Runs both video classification and enhanced audio transcription for each clip
151
+ * Prints per-clip results to console with NFL-optimized transcriptions
152
  * Saves cumulative results in:
153
  - `classification.json` (video classification scores)
154
+ - `transcripts.json` (professional-quality NFL commentary transcriptions)
155
  * Handles errors gracefully (empty lists/strings for failed clips)
156
 
157
  ## Complete Workflow Example
 
191
 
192
  ```json
193
  {
194
+ "segment_001.mov": "I can tell you that Lamar Jackson right now is",
195
+ "segment_002.mov": "is the sixth best quarterback in the NFL",
196
+ "segment_003.mov": "He's basically like an extra line"
197
  }
198
  ```
199
 
200
+ ## Audio Transcription Features
201
+
202
+ The system uses **Whisper-Medium** with NFL-specific enhancements for superior audio transcription:
203
+
204
+ ### 🎯 **NFL-Optimized Transcription**
205
+ * **Advanced Model**: OpenAI Whisper-Medium (3B parameters) for professional-quality transcription
206
+ * **Sports Vocabulary**: 80+ NFL-specific terms including teams, positions, plays, and penalties
207
+ * **Smart Corrections**: Automatic correction of common football terminology mishears
208
+ * **Player Recognition**: Accurately transcribes player names and team references
209
+ * **Commentary Context**: Optimized for NFL broadcast commentary and analysis
210
+
211
+ ### 🔧 **Audio Enhancement Pipeline**
212
+ * **Noise Filtering**: High-pass (80Hz) and low-pass (8kHz) filters to remove audio artifacts
213
+ * **Audio Normalization**: Automatic level adjustment for consistent processing
214
+ * **Silence Detection**: Skips transcription for very quiet or short audio segments
215
+ * **Error Handling**: Graceful fallback for corrupted or problematic audio
216
+
217
+ ### 📊 **Quality Examples**
218
+ ```
219
+ Before: "TA N ONE THE SECOND"
220
+ After: "I can tell you that Lamar Jackson right now is"
221
+
222
+ Before: "FAY FOOLISH"
223
+ After: "is the sixth best quarterback in the NFL"
224
+ ```
225
+
226
+ ## Video Classification Customization
227
 
228
  * **Model choice**: in `inference.py`, set `model_name` to one of:
229
 
 
231
  * **Clip length**: default is 2 seconds; adjust `video.get_clip(0, 2.0)`
232
  * **Sampling & crop**: modify `preprocess()` in `inference.py` to change `num_samples` or spatial size.
233
 
234
+ ## Audio Transcription Customization
235
+
236
+ * **Model choice**: in `inference.py`, change `model` from `whisper-medium` to:
237
+ * `whisper-base` (faster, less accurate)
238
+ * `whisper-large` (slower, more accurate)
239
+ * **Sports vocabulary**: Modify `NFL_SPORTS_CONTEXT` list to add custom terms
240
+ * **Audio filters**: Adjust FFmpeg filters in `load_audio()` for different audio quality
241
+ * **Corrections**: Add custom corrections in `apply_sports_corrections()`
242
+
243
  ## Troubleshooting
244
 
245
+ ### Video Issues
246
  * **InvalidDataError: moov atom not found**: skip the damaged clip—`run_all_clips.py` logs and continues.
247
  * **Dimension or kernel size errors**: ensure `num_samples` >= model's temporal kernel (≥13 for X3D).
248
  * **PyTorch installation**: use Conda on macOS for best compatibility.
249
 
250
+ ### Audio Transcription Issues
251
+ * **Slow transcription**: Whisper-Medium is large (~3GB). Use `whisper-base` for faster processing.
252
+ * **Poor audio quality**: Ensure clean audio input. The system filters noise but very poor audio may still fail.
253
+ * **Memory issues**: Whisper-Medium requires ~4GB RAM. Use `whisper-base` on lower-memory systems.
254
+ * **Language detection**: The system forces English. For other languages, modify the `language` parameter.
255
+
256
  ## Next Steps
257
 
258
  * **Fine-tune** X3D on your own "start" vs "end" NFL play dataset.
__pycache__/inference.cpython-310.pyc CHANGED
Binary files a/__pycache__/inference.cpython-310.pyc and b/__pycache__/inference.cpython-310.pyc differ
 
classification.json CHANGED
@@ -20,1656 +20,5 @@
20
  "\"passing American football (in game)\"",
21
  0.0025873929262161255
22
  ]
23
- ],
24
- "segment_002.mov": [
25
- [
26
- "\"mowing lawn\"",
27
- 0.004539191722869873
28
- ],
29
- [
30
- "\"riding or walking with horse\"",
31
- 0.002820482011884451
32
- ],
33
- [
34
- "\"driving tractor\"",
35
- 0.002591945929452777
36
- ],
37
- [
38
- "\"catching or throwing baseball\"",
39
- 0.002587514230981469
40
- ],
41
- [
42
- "archery",
43
- 0.0025512496940791607
44
- ]
45
- ],
46
- "segment_003.mov": [
47
- [
48
- "\"hurling (sport)\"",
49
- 0.0035289316438138485
50
- ],
51
- [
52
- "headbutting",
53
- 0.0029045743867754936
54
- ],
55
- [
56
- "\"passing American football (not in game)\"",
57
- 0.002668950939550996
58
- ],
59
- [
60
- "\"pumping fist\"",
61
- 0.0026475831400603056
62
- ],
63
- [
64
- "\"playing cricket\"",
65
- 0.002635735785588622
66
- ]
67
- ],
68
- "segment_004.mov": [
69
- [
70
- "applauding",
71
- 0.00304257869720459
72
- ],
73
- [
74
- "headbutting",
75
- 0.0029725206550210714
76
- ],
77
- [
78
- "\"pumping fist\"",
79
- 0.0029444803949445486
80
- ],
81
- [
82
- "\"hurling (sport)\"",
83
- 0.0027822419069707394
84
- ],
85
- [
86
- "\"shaking hands\"",
87
- 0.002624393440783024
88
- ]
89
- ],
90
- "segment_005.mov": [
91
- [
92
- "\"catching or throwing baseball\"",
93
- 0.003370030550286174
94
- ],
95
- [
96
- "\"pumping fist\"",
97
- 0.00289507070556283
98
- ],
99
- [
100
- "\"catching or throwing frisbee\"",
101
- 0.0026615660171955824
102
- ],
103
- [
104
- "\"eating hotdog\"",
105
- 0.002651733811944723
106
- ],
107
- [
108
- "\"javelin throw\"",
109
- 0.0026478723157197237
110
- ]
111
- ],
112
- "segment_006.mov": [
113
- [
114
- "\"riding mountain bike\"",
115
- 0.0030539515428245068
116
- ],
117
- [
118
- "\"bench pressing\"",
119
- 0.0030068582855165005
120
- ],
121
- [
122
- "\"changing wheel\"",
123
- 0.0028557234909385443
124
- ],
125
- [
126
- "\"checking tires\"",
127
- 0.002828161232173443
128
- ],
129
- [
130
- "\"changing oil\"",
131
- 0.0025825132615864277
132
- ]
133
- ],
134
- "segment_007.mov": [
135
- [
136
- "\"changing oil\"",
137
- 0.003507673041895032
138
- ],
139
- [
140
- "\"pushing wheelchair\"",
141
- 0.0028540242929011583
142
- ],
143
- [
144
- "motorcycling",
145
- 0.002735486486926675
146
- ],
147
- [
148
- "\"checking tires\"",
149
- 0.0026065800338983536
150
- ],
151
- [
152
- "\"changing wheel\"",
153
- 0.0026001674123108387
154
- ]
155
- ],
156
- "segment_008.mov": [
157
- [
158
- "motorcycling",
159
- 0.0034892940893769264
160
- ],
161
- [
162
- "\"riding mountain bike\"",
163
- 0.0027264610398560762
164
- ],
165
- [
166
- "\"pushing wheelchair\"",
167
- 0.0026729153469204903
168
- ],
169
- [
170
- "\"changing oil\"",
171
- 0.002655936172232032
172
- ],
173
- [
174
- "snowmobiling",
175
- 0.002622972708195448
176
- ]
177
- ],
178
- "segment_009.mov": [
179
- [
180
- "\"kicking field goal\"",
181
- 0.0051559642888605595
182
- ],
183
- [
184
- "\"tossing coin\"",
185
- 0.002858997555449605
186
- ],
187
- [
188
- "\"passing American football (in game)\"",
189
- 0.002840855158865452
190
- ],
191
- [
192
- "\"high kick\"",
193
- 0.0024956425186246634
194
- ],
195
- [
196
- "headbutting",
197
- 0.002494481625035405
198
- ]
199
- ],
200
- "segment_010.mov": [
201
- [
202
- "\"tossing coin\"",
203
- 0.003494303673505783
204
- ],
205
- [
206
- "headbutting",
207
- 0.003139702370390296
208
- ],
209
- [
210
- "\"kicking field goal\"",
211
- 0.003000226803123951
212
- ],
213
- [
214
- "\"passing American football (in game)\"",
215
- 0.0028010711539536715
216
- ],
217
- [
218
- "\"pumping fist\"",
219
- 0.0026133027859032154
220
- ]
221
- ],
222
- "segment_011.mov": [
223
- [
224
- "headbutting",
225
- 0.0035944455303251743
226
- ],
227
- [
228
- "\"kicking field goal\"",
229
- 0.002746515441685915
230
- ],
231
- [
232
- "\"passing American football (in game)\"",
233
- 0.00274651194922626
234
- ],
235
- [
236
- "cheerleading",
237
- 0.0027097328566014767
238
- ],
239
- [
240
- "\"playing ice hockey\"",
241
- 0.002675419207662344
242
- ]
243
- ],
244
- "segment_012.mov": [
245
- [
246
- "cheerleading",
247
- 0.0033036908134818077
248
- ],
249
- [
250
- "\"dancing macarena\"",
251
- 0.0031919179018586874
252
- ],
253
- [
254
- "applauding",
255
- 0.0027217946480959654
256
- ],
257
- [
258
- "\"hitting baseball\"",
259
- 0.0026708708610385656
260
- ],
261
- [
262
- "\"garbage collecting\"",
263
- 0.0026213040109723806
264
- ]
265
- ],
266
- "segment_013.mov": [
267
- [
268
- "\"pumping fist\"",
269
- 0.0035472228191792965
270
- ],
271
- [
272
- "\"kicking field goal\"",
273
- 0.0027715854812413454
274
- ],
275
- [
276
- "\"dunking basketball\"",
277
- 0.0027416404336690903
278
- ],
279
- [
280
- "applauding",
281
- 0.002673310926184058
282
- ],
283
- [
284
- "celebrating",
285
- 0.002629267517477274
286
- ]
287
- ],
288
- "segment_014.mov": [
289
- [
290
- "headbutting",
291
- 0.0038350492250174284
292
- ],
293
- [
294
- "bobsledding",
295
- 0.002937863813713193
296
- ],
297
- [
298
- "\"playing ice hockey\"",
299
- 0.002785387681797147
300
- ],
301
- [
302
- "\"punching person (boxing)\"",
303
- 0.002671806840226054
304
- ],
305
- [
306
- "\"changing wheel\"",
307
- 0.0026315213181078434
308
- ]
309
- ],
310
- "segment_015.mov": [
311
- [
312
- "\"passing American football (in game)\"",
313
- 0.00389948021620512
314
- ],
315
- [
316
- "\"side kick\"",
317
- 0.003301523393020034
318
- ],
319
- [
320
- "\"kicking field goal\"",
321
- 0.002986735198646784
322
- ],
323
- [
324
- "\"passing American football (not in game)\"",
325
- 0.0026217757258564234
326
- ],
327
- [
328
- "\"catching or throwing baseball\"",
329
- 0.002540471963584423
330
- ]
331
- ],
332
- "segment_016.mov": [
333
- [
334
- "\"passing American football (in game)\"",
335
- 0.006536518689244986
336
- ],
337
- [
338
- "\"side kick\"",
339
- 0.0025378491263836622
340
- ],
341
- [
342
- "\"passing American football (not in game)\"",
343
- 0.0025076796300709248
344
- ],
345
- [
346
- "\"kicking field goal\"",
347
- 0.002507618861272931
348
- ],
349
- [
350
- "\"high kick\"",
351
- 0.0024923686869442463
352
- ]
353
- ],
354
- "segment_017.mov": [
355
- [
356
- "\"passing American football (in game)\"",
357
- 0.004528654273599386
358
- ],
359
- [
360
- "\"kicking field goal\"",
361
- 0.003415569895878434
362
- ],
363
- [
364
- "\"passing American football (not in game)\"",
365
- 0.0026175878010690212
366
- ],
367
- [
368
- "\"side kick\"",
369
- 0.0025776273105293512
370
- ],
371
- [
372
- "\"high kick\"",
373
- 0.0025026851799339056
374
- ]
375
- ],
376
- "segment_018.mov": [
377
- [
378
- "\"passing American football (in game)\"",
379
- 0.004061450716108084
380
- ],
381
- [
382
- "\"side kick\"",
383
- 0.0038009993731975555
384
- ],
385
- [
386
- "\"kicking field goal\"",
387
- 0.002601894084364176
388
- ],
389
- [
390
- "\"high kick\"",
391
- 0.002582114189863205
392
- ],
393
- [
394
- "\"passing American football (not in game)\"",
395
- 0.0025175546761602163
396
- ]
397
- ],
398
- "segment_019.mov": [
399
- [
400
- "\"passing American football (in game)\"",
401
- 0.006576324347406626
402
- ],
403
- [
404
- "\"passing American football (not in game)\"",
405
- 0.002554940525442362
406
- ],
407
- [
408
- "\"kicking field goal\"",
409
- 0.0024935186374932528
410
- ],
411
- [
412
- "\"side kick\"",
413
- 0.0024903316516429186
414
- ],
415
- [
416
- "\"catching or throwing frisbee\"",
417
- 0.002489960053935647
418
- ]
419
- ],
420
- "segment_020.mov": [
421
- [
422
- "\"passing American football (in game)\"",
423
- 0.006745155900716782
424
- ],
425
- [
426
- "\"passing American football (not in game)\"",
427
- 0.002495990600436926
428
- ],
429
- [
430
- "\"kicking field goal\"",
431
- 0.0024898555129766464
432
- ],
433
- [
434
- "headbutting",
435
- 0.002489602193236351
436
- ],
437
- [
438
- "\"shaking hands\"",
439
- 0.0024894699454307556
440
- ]
441
- ],
442
- "segment_021.mov": [
443
- [
444
- "\"passing American football (in game)\"",
445
- 0.004887602757662535
446
- ],
447
- [
448
- "\"passing American football (not in game)\"",
449
- 0.002793429885059595
450
- ],
451
- [
452
- "situp",
453
- 0.0026539755053818226
454
- ],
455
- [
456
- "\"dribbling basketball\"",
457
- 0.0026028482243418694
458
- ],
459
- [
460
- "\"throwing ball\"",
461
- 0.002529650926589966
462
- ]
463
- ],
464
- "segment_022.mov": [
465
- [
466
- "\"pumping fist\"",
467
- 0.002948896726593375
468
- ],
469
- [
470
- "\"passing American football (in game)\"",
471
- 0.0028372337110340595
472
- ],
473
- [
474
- "\"tossing coin\"",
475
- 0.0027690029237419367
476
- ],
477
- [
478
- "\"shaking hands\"",
479
- 0.0027542426250874996
480
- ],
481
- [
482
- "headbutting",
483
- 0.0026179237756878138
484
- ]
485
- ],
486
- "segment_023.mov": [
487
- [
488
- "\"pumping fist\"",
489
- 0.003991341684013605
490
- ],
491
- [
492
- "headbutting",
493
- 0.002623251872137189
494
- ],
495
- [
496
- "motorcycling",
497
- 0.0025920518673956394
498
- ],
499
- [
500
- "skydiving",
501
- 0.0025866003707051277
502
- ],
503
- [
504
- "bobsledding",
505
- 0.0025851819664239883
506
- ]
507
- ],
508
- "segment_024.mov": [
509
- [
510
- "\"riding a bike\"",
511
- 0.0037740382831543684
512
- ],
513
- [
514
- "motorcycling",
515
- 0.002751761581748724
516
- ],
517
- [
518
- "bobsledding",
519
- 0.0026172574143856764
520
- ],
521
- [
522
- "\"riding unicycle\"",
523
- 0.0025924895890057087
524
- ],
525
- [
526
- "\"pumping fist\"",
527
- 0.0025839442387223244
528
- ]
529
- ],
530
- "segment_025.mov": [
531
- [
532
- "bobsledding",
533
- 0.004564006347209215
534
- ],
535
- [
536
- "\"shaking hands\"",
537
- 0.0026650093495845795
538
- ],
539
- [
540
- "motorcycling",
541
- 0.002605688525363803
542
- ],
543
- [
544
- "\"pumping fist\"",
545
- 0.0026000377256423235
546
- ],
547
- [
548
- "skydiving",
549
- 0.0025698416866362095
550
- ]
551
- ],
552
- "segment_026.mov": [
553
- [
554
- "\"tossing coin\"",
555
- 0.005768336355686188
556
- ],
557
- [
558
- "squat",
559
- 0.0025260422844439745
560
- ],
561
- [
562
- "\"side kick\"",
563
- 0.0025187088176608086
564
- ],
565
- [
566
- "\"shaking hands\"",
567
- 0.0025166154373437166
568
- ],
569
- [
570
- "\"kicking field goal\"",
571
- 0.0025109625421464443
572
- ]
573
- ],
574
- "segment_027.mov": [
575
- [
576
- "\"carrying baby\"",
577
- 0.0028944576624780893
578
- ],
579
- [
580
- "\"side kick\"",
581
- 0.002688055858016014
582
- ],
583
- [
584
- "\"salsa dancing\"",
585
- 0.002644676947966218
586
- ],
587
- [
588
- "\"hula hooping\"",
589
- 0.0026000014040619135
590
- ],
591
- [
592
- "archery",
593
- 0.002581424079835415
594
- ]
595
- ],
596
- "segment_028.mov": [
597
- [
598
- "\"stretching arm\"",
599
- 0.004183173179626465
600
- ],
601
- [
602
- "archery",
603
- 0.0028685072902590036
604
- ],
605
- [
606
- "\"carrying baby\"",
607
- 0.002629334107041359
608
- ],
609
- [
610
- "yoga",
611
- 0.0025525041855871677
612
- ],
613
- [
614
- "\"stretching leg\"",
615
- 0.0025523642543703318
616
- ]
617
- ],
618
- "segment_029.mov": [
619
- [
620
- "\"getting a tattoo\"",
621
- 0.0036486154422163963
622
- ],
623
- [
624
- "archery",
625
- 0.0027306571137160063
626
- ],
627
- [
628
- "\"punching person (boxing)\"",
629
- 0.0027052827645093203
630
- ],
631
- [
632
- "\"punching bag\"",
633
- 0.002618985017761588
634
- ],
635
- [
636
- "squat",
637
- 0.0026112094055861235
638
- ]
639
- ],
640
- "segment_030.mov": [
641
- [
642
- "\"spray painting\"",
643
- 0.004089465364813805
644
- ],
645
- [
646
- "\"getting a tattoo\"",
647
- 0.002762633841484785
648
- ],
649
- [
650
- "\"playing paintball\"",
651
- 0.0027071302756667137
652
- ],
653
- [
654
- "\"changing wheel\"",
655
- 0.0026773668359965086
656
- ],
657
- [
658
- "bobsledding",
659
- 0.0025922050699591637
660
- ]
661
- ],
662
- "segment_031.mov": [
663
- [
664
- "\"mowing lawn\"",
665
- 0.0034001749008893967
666
- ],
667
- [
668
- "\"passing American football (not in game)\"",
669
- 0.003030994674190879
670
- ],
671
- [
672
- "\"catching or throwing baseball\"",
673
- 0.0028556634206324816
674
- ],
675
- [
676
- "\"pumping fist\"",
677
- 0.002578843617811799
678
- ],
679
- [
680
- "\"riding or walking with horse\"",
681
- 0.002575062680989504
682
- ]
683
- ],
684
- "segment_032.mov": [
685
- [
686
- "\"passing American football (in game)\"",
687
- 0.003045632503926754
688
- ],
689
- [
690
- "marching",
691
- 0.0030235128942877054
692
- ],
693
- [
694
- "\"passing American football (not in game)\"",
695
- 0.0029362209606915712
696
- ],
697
- [
698
- "\"kicking field goal\"",
699
- 0.0027396646328270435
700
- ],
701
- [
702
- "\"hurling (sport)\"",
703
- 0.002676320029422641
704
- ]
705
- ],
706
- "segment_033.mov": [
707
- [
708
- "\"mowing lawn\"",
709
- 0.004852019250392914
710
- ],
711
- [
712
- "\"passing American football (not in game)\"",
713
- 0.002654429292306304
714
- ],
715
- [
716
- "\"hurling (sport)\"",
717
- 0.002581879962235689
718
- ],
719
- [
720
- "\"kicking soccer ball\"",
721
- 0.0025664607528597116
722
- ],
723
- [
724
- "\"juggling soccer ball\"",
725
- 0.002544356742873788
726
- ]
727
- ],
728
- "segment_034.mov": [
729
- [
730
- "archery",
731
- 0.004724352620542049
732
- ],
733
- [
734
- "\"trimming or shaving beard\"",
735
- 0.0026578360702842474
736
- ],
737
- [
738
- "\"golf driving\"",
739
- 0.002610759809613228
740
- ],
741
- [
742
- "\"tossing coin\"",
743
- 0.002541653113439679
744
- ],
745
- [
746
- "\"mowing lawn\"",
747
- 0.0025332642253488302
748
- ]
749
- ],
750
- "segment_035.mov": [
751
- [
752
- "\"playing harmonica\"",
753
- 0.006103646010160446
754
- ],
755
- [
756
- "whistling",
757
- 0.002615551697090268
758
- ],
759
- [
760
- "smoking",
761
- 0.0025100400671362877
762
- ],
763
- [
764
- "yawning",
765
- 0.0025017866864800453
766
- ],
767
- [
768
- "\"playing ukulele\"",
769
- 0.0025011510588228703
770
- ]
771
- ],
772
- "segment_036.mov": [
773
- [
774
- "\"passing American football (in game)\"",
775
- 0.006577454507350922
776
- ],
777
- [
778
- "\"passing American football (not in game)\"",
779
- 0.002514705527573824
780
- ],
781
- [
782
- "\"kicking field goal\"",
783
- 0.0025104687083512545
784
- ],
785
- [
786
- "\"side kick\"",
787
- 0.0025097192265093327
788
- ],
789
- [
790
- "\"high kick\"",
791
- 0.002491986844688654
792
- ]
793
- ],
794
- "segment_037.mov": [
795
- [
796
- "\"passing American football (in game)\"",
797
- 0.006760087329894304
798
- ],
799
- [
800
- "\"passing American football (not in game)\"",
801
- 0.0024913023225963116
802
- ],
803
- [
804
- "\"kicking field goal\"",
805
- 0.00248970789834857
806
- ],
807
- [
808
- "\"side kick\"",
809
- 0.002489360049366951
810
- ],
811
- [
812
- "\"high kick\"",
813
- 0.002489320933818817
814
- ]
815
- ],
816
- "segment_038.mov": [
817
- [
818
- "\"passing American football (in game)\"",
819
- 0.0062811062671244144
820
- ],
821
- [
822
- "\"kicking field goal\"",
823
- 0.0026691341772675514
824
- ],
825
- [
826
- "\"passing American football (not in game)\"",
827
- 0.002501868177205324
828
- ],
829
- [
830
- "\"side kick\"",
831
- 0.0024906292092055082
832
- ],
833
- [
834
- "\"tossing coin\"",
835
- 0.0024903123266994953
836
- ]
837
- ],
838
- "segment_039.mov": [
839
- [
840
- "\"passing American football (in game)\"",
841
- 0.004427704028785229
842
- ],
843
- [
844
- "\"kicking field goal\"",
845
- 0.00305744051001966
846
- ],
847
- [
848
- "\"passing American football (not in game)\"",
849
- 0.0028497367165982723
850
- ],
851
- [
852
- "\"shaking hands\"",
853
- 0.0025244825519621372
854
- ],
855
- [
856
- "\"tossing coin\"",
857
- 0.0025086107198148966
858
- ]
859
- ],
860
- "segment_040.mov": [
861
- [
862
- "\"passing American football (in game)\"",
863
- 0.00507122790440917
864
- ],
865
- [
866
- "\"tossing coin\"",
867
- 0.0028494407888501883
868
- ],
869
- [
870
- "\"kicking field goal\"",
871
- 0.0025832131505012512
872
- ],
873
- [
874
- "\"shaking hands\"",
875
- 0.0025662044063210487
876
- ],
877
- [
878
- "\"passing American football (not in game)\"",
879
- 0.0025347082410007715
880
- ]
881
- ],
882
- "segment_041.mov": [
883
- [
884
- "\"passing American football (in game)\"",
885
- 0.002910151146352291
886
- ],
887
- [
888
- "\"tossing coin\"",
889
- 0.00288573419675231
890
- ],
891
- [
892
- "bobsledding",
893
- 0.0027363626286387444
894
- ],
895
- [
896
- "\"changing wheel\"",
897
- 0.0027150516398251057
898
- ],
899
- [
900
- "\"kicking field goal\"",
901
- 0.0026453319005668163
902
- ]
903
- ],
904
- "segment_042.mov": [
905
- [
906
- "bobsledding",
907
- 0.0029746112413704395
908
- ],
909
- [
910
- "marching",
911
- 0.0026662067975848913
912
- ],
913
- [
914
- "\"riding mountain bike\"",
915
- 0.0026005373802036047
916
- ],
917
- [
918
- "archery",
919
- 0.002575363963842392
920
- ],
921
- [
922
- "\"passing American football (not in game)\"",
923
- 0.0025738172698765993
924
- ]
925
- ],
926
- "segment_043.mov": [
927
- [
928
- "bobsledding",
929
- 0.0032584425061941147
930
- ],
931
- [
932
- "\"changing wheel\"",
933
- 0.002937484998255968
934
- ],
935
- [
936
- "\"driving car\"",
937
- 0.0028462321497499943
938
- ],
939
- [
940
- "motorcycling",
941
- 0.00263536861166358
942
- ],
943
- [
944
- "skateboarding",
945
- 0.002625212771818042
946
- ]
947
- ],
948
- "segment_044.mov": [
949
- [
950
- "archery",
951
- 0.0029061429668217897
952
- ],
953
- [
954
- "bobsledding",
955
- 0.002719373907893896
956
- ],
957
- [
958
- "\"golf driving\"",
959
- 0.0027050392236560583
960
- ],
961
- [
962
- "barbequing",
963
- 0.0025971110444515944
964
- ],
965
- [
966
- "\"golf putting\"",
967
- 0.0025699003599584103
968
- ]
969
- ],
970
- "segment_045.mov": [
971
- [
972
- "barbequing",
973
- 0.003022523829713464
974
- ],
975
- [
976
- "\"changing wheel\"",
977
- 0.002754890127107501
978
- ],
979
- [
980
- "\"mowing lawn\"",
981
- 0.0026360696647316217
982
- ],
983
- [
984
- "auctioning",
985
- 0.0026054272893816233
986
- ],
987
- [
988
- "\"changing oil\"",
989
- 0.0025794513057917356
990
- ]
991
- ],
992
- "segment_046.mov": [
993
- [
994
- "\"tossing coin\"",
995
- 0.003568414831534028
996
- ],
997
- [
998
- "\"side kick\"",
999
- 0.003212416311725974
1000
- ],
1001
- [
1002
- "\"rock scissors paper\"",
1003
- 0.002615532139316201
1004
- ],
1005
- [
1006
- "\"punching person (boxing)\"",
1007
- 0.0026119472458958626
1008
- ],
1009
- [
1010
- "\"high kick\"",
1011
- 0.002596732461825013
1012
- ]
1013
- ],
1014
- "segment_047.mov": [
1015
- [
1016
- "\"passing American football (in game)\"",
1017
- 0.0031079247128218412
1018
- ],
1019
- [
1020
- "\"juggling soccer ball\"",
1021
- 0.0028041608165949583
1022
- ],
1023
- [
1024
- "\"passing American football (not in game)\"",
1025
- 0.002784370444715023
1026
- ],
1027
- [
1028
- "\"catching or throwing baseball\"",
1029
- 0.0027656129095703363
1030
- ],
1031
- [
1032
- "\"tossing coin\"",
1033
- 0.0027509713545441628
1034
- ]
1035
- ],
1036
- "segment_048.mov": [
1037
- [
1038
- "\"tossing coin\"",
1039
- 0.004612566903233528
1040
- ],
1041
- [
1042
- "\"passing American football (in game)\"",
1043
- 0.0030128920916467905
1044
- ],
1045
- [
1046
- "\"side kick\"",
1047
- 0.002602673601359129
1048
- ],
1049
- [
1050
- "\"passing American football (not in game)\"",
1051
- 0.0025423497427254915
1052
- ],
1053
- [
1054
- "\"rock scissors paper\"",
1055
- 0.0025353787932544947
1056
- ]
1057
- ],
1058
- "segment_049.mov": [
1059
- [
1060
- "beatboxing",
1061
- 0.002776292385533452
1062
- ],
1063
- [
1064
- "\"pumping fist\"",
1065
- 0.0027726562693715096
1066
- ],
1067
- [
1068
- "\"shaking hands\"",
1069
- 0.0027530265506356955
1070
- ],
1071
- [
1072
- "\"playing poker\"",
1073
- 0.002649413887411356
1074
- ],
1075
- [
1076
- "\"arm wrestling\"",
1077
- 0.0026053758338093758
1078
- ]
1079
- ],
1080
- "segment_050.mov": [
1081
- [
1082
- "crying",
1083
- 0.0032352209091186523
1084
- ],
1085
- [
1086
- "beatboxing",
1087
- 0.002813587663695216
1088
- ],
1089
- [
1090
- "\"fixing hair\"",
1091
- 0.002721605822443962
1092
- ],
1093
- [
1094
- "\"pumping fist\"",
1095
- 0.002583273220807314
1096
- ],
1097
- [
1098
- "\"brushing hair\"",
1099
- 0.0025578502099961042
1100
- ]
1101
- ],
1102
- "segment_051.mov": [
1103
- [
1104
- "\"passing American football (in game)\"",
1105
- 0.005108952056616545
1106
- ],
1107
- [
1108
- "\"passing American football (not in game)\"",
1109
- 0.002873431658372283
1110
- ],
1111
- [
1112
- "\"side kick\"",
1113
- 0.002661630278453231
1114
- ],
1115
- [
1116
- "\"kicking field goal\"",
1117
- 0.0026403891388326883
1118
- ],
1119
- [
1120
- "\"high kick\"",
1121
- 0.0025104281958192587
1122
- ]
1123
- ],
1124
- "segment_052.mov": [
1125
- [
1126
- "\"passing American football (in game)\"",
1127
- 0.0058504920452833176
1128
- ],
1129
- [
1130
- "\"kicking field goal\"",
1131
- 0.0027115345001220703
1132
- ],
1133
- [
1134
- "\"passing American football (not in game)\"",
1135
- 0.0026032112073153257
1136
- ],
1137
- [
1138
- "\"side kick\"",
1139
- 0.0025289678014814854
1140
- ],
1141
- [
1142
- "\"high kick\"",
1143
- 0.002494329586625099
1144
- ]
1145
- ],
1146
- "segment_053.mov": [
1147
- [
1148
- "\"passing American football (in game)\"",
1149
- 0.006694582756608725
1150
- ],
1151
- [
1152
- "\"passing American football (not in game)\"",
1153
- 0.0025113301817327738
1154
- ],
1155
- [
1156
- "\"side kick\"",
1157
- 0.0024927803315222263
1158
- ],
1159
- [
1160
- "\"kicking field goal\"",
1161
- 0.0024906357284635305
1162
- ],
1163
- [
1164
- "\"high kick\"",
1165
- 0.002489699050784111
1166
- ]
1167
- ],
1168
- "segment_054.mov": [
1169
- [
1170
- "\"passing American football (in game)\"",
1171
- 0.006701494567096233
1172
- ],
1173
- [
1174
- "\"passing American football (not in game)\"",
1175
- 0.0025095203891396523
1176
- ],
1177
- [
1178
- "\"kicking field goal\"",
1179
- 0.0024933733511716127
1180
- ],
1181
- [
1182
- "\"side kick\"",
1183
- 0.002489532344043255
1184
- ],
1185
- [
1186
- "headbutting",
1187
- 0.002489422680810094
1188
- ]
1189
- ],
1190
- "segment_055.mov": [
1191
- [
1192
- "\"passing American football (in game)\"",
1193
- 0.005614574532955885
1194
- ],
1195
- [
1196
- "\"kicking field goal\"",
1197
- 0.002844724338501692
1198
- ],
1199
- [
1200
- "\"tossing coin\"",
1201
- 0.0025539705529809
1202
- ],
1203
- [
1204
- "\"passing American football (not in game)\"",
1205
- 0.0025522371288388968
1206
- ],
1207
- [
1208
- "headbutting",
1209
- 0.0024937023408710957
1210
- ]
1211
- ],
1212
- "segment_056.mov": [
1213
- [
1214
- "headbutting",
1215
- 0.003259368008002639
1216
- ],
1217
- [
1218
- "\"pumping fist\"",
1219
- 0.0029684980399906635
1220
- ],
1221
- [
1222
- "\"playing ice hockey\"",
1223
- 0.0029396419413387775
1224
- ],
1225
- [
1226
- "\"shaking hands\"",
1227
- 0.002817715285345912
1228
- ],
1229
- [
1230
- "\"passing American football (in game)\"",
1231
- 0.002679395256564021
1232
- ]
1233
- ],
1234
- "segment_057.mov": [
1235
- [
1236
- "bobsledding",
1237
- 0.004842189606279135
1238
- ],
1239
- [
1240
- "\"pumping fist\"",
1241
- 0.002615878591313958
1242
- ],
1243
- [
1244
- "\"driving car\"",
1245
- 0.002567970659583807
1246
- ],
1247
- [
1248
- "\"playing poker\"",
1249
- 0.0025621275417506695
1250
- ],
1251
- [
1252
- "\"playing ice hockey\"",
1253
- 0.002544831018894911
1254
- ]
1255
- ],
1256
- "segment_058.mov": [
1257
- [
1258
- "motorcycling",
1259
- 0.002834487706422806
1260
- ],
1261
- [
1262
- "\"driving car\"",
1263
- 0.002728639403358102
1264
- ],
1265
- [
1266
- "\"changing wheel\"",
1267
- 0.0027119864244014025
1268
- ],
1269
- [
1270
- "bobsledding",
1271
- 0.002644300926476717
1272
- ],
1273
- [
1274
- "kissing",
1275
- 0.002592987846583128
1276
- ]
1277
- ],
1278
- "segment_059.mov": [
1279
- [
1280
- "bobsledding",
1281
- 0.004265598952770233
1282
- ],
1283
- [
1284
- "\"playing ice hockey\"",
1285
- 0.0030175303108990192
1286
- ],
1287
- [
1288
- "\"playing paintball\"",
1289
- 0.002638093428686261
1290
- ],
1291
- [
1292
- "motorcycling",
1293
- 0.0025540166534483433
1294
- ],
1295
- [
1296
- "\"riding mountain bike\"",
1297
- 0.002545550698414445
1298
- ]
1299
- ],
1300
- "segment_060.mov": [
1301
- [
1302
- "\"passing American football (in game)\"",
1303
- 0.005962858442217112
1304
- ],
1305
- [
1306
- "\"kicking field goal\"",
1307
- 0.002803174778819084
1308
- ],
1309
- [
1310
- "\"passing American football (not in game)\"",
1311
- 0.0025008893571794033
1312
- ],
1313
- [
1314
- "\"side kick\"",
1315
- 0.0024952334351837635
1316
- ],
1317
- [
1318
- "headbutting",
1319
- 0.002492264611646533
1320
- ]
1321
- ],
1322
- "segment_061.mov": [
1323
- [
1324
- "\"passing American football (in game)\"",
1325
- 0.006750195287168026
1326
- ],
1327
- [
1328
- "\"kicking field goal\"",
1329
- 0.0024920343421399593
1330
- ],
1331
- [
1332
- "\"passing American football (not in game)\"",
1333
- 0.002491830848157406
1334
- ],
1335
- [
1336
- "\"side kick\"",
1337
- 0.0024899402633309364
1338
- ],
1339
- [
1340
- "\"high kick\"",
1341
- 0.002489452948793769
1342
- ]
1343
- ],
1344
- "segment_062.mov": [
1345
- [
1346
- "\"passing American football (in game)\"",
1347
- 0.006219817325472832
1348
- ],
1349
- [
1350
- "\"passing American football (not in game)\"",
1351
- 0.002605071058496833
1352
- ],
1353
- [
1354
- "headbutting",
1355
- 0.0025401373859494925
1356
- ],
1357
- [
1358
- "\"kicking field goal\"",
1359
- 0.0025001864414662123
1360
- ],
1361
- [
1362
- "\"pumping fist\"",
1363
- 0.002497575245797634
1364
- ]
1365
- ],
1366
- "segment_063.mov": [
1367
- [
1368
- "marching",
1369
- 0.003558160038664937
1370
- ],
1371
- [
1372
- "\"passing American football (in game)\"",
1373
- 0.0030603946652263403
1374
- ],
1375
- [
1376
- "\"tango dancing\"",
1377
- 0.00266551086679101
1378
- ],
1379
- [
1380
- "\"side kick\"",
1381
- 0.002660425379872322
1382
- ],
1383
- [
1384
- "\"passing American football (not in game)\"",
1385
- 0.002627450041472912
1386
- ]
1387
- ],
1388
- "segment_064.mov": [
1389
- [
1390
- "\"passing American football (in game)\"",
1391
- 0.00557365408167243
1392
- ],
1393
- [
1394
- "\"passing American football (not in game)\"",
1395
- 0.0027207054663449526
1396
- ],
1397
- [
1398
- "headbutting",
1399
- 0.0026054433546960354
1400
- ],
1401
- [
1402
- "\"pumping fist\"",
1403
- 0.00251823291182518
1404
- ],
1405
- [
1406
- "\"kicking field goal\"",
1407
- 0.002515583299100399
1408
- ]
1409
- ],
1410
- "segment_065.mov": [
1411
- [
1412
- "\"side kick\"",
1413
- 0.005902828648686409
1414
- ],
1415
- [
1416
- "\"high kick\"",
1417
- 0.0025668020825833082
1418
- ],
1419
- [
1420
- "wrestling",
1421
- 0.0025415299460291862
1422
- ],
1423
- [
1424
- "squat",
1425
- 0.0025292884092777967
1426
- ],
1427
- [
1428
- "\"drop kicking\"",
1429
- 0.00251045823097229
1430
- ]
1431
- ],
1432
- "segment_066.mov": [
1433
- [
1434
- "bobsledding",
1435
- 0.003806664375588298
1436
- ],
1437
- [
1438
- "\"changing wheel\"",
1439
- 0.0029659303836524487
1440
- ],
1441
- [
1442
- "\"punching bag\"",
1443
- 0.0027637933380901814
1444
- ],
1445
- [
1446
- "headbutting",
1447
- 0.00258650747127831
1448
- ],
1449
- [
1450
- "motorcycling",
1451
- 0.002585215028375387
1452
- ]
1453
- ],
1454
- "segment_067.mov": [
1455
- [
1456
- "\"changing wheel\"",
1457
- 0.0038947509601712227
1458
- ],
1459
- [
1460
- "\"pushing car\"",
1461
- 0.002689485903829336
1462
- ],
1463
- [
1464
- "\"driving car\"",
1465
- 0.00266862940043211
1466
- ],
1467
- [
1468
- "\"changing oil\"",
1469
- 0.0026266295462846756
1470
- ],
1471
- [
1472
- "\"arm wrestling\"",
1473
- 0.0025696069933474064
1474
- ]
1475
- ],
1476
- "segment_068.mov": [
1477
- [
1478
- "\"passing American football (not in game)\"",
1479
- 0.0030197601299732924
1480
- ],
1481
- [
1482
- "\"passing American football (in game)\"",
1483
- 0.0029855112079530954
1484
- ],
1485
- [
1486
- "\"kicking field goal\"",
1487
- 0.0027115403208881617
1488
- ],
1489
- [
1490
- "\"catching or throwing baseball\"",
1491
- 0.0026096913497895002
1492
- ],
1493
- [
1494
- "\"high kick\"",
1495
- 0.0026070410385727882
1496
- ]
1497
- ],
1498
- "segment_069.mov": [
1499
- [
1500
- "\"passing American football (in game)\"",
1501
- 0.005361294839531183
1502
- ],
1503
- [
1504
- "\"kicking field goal\"",
1505
- 0.002796306274831295
1506
- ],
1507
- [
1508
- "\"passing American football (not in game)\"",
1509
- 0.0027009581681340933
1510
- ],
1511
- [
1512
- "\"side kick\"",
1513
- 0.002553092548623681
1514
- ],
1515
- [
1516
- "\"high kick\"",
1517
- 0.002506962278857827
1518
- ]
1519
- ],
1520
- "segment_070.mov": [
1521
- [
1522
- "\"passing American football (in game)\"",
1523
- 0.005472357384860516
1524
- ],
1525
- [
1526
- "\"passing American football (not in game)\"",
1527
- 0.002799208741635084
1528
- ],
1529
- [
1530
- "\"kicking field goal\"",
1531
- 0.0027042534202337265
1532
- ],
1533
- [
1534
- "\"side kick\"",
1535
- 0.0025148894637823105
1536
- ],
1537
- [
1538
- "\"catching or throwing baseball\"",
1539
- 0.002496932167559862
1540
- ]
1541
- ],
1542
- "segment_071.mov": [
1543
- [
1544
- "\"side kick\"",
1545
- 0.003893344197422266
1546
- ],
1547
- [
1548
- "\"passing American football (in game)\"",
1549
- 0.0035547567531466484
1550
- ],
1551
- [
1552
- "\"kicking field goal\"",
1553
- 0.002741483272984624
1554
- ],
1555
- [
1556
- "\"passing American football (not in game)\"",
1557
- 0.0026810814160853624
1558
- ],
1559
- [
1560
- "\"catching or throwing baseball\"",
1561
- 0.0025338695850223303
1562
- ]
1563
- ],
1564
- "segment_072.mov": [
1565
- [
1566
- "\"passing American football (in game)\"",
1567
- 0.005563896149396896
1568
- ],
1569
- [
1570
- "\"passing American football (not in game)\"",
1571
- 0.0027015593368560076
1572
- ],
1573
- [
1574
- "\"side kick\"",
1575
- 0.002657951321452856
1576
- ],
1577
- [
1578
- "\"kicking field goal\"",
1579
- 0.0026104655116796494
1580
- ],
1581
- [
1582
- "\"catching or throwing baseball\"",
1583
- 0.0024953498505055904
1584
- ]
1585
- ],
1586
- "segment_073.mov": [
1587
- [
1588
- "\"passing American football (in game)\"",
1589
- 0.006470989435911179
1590
- ],
1591
- [
1592
- "\"passing American football (not in game)\"",
1593
- 0.0025515288580209017
1594
- ],
1595
- [
1596
- "\"side kick\"",
1597
- 0.0025365715846419334
1598
- ],
1599
- [
1600
- "\"kicking field goal\"",
1601
- 0.002492384286597371
1602
- ],
1603
- [
1604
- "\"high kick\"",
1605
- 0.002490945626050234
1606
- ]
1607
- ],
1608
- "segment_074.mov": [
1609
- [
1610
- "\"passing American football (in game)\"",
1611
- 0.004092047456651926
1612
- ],
1613
- [
1614
- "\"passing American football (not in game)\"",
1615
- 0.0037548826076090336
1616
- ],
1617
- [
1618
- "\"side kick\"",
1619
- 0.0026034193579107523
1620
- ],
1621
- [
1622
- "\"kicking field goal\"",
1623
- 0.0025540809147059917
1624
- ],
1625
- [
1626
- "\"catching or throwing baseball\"",
1627
- 0.0025116554461419582
1628
- ]
1629
- ],
1630
- "segment_075.mov": [
1631
- [
1632
- "\"passing American football (in game)\"",
1633
- 0.006258341949433088
1634
- ],
1635
- [
1636
- "\"passing American football (not in game)\"",
1637
- 0.002621858147904277
1638
- ],
1639
- [
1640
- "\"kicking field goal\"",
1641
- 0.0025423644110560417
1642
- ],
1643
- [
1644
- "\"catching or throwing baseball\"",
1645
- 0.0024970977101475
1646
- ],
1647
- [
1648
- "\"pumping fist\"",
1649
- 0.0024926913902163506
1650
- ]
1651
- ],
1652
- "segment_076.mov": [
1653
- [
1654
- "\"hurling (sport)\"",
1655
- 0.003916610963642597
1656
- ],
1657
- [
1658
- "headbutting",
1659
- 0.0029018200002610683
1660
- ],
1661
- [
1662
- "\"passing American football (in game)\"",
1663
- 0.0027735705953091383
1664
- ],
1665
- [
1666
- "\"passing American football (not in game)\"",
1667
- 0.00273358216509223
1668
- ],
1669
- [
1670
- "\"kicking field goal\"",
1671
- 0.0026465952396392822
1672
- ]
1673
- ],
1674
- "segment_077.mov": []
1675
  }
 
20
  "\"passing American football (in game)\"",
21
  0.0025873929262161255
22
  ]
23
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
inference.py CHANGED
@@ -69,7 +69,67 @@ def preprocess(frames, num_samples: int = 16, size: int = 224) -> torch.Tensor:
69
  clip = (clip - mean) / std
70
  return clip
71
 
72
- # === Prediction ===
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  def predict_clip(path: str):
74
  try:
75
  video = EncodedVideo.from_path(path)
@@ -91,24 +151,102 @@ def predict_clip(path: str):
91
  idx = idx_tensor.item()
92
  label = kinetics_labels.get(idx, f"Class_{idx}")
93
  results.append((label, float(score)))
 
 
 
 
 
94
  return results
95
  except Exception as e:
96
  print(f"[ERROR] Failed to process {path}: {e}")
97
  return []
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  # === Audio ASR Setup ===
 
100
  asr = pipeline(
101
  "automatic-speech-recognition",
102
- model="facebook/wav2vec2-base-960h",
103
- chunk_length_s=10,
104
- device=-1
 
 
 
 
105
  )
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  # === Audio Loading via FFmpeg ===
108
  def load_audio(path: str, sr: int = 16000):
109
- """Decode audio track from any container using FFmpeg to PCM float32 array"""
110
  cmd = [
111
  "ffmpeg", "-i", path,
 
112
  "-f", "s16le",
113
  "-acodec", "pcm_s16le",
114
  "-ac", "1", "-ar", str(sr),
@@ -117,13 +255,198 @@ def load_audio(path: str, sr: int = 16000):
117
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
118
  raw = proc.stdout.read()
119
  audio = np.frombuffer(raw, np.int16).astype(np.float32) / 32768.0
 
 
 
 
 
120
  return audio, sr
121
 
122
- # === Transcription ===
123
  def transcribe_clip(path: str) -> str:
124
  audio, sr = load_audio(path, sr=16000)
125
- result = asr(audio)
126
- return result.get("text", "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  # === CLI ===
129
  if __name__ == "__main__":
 
69
  clip = (clip - mean) / std
70
  return clip
71
 
72
+ # === Play State Detection ===
73
+ def analyze_play_state(predictions, confidence_threshold=0.002):
74
+ """
75
+ Analyze predictions to determine if this is likely start, middle, or end of play
76
+ """
77
+ if not predictions:
78
+ return "unknown", 0.0
79
+
80
+ # Football-specific labels that indicate different play states
81
+ play_start_indicators = [
82
+ "passing American football (in game)",
83
+ "kicking field goal",
84
+ "side kick",
85
+ "high kick"
86
+ ]
87
+
88
+ play_action_indicators = [
89
+ "catching or throwing baseball", # Often misclassified football throws
90
+ "catching or throwing softball",
91
+ "playing cricket", # Sometimes catches football
92
+ "throwing ball"
93
+ ]
94
+
95
+ non_play_indicators = [
96
+ "applauding",
97
+ "marching",
98
+ "sitting",
99
+ "standing",
100
+ "clapping",
101
+ "cheering"
102
+ ]
103
+
104
+ # Calculate weighted scores for each state
105
+ play_start_score = 0.0
106
+ play_action_score = 0.0
107
+ non_play_score = 0.0
108
+
109
+ for label, confidence in predictions:
110
+ # Remove quotes and normalize
111
+ clean_label = label.replace('"', '').lower()
112
+
113
+ if any(indicator.lower() in clean_label for indicator in play_start_indicators):
114
+ play_start_score += confidence * 2.0 # Weight play-specific actions higher
115
+ elif any(indicator.lower() in clean_label for indicator in play_action_indicators):
116
+ play_action_score += confidence
117
+ elif any(indicator.lower() in clean_label for indicator in non_play_indicators):
118
+ non_play_score += confidence
119
+
120
+ # Determine play state
121
+ max_score = max(play_start_score, play_action_score, non_play_score)
122
+
123
+ if max_score < confidence_threshold:
124
+ return "unknown", max_score
125
+ elif play_start_score == max_score:
126
+ return "play_active", play_start_score
127
+ elif play_action_score == max_score:
128
+ return "play_action", play_action_score
129
+ else:
130
+ return "non_play", non_play_score
131
+
132
+ # === Enhanced Prediction ===
133
  def predict_clip(path: str):
134
  try:
135
  video = EncodedVideo.from_path(path)
 
151
  idx = idx_tensor.item()
152
  label = kinetics_labels.get(idx, f"Class_{idx}")
153
  results.append((label, float(score)))
154
+
155
+ # Add play state analysis
156
+ play_state, confidence = analyze_play_state(results)
157
+ print(f"[PLAY STATE] {play_state} (confidence: {confidence:.3f})")
158
+
159
  return results
160
  except Exception as e:
161
  print(f"[ERROR] Failed to process {path}: {e}")
162
  return []
163
 
164
+ # === Advanced Play Sequence Detection ===
165
+ def detect_play_boundaries(clip_results, window_size=3):
166
+ """
167
+ Analyze sequence of clips to detect play start and end boundaries
168
+ """
169
+ if len(clip_results) < window_size:
170
+ return []
171
+
172
+ play_states = []
173
+ for results in clip_results:
174
+ state, confidence = analyze_play_state(results)
175
+ play_states.append((state, confidence))
176
+
177
+ boundaries = []
178
+
179
+ # Look for transitions from non_play -> play_active (START)
180
+ # and play_active -> non_play (END)
181
+ for i in range(len(play_states) - 1):
182
+ current_state, current_conf = play_states[i]
183
+ next_state, next_conf = play_states[i + 1]
184
+
185
+ if (current_state in ["non_play", "unknown"] and
186
+ next_state in ["play_active", "play_action"] and
187
+ next_conf > 0.002):
188
+ boundaries.append(("play_start", i + 1, next_conf))
189
+
190
+ if (current_state in ["play_active", "play_action"] and
191
+ next_state in ["non_play", "unknown"] and
192
+ current_conf > 0.002):
193
+ boundaries.append(("play_end", i, current_conf))
194
+
195
+ return boundaries
196
+
197
  # === Audio ASR Setup ===
198
+ # Using Whisper Medium for much better transcription quality
199
  asr = pipeline(
200
  "automatic-speech-recognition",
201
+ model="openai/whisper-medium", # Larger model for better accuracy
202
+ device=-1,
203
+ # Optimized for English sports content
204
+ generate_kwargs={
205
+ "language": "en", # Force English to avoid multilingual detection
206
+ "task": "transcribe" # Don't translate
207
+ }
208
  )
209
 
210
+ # === Sports-Specific Vocabulary ===
211
+ NFL_SPORTS_CONTEXT = [
212
+ # NFL Teams
213
+ "Patriots", "Cowboys", "Packers", "49ers", "Chiefs", "Bills", "Ravens", "Steelers",
214
+ "Eagles", "Giants", "Rams", "Saints", "Buccaneers", "Panthers", "Falcons", "Cardinals",
215
+ "Seahawks", "Broncos", "Raiders", "Chargers", "Dolphins", "Jets", "Colts", "Titans",
216
+ "Jaguars", "Texans", "Browns", "Bengals", "Lions", "Vikings", "Bears", "Commanders",
217
+
218
+ # NFL Positions
219
+ "quarterback", "QB", "running back", "wide receiver", "tight end", "offensive line",
220
+ "defensive end", "linebacker", "cornerback", "safety", "kicker", "punter",
221
+ "center", "guard", "tackle", "fullback", "nose tackle", "middle linebacker",
222
+
223
+ # NFL Terminology
224
+ "touchdown", "field goal", "first down", "second down", "third down", "fourth down",
225
+ "punt", "fumble", "interception", "sack", "blitz", "snap", "hike", "audible",
226
+ "red zone", "end zone", "yard line", "scrimmage", "pocket", "shotgun formation",
227
+ "play action", "screen pass", "draw play", "bootleg", "rollout", "scramble",
228
+ "timeout", "penalty", "flag", "holding", "false start", "offside", "encroachment",
229
+ "pass interference", "roughing the passer", "illegal formation", "delay of game",
230
+
231
+ # Game Situations
232
+ "two minute warning", "overtime", "coin toss", "kickoff", "touchback", "fair catch",
233
+ "onside kick", "safety", "conversion", "extra point", "two point conversion",
234
+ "challenge", "replay", "incomplete", "completion", "rushing yards", "passing yards",
235
+
236
+ # Common Commentary
237
+ "yards to go", "first and ten", "goal line", "midfield", "hash marks",
238
+ "pocket presence", "arm strength", "accuracy", "mobility", "coverage",
239
+ "rush defense", "pass rush", "secondary", "offensive line", "defensive line"
240
+ ]
241
+
242
+ NFL_PROMPT = " ".join(NFL_SPORTS_CONTEXT[:20]) # Use first 20 terms as prompt context
243
+
244
  # === Audio Loading via FFmpeg ===
245
  def load_audio(path: str, sr: int = 16000):
246
+ """Enhanced audio loading with filtering and normalization"""
247
  cmd = [
248
  "ffmpeg", "-i", path,
249
+ "-af", "highpass=f=80,lowpass=f=8000,loudnorm", # Filter noise and normalize
250
  "-f", "s16le",
251
  "-acodec", "pcm_s16le",
252
  "-ac", "1", "-ar", str(sr),
 
255
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
256
  raw = proc.stdout.read()
257
  audio = np.frombuffer(raw, np.int16).astype(np.float32) / 32768.0
258
+
259
+ # Normalize audio levels
260
+ if len(audio) > 0:
261
+ audio = audio / (np.max(np.abs(audio)) + 1e-8)
262
+
263
  return audio, sr
264
 
265
+ # === Enhanced Transcription with Sports Context ===
266
  def transcribe_clip(path: str) -> str:
267
  audio, sr = load_audio(path, sr=16000)
268
+
269
+ # Skip transcription if audio is too short or quiet
270
+ if len(audio) < sr * 0.5: # Less than 0.5 seconds
271
+ return ""
272
+
273
+ if np.max(np.abs(audio)) < 0.01: # Very quiet audio
274
+ return ""
275
+
276
+ try:
277
+ # Use enhanced generation parameters for better NFL transcription
278
+ result = asr(
279
+ audio,
280
+ generate_kwargs={
281
+ "language": "en",
282
+ "task": "transcribe",
283
+ "no_repeat_ngram_size": 3, # Reduce repetitive transcriptions
284
+ "temperature": 0.0, # More deterministic output
285
+ "do_sample": False, # Use greedy decoding for consistency
286
+ "num_beams": 1 # Faster single-beam search
287
+ }
288
+ )
289
+ text = result.get("text", "").strip()
290
+
291
+ # Clean up common Whisper artifacts
292
+ text = text.replace("[BLANK_AUDIO]", "").strip()
293
+ text = text.replace("♪", "").strip() # Remove music notes
294
+
295
+ # Post-process with sports-specific corrections
296
+ text = apply_sports_corrections(text)
297
+
298
+ return text
299
+ except Exception as e:
300
+ print(f"[WARN] Transcription failed: {e}")
301
+ return ""
302
+
303
+ def apply_sports_corrections(text: str) -> str:
304
+ """Apply NFL-specific text corrections and standardization"""
305
+ import re
306
+
307
+ if not text:
308
+ return text
309
+
310
+ # Common misheard sports terms corrections
311
+ corrections = {
312
+ # Position corrections
313
+ r'\bqb\b': "QB",
314
+ r'\bquarter back\b': "quarterback",
315
+ r'\bwide receiver\b': "wide receiver",
316
+ r'\btight end\b': "tight end",
317
+ r'\brunning back\b': "running back",
318
+ r'\bline backer\b': "linebacker",
319
+ r'\bcorner back\b': "cornerback",
320
+
321
+ # Play corrections
322
+ r'\btouch down\b': "touchdown",
323
+ r'\bfield goal\b': "field goal",
324
+ r'\bfirst down\b': "first down",
325
+ r'\bsecond down\b': "second down",
326
+ r'\bthird down\b': "third down",
327
+ r'\bfourth down\b': "fourth down",
328
+ r'\byard line\b': "yard line",
329
+ r'\bend zone\b': "end zone",
330
+ r'\bred zone\b': "red zone",
331
+ r'\btwo minute warning\b': "two minute warning",
332
+
333
+ # Common misheard words
334
+ r'\bfourty\b': "forty",
335
+ r'\bfourty yard\b': "forty yard",
336
+ r'\btwenny\b': "twenty",
337
+ r'\bthirty yard\b': "thirty yard",
338
+
339
+ # Numbers/downs that are often misheard
340
+ r'\b1st\b': "first",
341
+ r'\b2nd\b': "second",
342
+ r'\b3rd\b': "third",
343
+ r'\b4th\b': "fourth",
344
+ r'\b1st and 10\b': "first and ten",
345
+ r'\b2nd and long\b': "second and long",
346
+ r'\b3rd and short\b': "third and short",
347
+
348
+ # Team name corrections (common mishears)
349
+ r'\bforty niners\b': "49ers",
350
+ r'\bforty-niners\b': "49ers",
351
+ r'\bsan francisco\b': "49ers",
352
+ r'\bnew england\b': "Patriots",
353
+ r'\bgreen bay\b': "Packers",
354
+ r'\bkansas city\b': "Chiefs",
355
+ r'\bnew york giants\b': "Giants",
356
+ r'\bnew york jets\b': "Jets",
357
+ r'\blos angeles rams\b': "Rams",
358
+ r'\blos angeles chargers\b': "Chargers",
359
+
360
+ # Yard markers and positions
361
+ r'\b10 yard line\b': "ten yard line",
362
+ r'\b20 yard line\b': "twenty yard line",
363
+ r'\b30 yard line\b': "thirty yard line",
364
+ r'\b40 yard line\b': "forty yard line",
365
+ r'\b50 yard line\b': "fifty yard line",
366
+ r'\bmid field\b': "midfield",
367
+ r'\bgoal line\b': "goal line",
368
+
369
+ # Penalties and flags
370
+ r'\bfalse start\b': "false start",
371
+ r'\boff side\b': "offside",
372
+ r'\bpass interference\b': "pass interference",
373
+ r'\broughing the passer\b': "roughing the passer",
374
+ r'\bdelay of game\b': "delay of game",
375
+
376
+ # Common play calls
377
+ r'\bplay action\b': "play action",
378
+ r'\bscreen pass\b': "screen pass",
379
+ r'\bdraw play\b': "draw play",
380
+ r'\bboot leg\b': "bootleg",
381
+ r'\broll out\b': "rollout",
382
+ r'\bshot gun\b': "shotgun",
383
+ r'\bno huddle\b': "no huddle"
384
+ }
385
+
386
+ # Apply corrections (case-insensitive)
387
+ corrected_text = text
388
+ for pattern, replacement in corrections.items():
389
+ corrected_text = re.sub(pattern, replacement, corrected_text, flags=re.IGNORECASE)
390
+
391
+ # Capitalize specific terms that should always be capitalized
392
+ capitalize_terms = ["NFL", "QB", "Patriots", "Cowboys", "Chiefs", "Packers", "49ers",
393
+ "Eagles", "Giants", "Rams", "Saints", "Bills", "Ravens", "Steelers"]
394
+ for term in capitalize_terms:
395
+ pattern = r'\b' + re.escape(term.lower()) + r'\b'
396
+ corrected_text = re.sub(pattern, term, corrected_text, flags=re.IGNORECASE)
397
+
398
+ # Enhanced spell-check for common NFL terms using fuzzy matching
399
+ corrected_text = fuzzy_sports_corrections(corrected_text)
400
+
401
+ return corrected_text.strip()
402
+
403
+ def fuzzy_sports_corrections(text: str) -> str:
404
+ """Apply fuzzy matching for sports terms that might be slightly misheard"""
405
+ import re
406
+
407
+ # Define common NFL terms and their likely misspellings
408
+ fuzzy_corrections = {
409
+ # Team names with common misspellings
410
+ r'\bpatriots?\b': "Patriots",
411
+ r'\bcowboys?\b': "Cowboys",
412
+ r'\bpackers?\b': "Packers",
413
+ r'\bchief\b': "Chiefs",
414
+ r'\bchiefs?\b': "Chiefs",
415
+ r'\beagles?\b': "Eagles",
416
+ r'\bgiants?\b': "Giants",
417
+ r'\brams?\b': "Rams",
418
+ r'\bsaints?\b': "Saints",
419
+
420
+ # Positions with common variations
421
+ r'\bquarterbacks?\b': "quarterback",
422
+ r'\brunning backs?\b': "running back",
423
+ r'\bwide receivers?\b': "wide receiver",
424
+ r'\btight ends?\b': "tight end",
425
+ r'\blinebackers?\b': "linebacker",
426
+ r'\bcornerbacks?\b': "cornerback",
427
+ r'\bsafety\b': "safety",
428
+ r'\bsafeties\b': "safety",
429
+
430
+ # Play terms
431
+ r'\btouchdowns?\b': "touchdown",
432
+ r'\bfield goals?\b': "field goal",
433
+ r'\binterceptions?\b': "interception",
434
+ r'\bfumbles?\b': "fumble",
435
+ r'\bsacks?\b': "sack",
436
+ r'\bpunt\b': "punt",
437
+ r'\bpunts?\b': "punt",
438
+
439
+ # Numbers and yards
440
+ r'\byards?\b': "yard",
441
+ r'\byards? line\b': "yard line",
442
+ r'\byard lines?\b': "yard line"
443
+ }
444
+
445
+ corrected = text
446
+ for pattern, replacement in fuzzy_corrections.items():
447
+ corrected = re.sub(pattern, replacement, corrected, flags=re.IGNORECASE)
448
+
449
+ return corrected
450
 
451
  # === CLI ===
452
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -4,3 +4,5 @@ pytorchvideo
4
  transformers
5
  huggingface_hub
6
  ffmpeg-python
 
 
 
4
  transformers
5
  huggingface_hub
6
  ffmpeg-python
7
+ # For better audio transcription
8
+ openai-whisper
run_all_clips.py CHANGED
@@ -7,10 +7,10 @@ results to separate JSON files as they're generated.
7
  import os
8
  import glob
9
  import json
10
- from inference import predict_clip, transcribe_clip
11
 
12
 
13
- def main(input_dir: str = "data", classification_file: str = "classification.json", transcript_file: str = "transcripts.json"):
14
  # find video files
15
  patterns = ["*.mov", "*.mp4"]
16
  clips = []
@@ -23,6 +23,7 @@ def main(input_dir: str = "data", classification_file: str = "classification.jso
23
 
24
  classification_results = {}
25
  transcript_results = {}
 
26
 
27
  # Ensure output files exist with empty JSON if first write fails
28
  try:
@@ -36,6 +37,15 @@ def main(input_dir: str = "data", classification_file: str = "classification.jso
36
  json.dump(transcript_results, f, indent=2)
37
  except Exception as e:
38
  print(f"[WARN] Could not initialize {transcript_file}: {e}")
 
 
 
 
 
 
 
 
 
39
 
40
  for clip in clips:
41
  clip_name = os.path.basename(clip)
@@ -45,6 +55,17 @@ def main(input_dir: str = "data", classification_file: str = "classification.jso
45
  print("Running video classification...")
46
  scores = predict_clip(clip)
47
  classification_results[clip_name] = scores
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  # Print classification results to console
50
  if scores:
@@ -76,10 +97,61 @@ def main(input_dir: str = "data", classification_file: str = "classification.jso
76
  json.dump(transcript_results, f, indent=2)
77
  except Exception as e:
78
  print(f"[ERROR] Failed to write {transcript_file}: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  print(f"\nFinished processing. Results saved to:")
81
  print(f" - Classifications: '{classification_file}'")
82
  print(f" - Transcripts: '{transcript_file}'")
 
83
 
84
 
85
  if __name__ == "__main__":
 
7
  import os
8
  import glob
9
  import json
10
+ from inference import predict_clip, transcribe_clip, detect_play_boundaries, analyze_play_state
11
 
12
 
13
+ def main(input_dir: str = "data", classification_file: str = "classification.json", transcript_file: str = "transcripts.json", play_analysis_file: str = "play_analysis.json"):
14
  # find video files
15
  patterns = ["*.mov", "*.mp4"]
16
  clips = []
 
23
 
24
  classification_results = {}
25
  transcript_results = {}
26
+ play_analysis_results = {"clips": [], "play_boundaries": [], "summary": {}}
27
 
28
  # Ensure output files exist with empty JSON if first write fails
29
  try:
 
37
  json.dump(transcript_results, f, indent=2)
38
  except Exception as e:
39
  print(f"[WARN] Could not initialize {transcript_file}: {e}")
40
+
41
+ try:
42
+ with open(play_analysis_file, 'w') as f:
43
+ json.dump(play_analysis_results, f, indent=2)
44
+ except Exception as e:
45
+ print(f"[WARN] Could not initialize {play_analysis_file}: {e}")
46
+
47
+ # Store all clip results for sequence analysis
48
+ all_clip_results = []
49
 
50
  for clip in clips:
51
  clip_name = os.path.basename(clip)
 
55
  print("Running video classification...")
56
  scores = predict_clip(clip)
57
  classification_results[clip_name] = scores
58
+ all_clip_results.append(scores) # Store for sequence analysis
59
+
60
+ # Analyze play state for this clip
61
+ play_state, confidence = analyze_play_state(scores)
62
+ clip_analysis = {
63
+ "filename": clip_name,
64
+ "play_state": play_state,
65
+ "confidence": confidence,
66
+ "classifications": scores
67
+ }
68
+ play_analysis_results["clips"].append(clip_analysis)
69
 
70
  # Print classification results to console
71
  if scores:
 
97
  json.dump(transcript_results, f, indent=2)
98
  except Exception as e:
99
  print(f"[ERROR] Failed to write {transcript_file}: {e}")
100
+
101
+ try:
102
+ with open(play_analysis_file, 'w') as f:
103
+ json.dump(play_analysis_results, f, indent=2)
104
+ except Exception as e:
105
+ print(f"[ERROR] Failed to write {play_analysis_file}: {e}")
106
+
107
+ # Perform sequence analysis to detect play boundaries
108
+ print("\n=== ANALYZING PLAY SEQUENCES ===")
109
+ boundaries = detect_play_boundaries(all_clip_results)
110
+ play_analysis_results["play_boundaries"] = []
111
+
112
+ for boundary_type, clip_index, confidence in boundaries:
113
+ clip_name = os.path.basename(clips[clip_index]) if clip_index < len(clips) else f"clip_{clip_index}"
114
+ boundary_info = {
115
+ "type": boundary_type,
116
+ "clip_index": clip_index,
117
+ "clip_name": clip_name,
118
+ "confidence": confidence
119
+ }
120
+ play_analysis_results["play_boundaries"].append(boundary_info)
121
+ print(f"[{boundary_type.upper()}] {clip_name} (confidence: {confidence:.3f})")
122
+
123
+ # Generate summary statistics
124
+ play_states = [clip["play_state"] for clip in play_analysis_results["clips"]]
125
+ play_analysis_results["summary"] = {
126
+ "total_clips": len(clips),
127
+ "play_active_clips": play_states.count("play_active"),
128
+ "play_action_clips": play_states.count("play_action"),
129
+ "non_play_clips": play_states.count("non_play"),
130
+ "unknown_clips": play_states.count("unknown"),
131
+ "detected_play_starts": len([b for b in boundaries if b[0] == "play_start"]),
132
+ "detected_play_ends": len([b for b in boundaries if b[0] == "play_end"])
133
+ }
134
+
135
+ print(f"\n=== PLAY ANALYSIS SUMMARY ===")
136
+ summary = play_analysis_results["summary"]
137
+ print(f"Total clips processed: {summary['total_clips']}")
138
+ print(f"Play active clips: {summary['play_active_clips']}")
139
+ print(f"Play action clips: {summary['play_action_clips']}")
140
+ print(f"Non-play clips: {summary['non_play_clips']}")
141
+ print(f"Play starts detected: {summary['detected_play_starts']}")
142
+ print(f"Play ends detected: {summary['detected_play_ends']}")
143
+
144
+ # Final save of complete analysis
145
+ try:
146
+ with open(play_analysis_file, 'w') as f:
147
+ json.dump(play_analysis_results, f, indent=2)
148
+ except Exception as e:
149
+ print(f"[ERROR] Failed to write final {play_analysis_file}: {e}")
150
 
151
  print(f"\nFinished processing. Results saved to:")
152
  print(f" - Classifications: '{classification_file}'")
153
  print(f" - Transcripts: '{transcript_file}'")
154
+ print(f" - Play Analysis: '{play_analysis_file}'")
155
 
156
 
157
  if __name__ == "__main__":
transcripts.json CHANGED
@@ -1,79 +1,3 @@
1
  {
2
- "segment_001.mov": "YOU T WABOU GOT OM RIGT NOW",
3
- "segment_002.mov": "THE SIX TE BEST POLL BACK AND THE OT",
4
- "segment_003.mov": "WELL WELL AN THAT'S JUST KILE",
5
- "segment_004.mov": "Y BA ALF PASSING RID IT'S IT'S LI",
6
- "segment_005.mov": "GOTA CONSIDER WHAT HE IS ES ATU",
7
- "segment_006.mov": "TON AND BE PAD THAT USES AS",
8
- "segment_007.mov": "LEGS AS WELL AS HE USES HIS ARM A",
9
- "segment_008.mov": "THEY FOUND A GREAT COMMENATION",
10
- "segment_009.mov": "WITH ME A DERI GENERY BUT",
11
- "segment_010.mov": "TERGAN A SACK TO BOX AT T BANGLES",
12
- "segment_011.mov": "O LIKE TE HAVE TO PUT AITE THE BOX ALL DAY T",
13
- "segment_012.mov": "O STOP THIS RUNYAT DON'T BE SURPRISED",
14
- "segment_013.mov": "THAT E BANN HAS A PIG DAY THROUGH THE",
15
- "segment_014.mov": "ER MEMORY AN",
16
- "segment_015.mov": "FAR WORBIN THE EYE FOR",
17
- "segment_016.mov": "SH AND NOW THEY SWORTS ALWAYS ABOUT SIX",
18
- "segment_017.mov": "BOUNDS OF WARRY",
19
- "segment_018.mov": "FVEIRY MOTION IS FOAR",
20
- "segment_019.mov": "THAT GOES TO FOWERS JUC",
21
- "segment_020.mov": "WHAT BY WI PAS AND A FO",
22
- "segment_021.mov": "MY COLLAR AND OUT OF BOUNDS GOES",
23
- "segment_022.mov": "AYFLOWERS WITH A JET SWEE",
24
- "segment_023.mov": "AND ON THE POYE PICKS UP NO",
25
- "segment_024.mov": "AN TO THE THIRTY NINE",
26
- "segment_025.mov": "I MET OFFENSOF WING WAR",
27
- "segment_026.mov": "NY STANLEY HAS BEEN TERRIFIC AT THE LEAP",
28
- "segment_027.mov": "TACKLE HE'S HEALTHY HE REALLY HAS BEEN THE",
29
- "segment_028.mov": "S BEEN SOME SHUFFLING AT THE GUARDS AS YOU SEE THAT",
30
- "segment_029.mov": "ONED AROUND AND THE ROOKY ROSY GARDENAL",
31
- "segment_030.mov": "WERE ON THE SIDE PATRICK REGARD",
32
- "segment_031.mov": "FORTY TWO HE GETS OVERLOOKED ALOT",
33
- "segment_032.mov": "UT NIGOES EVERYTHING FOR THE STAN IN",
34
- "segment_033.mov": "I BAZILY LIKE AN EXTRA WISE",
35
- "segment_034.mov": "NOR EXPERT IDIN ABOUT THEIRE LEADING",
36
- "segment_035.mov": "HOLE POTIS ONEN A GREAT JU",
37
- "segment_036.mov": "P A TOP TOPEN LIFE OR TRECKEN WUP A",
38
- "segment_037.mov": "SUPPORT NETHER SLUCK A DON AND",
39
- "segment_038.mov": "THAT WHERE THE DIES",
40
- "segment_039.mov": "",
41
- "segment_040.mov": "AND A GANE OF FOR IS",
42
- "segment_041.mov": "HE'S OUT TO THE FORTY THREE",
43
- "segment_042.mov": "AND AT FIRST DOWN O",
44
- "segment_043.mov": "S A LOOK AT FOND BELL OR MAKES THAT ST",
45
- "segment_044.mov": "UP AND UNMET DEFENCE OF LIND",
46
- "segment_045.mov": "THEY GET BACK CHRISJENKINS",
47
- "segment_046.mov": "AND KILL HEDRICKS IN HIS HEALTH",
48
- "segment_047.mov": "HOPBERED ON THE OTHER SIDE AYAD",
49
- "segment_048.mov": "THAT THE DEFENCES HAS BEEN NOPIC",
50
- "segment_049.mov": "LONG SOME THIS YEAR FOR THEY ARE GETTING HEALTHY AS YOU",
51
- "segment_050.mov": "ENC O THAT GET BACMA KINLY JACKSIN TO THY THE",
52
- "segment_051.mov": "T MILE S BORK YE AL MISS LA",
53
- "segment_052.mov": "COPAL GAMES IT'S A BORGAR",
54
- "segment_053.mov": "THAT WOOKED OTHER FROM EGGERING",
55
- "segment_054.mov": "FO TE TOLL OF THAT",
56
- "segment_055.mov": "TACKLEMAY BY BOBBE",
57
- "segment_056.mov": "FORTY FIVE AND A GAIN AT TWO",
58
- "segment_057.mov": "E'LL BE JACKIN DOWN AND ATE",
59
- "segment_058.mov": "WELL IT'S GOING TO BE IMPORTANT ALL DAY",
60
- "segment_059.mov": "ONG THE TACKLE ALOW YOU GOT TO BE ABLE",
61
- "segment_060.mov": "TO TAKE THE LEGS OUT OF THEIR",
62
- "segment_061.mov": "OR KINWRY IF YOU IF YOU GO UP TOO HIGH YOU KN",
63
- "segment_062.mov": "W THAT STIP AN AND GETS IN THE OPEN FIELD TO",
64
- "segment_063.mov": "BEAD SO EXCELLENT JOB THEIR",
65
- "segment_064.mov": "R BY HILL AND HUBBARD TO BRING HIM DOWN",
66
- "segment_065.mov": "",
67
- "segment_066.mov": "SO WITH THE HEAD MI COLTEN IS",
68
- "segment_067.mov": "T TO DAY ME AND FORGIDDN'T PRACTIV",
69
- "segment_068.mov": "A WEEK D J TURN HER",
70
- "segment_069.mov": "UTS LAKIN YER BE TEN TOBACC",
71
- "segment_070.mov": "ALE A SHRIK IN TAKING HIS PLICE",
72
- "segment_071.mov": "THAN THE FIRST POSSESSION THE DAY",
73
- "segment_072.mov": "IM SECOND DOWN AND EI",
74
- "segment_073.mov": "THAT WAT GOD IS ON THE MON",
75
- "segment_074.mov": "JACKSON TO THE AIL",
76
- "segment_075.mov": "SINGS ABOUT TE OL COL",
77
- "segment_076.mov": "ERE MAKES THE GRAB",
78
- "segment_077.mov": ""
79
  }
 
1
  {
2
+ "segment_001.mov": "I can tell you that Lamar Jackson right now is"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  }