-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
1458 lines (1227 loc) · 70.8 KB
/
index.html
1
2
3
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- (C) The Hyperaudio Project. AGPL 3.0 @license: https://www.gnu.org/licenses/agpl-3.0.en.html -->
<!-- Hyperaudio Lite Editor - Version 0.4.5 -->
<!-- Hyperaudio Lite Editor's source code is provided under a dual license model.
Commercial license
------------------
If you want to use Hyperaudio Lite Editor to develop commercial sites, tools, and applications, the Commercial License is the appropriate license. With this option, your source code is kept proprietary. To enquire about a Hyperaudio Lite Editor Commercial License please contact [email protected]
Open source license
-------------------
If you are creating an open source application under a license compatible with the GNU Affero GPL license v3, you may use Hyperaudio Lite Editor under the terms of the AGPL-3.0 License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hyperaudio Lite Editor</title>
<link rel="apple-touch-icon" href="images/icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
<link rel="stylesheet" href="css/hyperaudio-lite-player.css">
<script src="js/hyperaudio-lite-editor-deepgram.js"></script>
<script src="js/hyperaudio-lite-editor-whisper.js"></script>
<!-- DaisyUI / Tailwind -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
<!-- Meta Tags required for
Progressive Web App -->
<meta name= "apple-mobile-web-app-status-bar" content="#aa7700">
<meta name="theme-color" content="black">
<!-- Manifest File link -->
<link rel="manifest" href="manifest.json">
<style>
p {
padding-bottom: 1.5em;
line-height: 1.8;
}
.side-panel {
background-color: #efefef;
position: absolute;
top: 0;
left: 0;
bottom: 0;
padding: 8px;
overflow-y: hidden;
width: 400px;
transition: left 0.5s ease;
}
.side-panel h1 {
color: white;
}
.main-panel {
position: absolute;
left:400px;
right:0;
transition: left 0.5s ease;
}
#speaker-display {
margin-top: -30px;
text-align: right;
padding-right: 20px;
}
[contenteditable]:focus {
outline: 0px solid transparent;
}
</style>
<link rel="stylesheet" href="css/hyperaudio-lite-editor.css">
</head>
<body data-theme="light">
<!-- templates -->
<template id="deepgram-modal-template">
<form id="deepgram-form" name="deepgram-form">
<div class="flex flex-col gap-4 w-full">
<input id="token" type="text" placeholder="Deepgram token" class="input input-bordered w-full max-w-xs" />
<hr class="my-2 h-0 border border-t-0 border-solid border-neutral-700 opacity-50 dark:border-neutral-200" />
<input id="deepgram-media" type="text" placeholder="Link to media" class="input input-bordered w-full max-w-xs" />
<span class="label-text">or</span>
<input id="deepgram-file" name="file" type="file" class="file-input w-full max-w-xs" />
<hr class="my-2 h-0 border border-t-0 border-solid border-neutral-700 opacity-50 dark:border-neutral-200" />
<span class="label-text">Model</span>
<div>
<select id="language-model" name="language-model" placeholder="language-model" class="select select-bordered w-full max-w-xs">
</select>
</div>
<span class="label-text">Language</span>
<select id="language" name="language" placeholder="language" class="select select-bordered w-full max-w-xs">
</select>
<span class="label-text">Quality</span>
<select id="tier" name="tier" placeholder="tier" class="select select-bordered w-full max-w-xs">
<option value="base">Base</option>
<option value="enhanced">Enhanced (Better)</option>
<option value="nova">Nova-2 (Best)</option>
</select>
</div>
<div class="modal-action">
<label id="transcribe-btn" for="transcribe-modal" class="btn btn-primary">TRANSCRIBE</label>
</div>
</form>
</template>
<template id="whisper-client-template">
<form>
<div class="mb-3">
<input id="media" type="text" placeholder="Link to media" class="input input-bordered w-full max-w-xs" disabled />
<span style="display:block; padding:16px" class="label-text">or</span>
<input id="file-input" name="file" type="file" class="file-input w-full max-w-xs" />
<hr class="my-2 h-0 border border-t-0 border-solid border-neutral-700 opacity-50 dark:border-neutral-200" />
</div>
<div class="mb-3">
<label for="model-name-input" class="form-label label-text">Which model should be used?</label>
<div>
<select class="form-select select select-bordered w-full max-w-xs" aria-label="Default select example" id="model-name-input">
<option selected="" value="Xenova/whisper-tiny.en">Whisper (Tiny) English</option>
<option value="Xenova/whisper-tiny">Whisper (Tiny)</option>
<option value="Xenova/whisper-base.en">Whisper (Base) English</option>
<option value="Xenova/whisper-base">Whisper (Base)</option>
<option value="Xenova/whisper-small.en">Whisper (Small) English</option>
<option value="Xenova/whisper-small">Whisper (Small)</option>
<option value="distil-whisper/distil-small.en">Whisper Distil (Small) English</option>
</select>
</div>
<div class="form-text" style="font-size: 90%;">
<p style="padding-top:16px">The models are listed in order of size. The larger the model, the more accurate it is – and slower to process.</p>
<p>The English models are slightly more accurate (for the English language only).</p>
<p>* Whisper running in the browser is currently in beta.</p>
</div>
</div>
<div class="modal-action">
<label id="form-submit-btn" for="transcribe-modal" class="btn btn-primary">TRANSCRIBE</label>
</div>
</form>
</template>
<template id="caption-template-holder">
<div id="caption-template" class="caption">
<div class="caption-row">
<button class="play btn btn-primary btn-sm" onclick="playClip(this)">play clip <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg></button>
</div>
<div class="caption-row">
<button class="play-start btn btn-outline btn-xs" onclick="seekTo(this)" style="margin-right:4px"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-skip-forward"><polygon points="5 4 15 12 5 20 5 4"></polygon><line x1="19" x2="19" y1="5" y2="19"></line></svg></button><input class="start" value="" oninput="captionChange()">(In)
</div>
<div class="caption-row">
<button class="play-end btn btn-outline btn-xs" onclick="seekTo(this)" style="margin-right:4px"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-skip-forward"><polygon points="5 4 15 12 5 20 5 4"></polygon><line x1="19" x2="19" y1="5" y2="19"></line></svg></button><input class="end" value="" oninput="captionChange()">(Out)
</div>
<div class="caption-row">
<input class="line1" value="" oninput="captionChange()">
</div>
<div class="caption-row">
<input class="line2" value="" oninput="captionChange()">
</div>
<div class="caption-row btn-group btn-group-horizontal">
<button class="btn btn-outline btn-xs" onclick="addCaption(this)">insert <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line"><line x1="12" x2="12" y1="17" y2="3"></line><polyline points="6 11 12 17 18 11"></polyline><path d="M19 21H5"></path></svg></button>
<button class="btn btn-outline btn-xs" onclick="mergeCaption(this)">merge <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-from-line"><line x1="12" x2="12" y1="21" y2="7"></line><polyline points="6 15 12 21 18 15"></polyline><path d="M19 3H5"></path></svg></button>
<button class="btn btn-outline btn-xs" onclick="deleteCaption(this)">delete <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" x2="10" y1="11" y2="17"></line><line x1="14" x2="14" y1="11" y2="17"></line></svg></button>
</div>
<div class="divider"></div>
</div>
</template>
<!-- end of templates -->
<div class="holder grid grid-flow-col auto-cols-max">
<div class="side-panel">
<div>
<div class="top-bar-item">
<!-- example src -->
<div>
<video id="hyperplayer" class="hyperaudio-player" src="https://lab.hyperaud.io/video/HALiteIntro.mp4" type="video/mp4" controls poster="images/poster.png" style="width:400px; margin-left: -8px;">
<track id="hyperplayer-vtt" label="preview" kind="subtitles" src="">
</video>
</div>
</div>
<div class="top-bar-item">
<div id="pbr-holder" style="display: grid; grid-template-columns: 0.65fr 1.05fr 0.3fr; grid-gap: 10px;">
<div>
<label for="pbr">Playback Rate</label>
</div>
<div>
<input id="pbr" type="range" min="0.4" max="2.4" value="1" step="0.2" class="range range-md range-primary" />
<!--<div class="w-full flex justify-between text-xs px-2">-->
</div>
<div style="padding-right: 12px;">
<div class="hidden-label-holder">
<label style="width:0px;position:absolute;top:-100px" for="currentPbr">Playback Rate Value</label>
</div>
<input id="currentPbr" class="input input-bordered input-xs w-full max-w-xs" style="width:60px" type="number" id="pbr" name="pbr" value="1" step="0.2" min="0.4" max="2.4">
</div>
</div>
</div>
<div class="form-control">
<span style="text-align: right; padding-right: 12px; padding-top: 12px;">
<label for="show-speakers">Display speakers </label>
<input type="checkbox" id="show-speakers" name="show-speakers" checked="checked" class="checkbox checkbox-primary"/>
</span>
</div>
<div class="tabs">
<a class="tab tab-lifted tab-active"><strong>Local Storage</strong></a>
</div>
<div style="display: flex; overflow-y:scroll; ">
<div style="height:360px">
<ul id="file-picker" class="menu menu-compact bg-base-100 w-full" style="width:360px; height:360px">
</ul>
</div>
</div>
<div style="position: absolute; bottom: 16px; ">
<a href="https://deepgram.com">Powered by
<svg width="113" height="22" viewBox="0 0 226 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.8791 5.04737C29.0844 8.30338 30.8081 12.6072 30.7405 17.1645V17.1588C30.5997 26.3353 22.8878 33.7994 13.5536 33.7994H0.439392C0.19153 33.7994 0.0675988 33.5008 0.242229 33.3206L6.62468 26.9043C6.73171 26.7973 6.87254 26.7353 7.02464 26.7353H13.6775C19.0291 26.7353 23.5131 22.4541 23.6708 17.1983C23.7497 14.5168 22.7639 11.9819 20.8937 10.0553C19.0234 8.12875 16.5166 7.0697 13.8408 7.0697H7.0697V18.0094C7.0697 18.1052 6.99647 18.1784 6.90071 18.1784H0.168997C0.073232 18.1784 0 18.1052 0 18.0094V0.16899C0 0.0732251 0.073232 0 0.168997 0H13.8408C18.3981 0 22.6737 1.79136 25.8791 5.04737ZM45.1 9.06367C36.853 9.06367 33.09 15.3842 33.09 21.5582L33.0844 21.5638C33.0844 27.6928 37.3318 34.1541 45.5789 34.1541C51.4825 34.1541 56.0679 30.8643 57.1157 25.7268C57.1383 25.6197 57.0538 25.5183 56.9467 25.5183H50.722C50.6488 25.5183 50.5868 25.569 50.5643 25.6423C49.9953 27.6364 48.2265 28.656 45.5789 28.656C42.2046 28.656 40.0358 26.5323 39.5513 23.1073H56.8566C56.9467 23.1073 57.02 23.0454 57.0256 22.9552C57.0707 22.437 57.1101 21.7666 57.1101 20.9329C57.1101 15.3842 53.3471 9.06367 45.1 9.06367ZM45.1 13.9815C48.3335 13.9815 50.215 16.1503 50.4065 18.8542H39.6471C40.2273 15.4743 42.0637 13.9815 45.1 13.9815ZM60.0534 21.5582C60.0534 15.3842 63.8164 9.06367 72.0635 9.06367C80.3105 9.06367 84.0735 15.3842 84.0735 20.9329C84.0735 21.7666 84.0341 22.437 83.989 22.9552C83.9834 23.0454 83.9102 23.1073 83.82 23.1073H66.5148C66.9992 26.5323 69.168 28.656 72.5423 28.656C75.1899 28.656 76.9588 27.6364 77.5277 25.6423C77.5502 25.569 77.6122 25.5183 77.6854 25.5183H83.9102C84.0172 25.5183 84.1017 25.6197 84.0792 25.7268C83.0314 30.8643 78.4459 34.1541 72.5423 34.1541C64.2953 34.1541 60.0478 27.6928 60.0478 21.5638L60.0534 21.5582ZM77.37 18.8542C77.1785 16.1503 75.297 13.9815 72.0635 13.9815C69.0272 13.9815 67.1907 15.4743 66.6105 18.8542H77.37ZM94.3462 9.45236H87.9807V9.44109C87.8849 9.44109 87.8117 9.51433 87.8117 9.6101V43.4264C87.8117 43.5221 87.8849 43.5954 87.9807 43.5954H94.3462C94.442 43.5954 94.5152 43.5221 94.5152 43.4264V31.5853C95.8165 33.2246 98.1825 34.1428 100.931 34.1428C107.928 34.1428 112.654 29.1743 112.654 21.6032C112.654 14.0322 108.311 9.06367 101.461 9.06367C98.3233 9.06367 95.963 10.2241 94.5152 12.1056V9.62136C94.5152 9.52559 94.442 9.45236 94.3462 9.45236ZM105.996 21.6089C105.996 25.6592 103.635 28.3631 100.064 28.3631C96.4981 28.3631 94.1322 25.7042 94.1322 21.6089C94.1322 17.5135 96.4981 14.8096 100.064 14.8096C103.63 14.8096 105.996 17.5586 105.996 21.6089ZM122.445 38.5088C122.552 38.4018 122.693 38.3455 122.845 38.3455H129.684C131.757 38.3455 133.204 36.7062 133.204 34.4867V31.3039C131.948 33.0897 129.391 34.1487 126.546 34.1487C119.358 34.1487 115.065 29.1802 115.065 21.6091C115.065 14.0381 119.358 9.06956 126.45 9.06956C129.441 9.06956 131.802 10.1793 133.204 11.8693V9.62724C133.204 9.53148 133.278 9.45823 133.373 9.45823H139.739C139.835 9.45823 139.908 9.53148 139.908 9.62724V35.219C139.908 40.2382 136.291 43.6125 130.793 43.6125H118.045C117.792 43.6125 117.668 43.3083 117.848 43.1337L122.445 38.5201V38.5088ZM127.611 28.3577C131.278 28.3577 133.593 25.7045 133.593 21.6035C133.593 17.5025 131.278 14.8042 127.611 14.8042C123.943 14.8042 121.679 17.5081 121.679 21.6035C121.679 25.6989 124.045 28.3577 127.611 28.3577ZM151.557 33.5912V21.9417H151.563C151.563 17.79 153.056 15.041 156.385 15.041H160.221C160.317 15.041 160.39 14.9678 160.39 14.872V9.61622C160.39 9.52045 160.317 9.44721 160.221 9.44721H157.686C154.695 9.44721 152.859 10.4556 151.557 13.4975V9.61622C151.557 9.52045 151.484 9.44721 151.388 9.44721H145.023C144.927 9.44721 144.854 9.52045 144.854 9.61622V33.5912C144.854 33.687 144.927 33.7602 145.023 33.7602H151.388C151.484 33.7602 151.557 33.687 151.557 33.5912ZM162.532 26.8654C162.532 22.0884 166.103 19.193 171.455 19.193H175.505C176.711 19.193 177.336 18.4212 177.336 17.4072C177.336 15.3793 175.792 13.9822 173.043 13.9822C170.294 13.9822 168.638 15.7229 168.514 17.6832C168.514 17.7734 168.441 17.841 168.351 17.841H162.712C162.611 17.841 162.532 17.7565 162.537 17.6551C162.87 12.8668 166.807 9.05877 173.381 9.05877C179.555 9.05877 184.039 12.6302 184.039 18.1283V33.5859C184.039 33.6816 183.966 33.7548 183.87 33.7548H177.505C177.409 33.7548 177.336 33.6816 177.336 33.5859V30.3805C176.513 32.6451 173.815 34.1435 170.486 34.1435C165.805 34.1435 162.526 31.0058 162.526 26.8598L162.532 26.8654ZM172.227 29.2764C175.46 29.2764 177.342 26.8654 177.342 23.7784V23.4404H172.469C170.396 23.4404 168.993 24.6966 168.993 26.5781C168.993 28.1723 170.345 29.2821 172.227 29.2821V29.2764ZM194.671 9.45236H188.305L188.317 9.44673C188.221 9.44673 188.148 9.51997 188.148 9.61573V33.5908C188.148 33.6865 188.221 33.7598 188.317 33.7598H194.682C194.778 33.7598 194.851 33.6865 194.851 33.5908V19.964C194.851 16.8263 196.631 14.7532 199.431 14.7532C202.034 14.7532 203.724 16.8263 203.724 19.964V33.5908C203.724 33.6865 203.797 33.7598 203.893 33.7598H210.258C210.354 33.7598 210.427 33.6865 210.427 33.5908V19.964C210.427 16.8263 212.207 14.7532 215.007 14.7532C217.609 14.7532 219.299 16.8263 219.299 19.964V33.5908C219.299 33.6865 219.373 33.7598 219.468 33.7598H225.834C225.93 33.7598 226.003 33.6865 226.003 33.5908V17.8402C226.003 12.9731 222.578 9.06367 217.322 9.06367C213.418 9.06367 210.376 11.1367 209.171 13.5027C208.01 10.6072 205.549 9.06367 201.741 9.06367C198.457 9.06367 196.141 10.6579 194.84 12.8774V9.62136C194.84 9.52559 194.767 9.45236 194.671 9.45236Z" fill="black"></path>
</svg>
</a>
</div>
</div>
</div>
<div class="main-panel" style="z-index: 2">
<div class="navbar bg-base-100" style="background-color: #ffffff; opacity:0.95;">
<div class="navbar-start">
<button id="sidebar-toggle" class="btn btn-square btn-outline" aria-label="Toggle Sidebar">
<svg id="sidebar-close-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sidebar-close"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"></rect><path d="M9 3v18"></path><path d="m16 15-3-3 3-3"></path></svg>
<svg id="sidebar-open-icon" style="display: none" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sidebar-open"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"></rect><path d="M9 3v18"></path><path d="m14 9 3 3-3 3"></path></svg>
</button>
<button id="strikethrough" class="btn btn-square btn-outline" aria-label="Strike through text">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-strikethrough"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>
</button>
<div class="dropdown menu-compact">
<label tabindex="0" class="btn m-1 btn-outline gap-2">
<span id="file-dropdown-text">FILE</span>
<svg id="file-dropdown-symbol" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
<svg id="file-dropdown-symbol-mobile" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-menu"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>
</label>
<ul id="file-dropdown" tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52">
<li class="menu-title">
<span>
Download as
</span>
</li>
<li><a id="download-vtt" href="" download="hyperaudio.vtt">WebVTT (Captions)</a></li>
<li><a id="download-srt" href="" download="hyperaudio.srt">SRT (Captions)</a></li>
<li><a id="download-html" href="" download="hypertranscript.html">HTML</a></li>
<li><a id="download-hypertranscript" href="" download="hyperaudio.html">Interactive Transcript</a></li>
<li><a id="download-wav-cut">WAV</a></li>
<hr
class="my-2 h-0 border border-t-0 border-solid border-neutral-700 opacity-25 dark:border-neutral-200" />
<li class="menu-title">
<span>
Export / Import
</span>
</li>
<li><export-json></export-json></li>
<li><import-json></import-json></li>
<li><label for="file-import-deepgram-json-dialog">Import Deepgram JSON</label></li>
<li><import-srt></import-srt></li>
</ul>
</div>
<label for="info-modal" class="btn btn-ghost btn-primary gap-2">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"></circle><line x1="12" x2="12" y1="16" y2="12"></line><line x1="12" x2="12.01" y1="8" y2="8"></line></svg>
</label>
<input type="checkbox" id="info-modal" class="modal-toggle" />
<div class="modal">
<div class="modal-box relative">
<label for="info-modal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<h3 class="text-lg font-bold">Summary</h3>
<p id="summary" class="py-4"></p>
<h3 class="text-lg font-bold">Topics</h3>
<p id="topics" class="py-4"></p>
</div>
</div>
</div>
<div class="navbar-center">
<div class="form-control">
<input id="search-box" type="text" placeholder="Search" class="input input-bordered" />
</div>
</div>
<div class="navbar-end" style="padding-right: 8px;">
<label for="captions-modal" class="btn btn-outline gap-2" style="margin-right:4px">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-subtitles"><path d="M7 13h4"></path><path d="M15 13h2"></path><path d="M7 9h2"></path><path d="M13 9h4"></path><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10Z"></path></svg>
</label>
<input type="checkbox" id="captions-modal" class="modal-toggle" />
<div class="modal">
<div class="modal-box relative">
<label for="captions-modal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<button id="regenerate-btn" class="btn btn-disabled btn-outline btn-primary">Re-generate Captions from Transcript <svg id="regenerate-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-list-restart"><path d="M21 6H3"></path><path d="M7 12H3"></path><path d="M7 18H3"></path><path d="M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14"></path><path d="M11 10v4h4"></path></svg></button>
<div id="caption-editor">
<center>Preparing captions....</center>
</div>
<!--<caption-service></caption-service>-->
</div>
</div>
<label for="transcribe-modal" class="btn btn-primary gap-2">
<span id="transcribe-label">TRANSCRIBE</span>
<span id="transcribe-label-mobile">NEW</span>
<svg id="transcribe-logo" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sticker"><path d="M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z"></path><path d="M15 3v6h6"></path><path d="M10 16s.8 1 2 1c1.3 0 2-1 2-1"></path><path d="M8 13h0"></path><path d="M16 13h0"></path></svg>
</label>
</div>
</div>
</div>
<div class="transcript-holder">
<div id="hypertranscript" class="hyperaudio-transcript" contenteditable="true">
<!-- example data -->
<article>
<section>
<p>
<span data-m="560" data-d="0" class="speaker">[Angela] </span>
<span data-m="560" data-d="240">The </span>
<span data-m="800" data-d="640">Hyperaudio </span>
<span data-m="1440" data-d="240">Lite </span>
<span data-m="1680" data-d="400">Editor </span>
<span data-m="2080" data-d="320">makes </span>
<span data-m="2400" data-d="400">audio </span>
<span data-m="2800" data-d="240">and </span>
<span data-m="3040" data-d="400">video </span>
<span data-m="3440" data-d="240">more </span>
<span data-m="3680" data-d="480">accessible </span>
<span data-m="4160" data-d="240">through </span>
<span data-m="4400" data-d="160">the </span>
<span data-m="4560" data-d="480">creation </span>
<span data-m="5040" data-d="240">of </span>
<span data-m="5280" data-d="400">captions </span>
<span data-m="5680" data-d="240">and </span>
<span data-m="5920" data-d="500">interactive </span>
<span data-m="6640" data-d="500">transcripts. </span>
</p>
<p>
<span data-m="8240" data-d="240">The </span>
<span data-m="8480" data-d="320">first </span>
<span data-m="8800" data-d="320">step </span>
<span data-m="9130" data-d="160">is </span>
<span data-m="9290" data-d="80">to </span>
<span data-m="9370" data-d="500">transcribe </span>
<span data-m="10010" data-d="240">your </span>
<span data-m="10240" data-d="500">content. </span>
</p>
<p>
<span data-m="11530" data-d="240">We </span>
<span data-m="11760" data-d="240">use </span>
<span data-m="12000" data-d="160">the </span>
<span data-m="12160" data-d="500">Deepgram </span>
<span data-m="12720" data-d="320">API </span>
<span data-m="13040" data-d="240">which </span>
<span data-m="13290" data-d="500">produces </span>
<span data-m="13920" data-d="240">high </span>
<span data-m="14160" data-d="400">quality </span>
<span data-m="14560" data-d="500">transcripts </span>
<span data-m="15290" data-d="240">in </span>
<span data-m="15530" data-d="320">double-</span>
<span data-m="15840" data-d="400">quick </span>
<span data-m="16240" data-d="460">time. </span>
<span data-m="17180" data-d="500">Deepgram </span>
<span data-m="17740" data-d="160">are </span>
<span data-m="17900" data-d="480">offering </span>
<span data-m="18380" data-d="500">45,000 </span>
<span data-m="19420" data-d="320">minutes </span>
<span data-m="19740" data-d="240">of </span>
<span data-m="19980" data-d="500">transcription </span>
<span data-m="20700" data-d="240">for </span>
<span data-m="20940" data-d="500">free. </span>
</p>
<p>
<span data-m="22060" data-d="160">You </span>
<span data-m="22220" data-d="240">can </span>
<span data-m="22460" data-d="240">use </span>
<span data-m="22700" data-d="160">the </span>
<span data-m="22860" data-d="500">Deepgram </span>
<span data-m="23420" data-d="320">token </span>
<span data-m="23740" data-d="240">with </span>
<span data-m="23980" data-d="240">this </span>
<span data-m="24220" data-d="500">application. </span>
</p>
<p>
<span data-d="0" data-m="25770" class="speaker">[Angela] </span>
<span data-m="25770" data-d="240"> Once </span>
<span data-m="26020" data-d="500">transcribed, </span>
<span data-m="26890" data-d="240">you </span>
<span data-m="27140" data-d="160">can </span>
<span data-m="27300" data-d="400">correct </span>
<span data-m="27700" data-d="160">the </span>
<span data-m="27860" data-d="500">transcript </span>
<span data-m="28410" data-d="160">and </span>
<span data-m="28570" data-d="240">add </span>
<span data-m="28820" data-d="240">speaker </span>
<span data-m="29050" data-d="320">names </span>
<span data-m="29380" data-d="400">between </span>
<span data-m="29770" data-d="480">square </span>
<span data-m="30260" data-d="500">brackets. </span>
</p>
<p>
<span data-m="31610" data-d="240">Just </span>
<span data-m="31860" data-d="320">edit </span>
<span data-m="32170" data-d="240">the </span>
<span data-m="32410" data-d="480">transcript </span>
<span data-m="32900" data-d="160">like </span>
<span data-m="33050" data-d="160">you </span>
<span data-m="33220" data-d="160">would </span>
<span data-m="33380" data-d="160">any </span>
<span data-m="33530" data-d="320">other </span>
<span data-m="33850" data-d="240">text </span>
<span data-m="34250" data-d="240">and </span>
<span data-m="34490" data-d="240">we'll </span>
<span data-m="34730" data-d="240">look </span>
<span data-m="34970" data-d="320">after </span>
<span data-m="35290" data-d="240">the </span>
<span data-m="35530" data-d="500">timings. </span>
</p>
<p>
<span data-m="36890" data-d="240">When </span>
<span data-m="37130" data-d="320">happy </span>
<span data-m="37450" data-d="240">with </span>
<span data-m="37690" data-d="240">your </span>
<span data-m="37930" data-d="480">transcript, </span>
<span data-m="38410" data-d="160">you </span>
<span data-m="38570" data-d="160">can </span>
<span data-m="38730" data-d="400">convert </span>
<span data-m="39130" data-d="160">it </span>
<span data-m="39290" data-d="160">to </span>
<span data-m="39450" data-d="480">captions </span>
<span data-m="39930" data-d="160">and </span>
<span data-m="40090" data-d="400">tweak </span>
<span data-m="40490" data-d="240">those </span>
<span data-m="40730" data-d="400">captions </span>
<span data-m="41130" data-d="320">within </span>
<span data-m="41450" data-d="160">the </span>
<span data-m="41610" data-d="500">editor. </span>
</p>
<p>
<span data-m="43090" data-d="500">Finally, </span>
<span data-m="43730" data-d="240">you </span>
<span data-m="43960" data-d="240">should </span>
<span data-m="44200" data-d="160">be </span>
<span data-m="44360" data-d="240">ready </span>
<span data-m="44600" data-d="160">to </span>
<span data-m="44770" data-d="400">export </span>
<span data-m="45160" data-d="240">your </span>
<span data-m="45410" data-d="480">transcript </span>
<span data-m="45880" data-d="160">in </span>
<span data-m="46050" data-d="160">a </span>
<span data-m="46200" data-d="320">number </span>
<span data-m="46520" data-d="80">of </span>
<span data-m="46600" data-d="480">formats </span>
<span data-m="47090" data-d="160">that </span>
<span data-m="47240" data-d="80">you </span>
<span data-m="47320" data-d="240">can </span>
<span data-m="47560" data-d="500">associate </span>
<span data-m="48120" data-d="160">with </span>
<span data-m="48280" data-d="240">your </span>
<span data-m="48520" data-d="320">audio</span>
<span data-m="48840" data-d="400">visual </span>
<span data-m="49240" data-d="500">media. </span>
</p>
<p>
<span data-m="50540" data-d="400">Use </span>
<span data-m="50940" data-d="400">formats </span>
<span data-m="51340" data-d="160">like </span>
<span data-m="51500" data-d="500">interactive </span>
<span data-m="52140" data-d="500">transcripts </span>
<span data-m="52780" data-d="160">with </span>
<span data-m="52940" data-d="240">the </span>
<span data-m="53180" data-d="560">Hyperaudio </span>
<span data-m="53740" data-d="320">Lite </span>
<span data-m="54060" data-d="400">Library </span>
<span data-m="54460" data-d="240">or </span>
<span data-m="54700" data-d="480">WordPress </span>
<span data-m="55180" data-d="480">module </span>
<span data-m="55660" data-d="160">to </span>
<span data-m="55820" data-d="480">integrate </span>
<span data-m="56300" data-d="320">into </span>
<span data-m="56620" data-d="240">your </span>
<span data-m="56860" data-d="500">website. </span>
</p>
</section>
</article>
</div>
</div>
<div id="captionsource-alert" class="alert alert-info shadow-lg" style="visibility:hidden; z-index:2; position:absolute; top:50%; left:50%; width:480px; height:140px; margin: -240px 0 0 -240px;">
<div>
<div style="margin-top:-60px; width:400px">
<h3 class="font-bold">Captions have been edited.</h3>
<div class="text-xs">These captions may differ from the transcript. You can re-generate captions from the transcript in the Caption Editor.</div>
</div>
</div>
<div class="modal-action" style="margin-top:80px; margin-left:-120px">
<button id="captionsource-alert-cancel" class="btn btn-sm btn-secondary">don't tell me again</button>
<button id="captionsource-alert-ok" class="btn btn-sm btn-primary">ok</button>
</div>
</div>
</div>
<input type="checkbox" id="transcribe-modal" class="modal-toggle" />
<div class="modal">
<div class="modal-box">
<label id="close-modal" for="transcribe-modal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<h3 class="font-bold text-lg" style="margin-bottom:16px">Transcribe</h3>
<div role="tablist" class="tabs tabs-lifted">
<input type="radio" name="my_tabs_2" role="tab" class="tab" style="width:160px" aria-label="Whisper (Local) *" checked />
<div role="tabpanel" class="tab-content bg-base-100 border-base-300 rounded-box p-10">
<client-whisper-service templateSelector="#whisper-client-template"></client-whisper-service>
</div>
<input type="radio" name="my_tabs_2" role="tab" class="tab" style="width:160px" aria-label="Deepgram (Cloud)" />
<div role="tabpanel" class="tab-content bg-base-100 border-base-300 rounded-box p-10">
<deepgram-service templateSelector="#deepgram-modal-template"></deepgram-service>
</div>
</div>
</div>
</div>
<script src="js/hyperaudio-push-notification.js"></script>
<script src="js/hyperaudio-lite.js"></script>
<script src="js/hyperaudio-lite-extension.js"></script>
<script src="js/caption.js"></script>
<script>
let updateCaptionsFromTranscript = true;
let alertOkBtn = document.querySelector('#captionsource-alert-ok');
alertOkBtn.addEventListener('click', function() {
document.querySelector('#captionsource-alert').style.visibility = "hidden";
});
let alertCancelBtn = document.querySelector('#captionsource-alert-cancel');
alertCancelBtn.addEventListener('click', function() {
document.querySelector('#captionsource-alert').style.visibility = "hidden";
localStorage.setItem("noCaptionAlert", "true");
});
let editableDiv = document.querySelector('#hypertranscript');
editableDiv.addEventListener("paste", function(e) {
e.preventDefault();
var text = e.clipboardData.getData("text/plain");
text.replaceAll(" ", " ");
document.execCommand("insertHTML", false, text);
});
window.document.addEventListener('hyperaudioInit', hyperaudio, false);
window.document.addEventListener('hyperaudioGenerateCaptionsFromTranscript', hyperaudioGenerateCaptionsFromTranscript, false);
window.document.addEventListener('hyperaudioTranscriptLoaded', updateInteractiveTranscriptDownloadLink, false);
let hyperaudioTemplate = "";
fetch('hyperaudio-template.html')
.then(function(response) {
// When the page is loaded convert it to text
return response.text()
})
.then(function(html) {
hyperaudioTemplate = html;
})
.catch(function(err) {
console.log('Failed to fetch page: ', err);
});
function hyperaudio() {
const minimizedMode = false;
const autoScroll = false;
const doubleClick = true;
const webMonetization = false;
const playOnClick = false;
const hyperaudioInstance = new HyperaudioLite("hypertranscript", "hyperplayer", minimizedMode, autoScroll, doubleClick, webMonetization, playOnClick);
window.hyperaudioInstance = hyperaudioInstance;
const sanitisationCheck = function () {
let time = 0;
resetTimer();
window.onload = resetTimer;
document.onkeyup = resetTimer;
document.ontouchend = resetTimer;
let rootnode = document.querySelector("#hypertranscript");
let sourceMedia = document.querySelector("#hyperplayer").src;
let track = document.querySelector('#hyperplayer-vtt');
function sanitise() {
let d = new Date();
let starttime = d.getTime();
// check that transcript has the focus
// check for focus
let isTranscriptFocused = false;
let isCaptionEditorFocused = false;
if (document.activeElement === rootnode) {
isTranscriptFocused = true;
}
let walker = document.createTreeWalker(rootnode, NodeFilter.SHOW_TEXT, null, false);
while (walker.nextNode()) {
if (walker.currentNode.textContent.replaceAll('\n', '').trim().length > 0
&& walker.currentNode.parentElement.tagName !== "SPAN") {
// if previousSibling is a span, add the textContent of currentNode to it
if (walker.currentNode.previousSibling.tagName === "SPAN") {
walker.currentNode.previousSibling.textContent += walker.currentNode.textContent;
} else {
// assume nextSibling is a span for now and add textContent of currentNode to that
walker.currentNode.nextSibling.textContent += walker.currentNode.textContent;
}
// remove currentNode as we've merged its contents
//walker.currentNode.parentNode.removeChild(walker.currentNode);
walker.currentNode.textContent = "";
}
}
// look for speakers and break them out into their own spans
walker = document.createTreeWalker(rootnode, NodeFilter.SHOW_TEXT, null, false);
while (walker.nextNode()) {
if (walker.currentNode.textContent.replaceAll('\n', '').replaceAll(' ', ' ').trim().length > 0
&& walker.currentNode.parentElement.tagName === "SPAN" && walker.currentNode.textContent.includes('[') && walker.currentNode.textContent.includes(']')) {
// if previousSibling is a span, add the textContent of currentNode to it
if (walker.currentNode.textContent.trim().startsWith('[') === false || walker.currentNode.textContent.trim().endsWith(']') === false) {
//look for text in square brackets
const regex = / *\[[^\]]*]/g;
const found = walker.currentNode.textContent.match(regex);
let startsWithSpeaker = false;
if (walker.currentNode.textContent.trim().startsWith('[') === true){
startsWithSpeaker = true;
}
walker.currentNode.textContent = walker.currentNode.textContent.replace(regex, '');
let span = document.createElement("span");
span.textContent = found + ' ';
if (span.textContent.includes('[') && span.textContent.includes(']')) {
span.classList.add("speaker");
closedSpeaker = false;
}
// add the classes of the current node
span.classList.add(...walker.currentNode.parentNode.classList);
//DOMTokenList.prototype.add.apply(span.classList, walker.currentNode.parentNode.classList);
span.setAttribute("data-d","0");
if (startsWithSpeaker === true) {
span.setAttribute("data-m",walker.currentNode.parentNode.getAttribute("data-m"));
walker.currentNode.parentNode.before(span);
} else {
let nextStart = walker.currentNode.parentNode.nextElementSibling.getAttribute("data-m");
span.setAttribute("data-m",nextStart);
let newSpan = document.createElement("span");
newSpan.setAttribute("data-m",nextStart);
newSpan.innerHTML = " ";
walker.currentNode.parentNode.after(span);
span.after(newSpan);
// set the cursor
const range = document.createRange();
const sel = window.getSelection();
range.setStartBefore(newSpan.nextElementSibling);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
}
}
}
let hypertranscript = rootnode.innerHTML.replace(/ class=".*?"/g, '');
document.querySelector('#download-html').setAttribute('href', 'data:text/html,'+encodeURIComponent(hypertranscript));
updateInteractiveTranscriptDownloadLink();
if (isTranscriptFocused === true && updateCaptionsFromTranscript === true) {
const words = document.querySelectorAll("[data-m]");
hyperaudioInstance.wordArr = hyperaudioInstance.createWordArray(words);
hyperaudioInstance.parentElements = hyperaudioInstance.transcript.getElementsByTagName(hyperaudioInstance.parentTag);
if (hyperaudioInstance.currentTime !== undefined) {
hyperaudioInstance.updateTranscriptVisualState(hyperaudioInstance.currentTime);
}
/*let hypertranscript = rootnode.innerHTML.replace(/ class=".*?"/g, '');
document.querySelector('#download-html').setAttribute('href', 'data:text/html,'+encodeURIComponent(hypertranscript));*/
generateCaptionsFromTranscript(hypertranscript, sourceMedia, track);
const cap2 = caption();
let subs = cap2.init("hypertranscript", "hyperplayer", '37' , '21'); // transcript Id, player Id, max chars, min chars for caption line
populateCaptionEditor(subs.data);
}
if (isCaptionEditorFocused === true && updateCaptionsFromTranscript === false) {
generateCaptionsFromCaptionEditor();
}
d = new Date();
//console.log("sanitising took "+(d.getTime() - starttime)+"ms");
}
function resetTimer() {
//console.log("reset sanitisation timer");
clearTimeout(time);
time = setTimeout(sanitise, 1000);
}
//longpress to set playhead on mobile
function longPress(element, callback) {
let pressTimer;
element.addEventListener("touchstart", function(e) {
pressTimer = setTimeout(function() {
callback(e);
}, 2000);
});
element.addEventListener("touchend", function(e) {
clearTimeout(pressTimer);
});
}
longPress(rootnode, function(e) {
const startTime = e.target.getAttribute('data-m');
if (startTime !== null) {
e.target.classList.add("active");
hyperaudioInstance.myPlayer.setTime(startTime/1000);
hyperaudioInstance.setPlayHead(e);
hyperaudioInstance.checkPlayHead();
}
});
};
sanitisationCheck();
const videoElement = document.querySelector("#hyperplayer");
let sidebarOpen = true;
document.querySelector('#sidebar-toggle').addEventListener('click', (e) => {
if (sidebarOpen === true) {
document.querySelector('.holder').style.left = 0;
document.querySelector('.main-panel').style.left = 0;
document.querySelector('.transcript-holder').style.left = 0;
document.querySelector('#sidebar-close-icon').style.display = "none";
document.querySelector('#sidebar-open-icon').style.display = "block";
sidebarOpen = false;
} else {
document.querySelector('.holder').style.left = "400px";
document.querySelector('.main-panel').style.left = "400px";
document.querySelector('.transcript-holder').style.left = "400px";
document.querySelector('#sidebar-close-icon').style.display = "block";
document.querySelector('#sidebar-open-icon').style.display = "none";
sidebarOpen = true;
}
if(
document.pictureInPictureEnabled &&
!videoElement.disablePictureInPicture) {
try {
if (sidebarOpen === false) {
videoElement.requestPictureInPicture();
} else {
document.exitPictureInPicture();
}
} catch(err) {
console.error(err);
}
}
});
let showSpeakers = document.querySelector('#show-speakers');
showSpeakers.addEventListener('change', function(e) {
let speakers = document.querySelectorAll('.speaker');
if (showSpeakers.checked === true) {
speakers.forEach((speaker) => {
//speaker.style.display = "inline";
speaker.removeAttribute("style");
});
} else {
speakers.forEach((speaker) => {
speaker.style.display = "none";
});
}
});
}
if (window.matchMedia("(max-width: 480px)").matches === true){
let elem = document.querySelector("#hyperplayer");
// Create a copy of it
let clone = elem.cloneNode(true);
clone.style.width = "100%";
clone.style.paddingTop = "72px";
// Inject it into the DOM
document.querySelector('.transcript-holder').prepend(clone);
elem.remove();
}
hyperaudio();
function hyperaudioGenerateCaptionsFromTranscript() {
let rootnode = document.querySelector("#hypertranscript");
let sourceMedia = document.querySelector("#hyperplayer").src;
let track = document.querySelector('#hyperplayer-vtt');
let hypertranscript = rootnode.innerHTML.replace(/ class=".*?"/g, '');
populateCaptionEditor(generateCaptionsFromTranscript(hypertranscript, sourceMedia, track));
}
function generateCaptionsFromTranscript(hypertranscript, sourceMedia, track) {
const cap1 = caption();
let subs = cap1.init("hypertranscript", "hyperplayer", '37' , '21'); // transcript Id, player Id, max chars, min chars for caption line
document.querySelector('#download-vtt').setAttribute('href', 'data:text/vtt,'+encodeURIComponent(subs.vtt));
document.querySelector('#download-srt').setAttribute('href', 'data:text/srt,'+encodeURIComponent(subs.srt));
track.kind = "captions";
//track.label = "English";
//track.srclang = "en";
track.src = "data:text/vtt,"+encodeURIComponent(subs.vtt);
document
.querySelector("#download-hypertranscript")
.setAttribute(
"href",
"data:text/html," +
encodeURIComponent(
hyperaudioTemplate
.replace("{hypertranscript}", hypertranscript)
.replace("{sourcemedia}", sourceMedia)
.replace("{sourcevtt}", track.src)
)
);
// check to see if it's an mp3, in which case we don't display captions
if (document.querySelector('#hyperplayer').src.split('.').pop() === "mp3") {
document.querySelector('#hyperplayer').textTracks[0].mode = "hidden";
} else {
document.querySelector('#hyperplayer').textTracks[0].mode = "showing";
}
return subs.data;
}
function updateInteractiveTranscriptDownloadLink() {
let isAudio = document.querySelector('#hyperplayer').src.split('.').pop() === "mp3";
document
.querySelector("#download-hypertranscript")
.setAttribute(
"href",
"data:text/html," +
encodeURIComponent(
hyperaudioTemplate
.replace("{hypertranscript}", document.querySelector("#hypertranscript").innerHTML.replace(/ class=".*?"/g, ''))
// check to see if it's an mp3, in which case we don't display captions
.replace("{sourcemedia}", document.querySelector("#hyperplayer").src)
.replace("{sourcevtt}", isAudio ? "" : document.querySelector("#hyperplayer-vtt").src)
)
);
}
function hasParent(element, parent) {
let currentElement = element.parentNode;
while (currentElement !== null) {
if (currentElement === parent) {
return true;
}
currentElement = currentElement.parentNode;
}
return false;
}
</script>
<import-deepgram-json></import-deepgram-json>
<!-- comment out if localstorage not required -->
<div class="hidden-label-holder">
<label for="file-save-dialog">Open Save to Local Storage Dialog</label>
</div>
<input type="checkbox" id="file-save-dialog" class="modal-toggle" />
<div class="modal">
<div class="modal-box">
<div class="flex flex-col gap-4 w-full">
<label id="close-modal" for="file-save-dialog" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<h3 class="font-bold text-lg">Save to Local Storage</h3>
<input type="text" id="save-localstorage-filename" name="save-localstorage-filename" placeholder="File name" class="input input-bordered w-full max-w-xs" />
</div>
<div class="modal-action">
<label for="file-save-dialog" class="btn btn-ghost">Cancel</label>
<label id="file-save-localstorage" for="file-save-dialog" class="btn btn-primary">Confirm</label>
</div>
</div>
</div>
<div class="hidden-label-holder">
<label for="file-load-dialog">Open Load from Local Storage Dialog</label>
</div>
<input type="checkbox" id="file-load-dialog" class="modal-toggle" />
<div class="modal">
<div class="modal-box">
<div class="flex flex-col gap-4 w-full">
<label id="close-modal" for="file-load-dialog" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<h3 class="font-bold text-lg">Load from Local Storage</h3>
<select id="load-localstorage-filename" class="select select-bordered w-full max-w-xs">
</select>
</div>
<div class="modal-action">
<label for="file-load-dialog" class="btn btn-ghost">Cancel</label>
<label id="file-load-localstorage" for="file-load-dialog" class="btn btn-primary">Confirm</label>
</div>
</div>
</div>
<script src="./js/hyperaudio-lite-editor-storage.js"></script>
<script>
document.querySelector('#file-dropdown').insertAdjacentHTML("beforeend", '<hr class="my-2 h-0 border border-t-0 border-solid border-neutral-700 opacity-25 dark:border-neutral-200" /><li class="menu-title"><span>Local Storage</span></li><li><label for="file-save-dialog">Save to Local Storage</label></li><li><label for="file-load-dialog">Load from Local Storage</label></li>');
document.querySelector('#save-localstorage-filename').value = getLocalStorageSaveFilename(document.querySelector("#hyperplayer").src);
loadLocalStorageOptions();
document
.querySelector("#file-save-localstorage")
.addEventListener("click", function () {
let filename = document.querySelector('#save-localstorage-filename').value;
saveHyperTranscriptToLocalStorage(filename);
loadLocalStorageOptions();
});
document
.querySelector("#file-load-localstorage")
.addEventListener("click", function () {
let filenameIndex = document.querySelector('#load-localstorage-filename').value;
loadHyperTranscriptFromLocalStorage(filenameIndex);
});
setFileSelectListeners();
</script>
<script src="./js/hyperaudio-lite-editor-export.js" type="module"> </script>
<!-- end of localstorage additions -->
<!-- caption editor additions -->
<style>
input.line1 {
width: 36ch;
}
input.line2 {
width: 36ch;