@patterkit/model 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -25,20 +25,22 @@ __export(index_exports, {
25
25
  DEFAULT_CAPTION_CHARACTER: () => DEFAULT_CAPTION_CHARACTER,
26
26
  DEFAULT_CAPTION_DELIMITERS: () => DEFAULT_CAPTION_DELIMITERS,
27
27
  DEFAULT_DOCUMENTATION_CLASSES: () => DEFAULT_DOCUMENTATION_CLASSES,
28
- DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND: () => DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND,
28
+ DEFAULT_ESTIMATE_SPEED: () => DEFAULT_ESTIMATE_SPEED,
29
29
  DEFAULT_LAYOUT: () => DEFAULT_LAYOUT,
30
30
  DEFAULT_PAD_AFTER: () => DEFAULT_PAD_AFTER,
31
31
  DEFAULT_QUALIFIERS: () => DEFAULT_QUALIFIERS,
32
32
  DEFAULT_RECORDING_STATUSES: () => DEFAULT_RECORDING_STATUSES,
33
33
  DEFAULT_SPEAKER_PATTERN: () => DEFAULT_SPEAKER_PATTERN,
34
34
  DEFAULT_WRITING_STATUSES: () => DEFAULT_WRITING_STATUSES,
35
- ESTIMATE_SYLLABLES_PER_SECOND_MAX: () => ESTIMATE_SYLLABLES_PER_SECOND_MAX,
36
- ESTIMATE_SYLLABLES_PER_SECOND_MIN: () => ESTIMATE_SYLLABLES_PER_SECOND_MIN,
35
+ ESTIMATE_SPEED_MAX: () => ESTIMATE_SPEED_MAX,
36
+ ESTIMATE_SPEED_MIN: () => ESTIMATE_SPEED_MIN,
37
37
  EXTENSIONS_DIR: () => EXTENSIONS_DIR,
38
38
  EXTENSION_SCHEMA: () => EXTENSION_SCHEMA,
39
39
  EXTENSION_SHARD: () => EXTENSION_SHARD,
40
40
  FLOW_SCHEMA: () => FLOW_SCHEMA,
41
41
  HANDOFF_SCHEMA: () => HANDOFF_SCHEMA,
42
+ LINE_CHARS_PER_SECOND: () => LINE_CHARS_PER_SECOND,
43
+ LINE_CHAR_WEIGHTS: () => LINE_CHAR_WEIGHTS,
42
44
  LINE_DURATION_MAX: () => LINE_DURATION_MAX,
43
45
  LINE_DURATION_MIN: () => LINE_DURATION_MIN,
44
46
  MANIFEST_EXTENSION: () => MANIFEST_EXTENSION,
@@ -53,15 +55,10 @@ __export(index_exports, {
53
55
  SAVE_SCHEMA: () => SAVE_SCHEMA,
54
56
  SAVE_VERSION: () => SAVE_VERSION,
55
57
  SPEAKER_PATTERN_KEY: () => SPEAKER_PATTERN_KEY,
56
- SPEECH_DIGIT_WEIGHT: () => SPEECH_DIGIT_WEIGHT,
57
- SPEECH_KANJI_WEIGHT: () => SPEECH_KANJI_WEIGHT,
58
- SPEECH_PAUSE_LONG_WEIGHT: () => SPEECH_PAUSE_LONG_WEIGHT,
59
- SPEECH_PAUSE_SHORT_WEIGHT: () => SPEECH_PAUSE_SHORT_WEIGHT,
60
58
  STRINGS_SCHEMA: () => STRINGS_SCHEMA,
61
59
  SUBTITLE_READING_MIN: () => SUBTITLE_READING_MIN,
62
60
  UNRESOLVED_KEY: () => UNRESOLVED_KEY,
63
61
  castStringKey: () => castStringKey,
64
- countSyllables: () => countSyllables,
65
62
  deriveRecordingFolders: () => deriveRecordingFolders,
66
63
  effectiveGameId: () => effectiveGameId,
67
64
  estimateLineDuration: () => estimateLineDuration,
@@ -72,6 +69,7 @@ __export(index_exports, {
72
69
  isDialogueScene: () => isDialogueScene,
73
70
  isValidGameId: () => import_toolkit.isValidGameId,
74
71
  isValidPropertyName: () => import_expr.isValidPropertyName,
72
+ normaliseEstimateSpeed: () => normaliseEstimateSpeed,
75
73
  projectLayout: () => projectLayout,
76
74
  projectQualifiers: () => projectQualifiers,
77
75
  propertyNameify: () => import_expr.propertyNameify,
@@ -81,7 +79,6 @@ __export(index_exports, {
81
79
  sceneFolderLayout: () => sceneFolderLayout,
82
80
  sceneFolderPath: () => sceneFolderPath,
83
81
  speakerLabelKey: () => speakerLabelKey,
84
- speechUnits: () => speechUnits,
85
82
  textIsAction: () => textIsAction,
86
83
  usedQualifiers: () => usedQualifiers,
87
84
  usedSpeakerPairs: () => usedSpeakerPairs,
@@ -89,2078 +86,6 @@ __export(index_exports, {
89
86
  });
90
87
  module.exports = __toCommonJS(index_exports);
91
88
  var import_toolkit = require("@wildwinter/toolkit");
92
-
93
- // src/speech-table.ts
94
- var SpeechClass = {
95
- NONE: 0,
96
- LATIN_VOWEL: 1,
97
- LATIN_LETTER: 2,
98
- CYRILLIC_VOWEL: 3,
99
- CYRILLIC_LETTER: 4,
100
- HAN: 5,
101
- KANA: 6,
102
- KANA_SMALL: 7,
103
- KANA_SOKUON: 8,
104
- KANA_LONG: 9,
105
- HANGUL: 10,
106
- ARABIC_LETTER: 11,
107
- ARABIC_VOWEL: 12,
108
- THAI_CONSONANT: 13,
109
- THAI_LEAD: 14,
110
- THAI_VOWEL: 15,
111
- MARK: 16,
112
- OTHER_LETTER: 17,
113
- DIGIT: 18,
114
- PAUSE_SHORT: 19,
115
- PAUSE_LONG: 20,
116
- JOINER: 21,
117
- SPACE: 22
118
- };
119
- var SPEECH_RANGES = [
120
- 9,
121
- 13,
122
- 22,
123
- 32,
124
- 32,
125
- 22,
126
- 33,
127
- 33,
128
- 20,
129
- 39,
130
- 39,
131
- 21,
132
- 44,
133
- 44,
134
- 19,
135
- 46,
136
- 46,
137
- 20,
138
- 48,
139
- 57,
140
- 18,
141
- 58,
142
- 59,
143
- 19,
144
- 63,
145
- 63,
146
- 20,
147
- 65,
148
- 65,
149
- 1,
150
- 66,
151
- 68,
152
- 2,
153
- 69,
154
- 69,
155
- 1,
156
- 70,
157
- 72,
158
- 2,
159
- 73,
160
- 73,
161
- 1,
162
- 74,
163
- 78,
164
- 2,
165
- 79,
166
- 79,
167
- 1,
168
- 80,
169
- 84,
170
- 2,
171
- 85,
172
- 85,
173
- 1,
174
- 86,
175
- 88,
176
- 2,
177
- 89,
178
- 89,
179
- 1,
180
- 90,
181
- 90,
182
- 2,
183
- 97,
184
- 97,
185
- 1,
186
- 98,
187
- 100,
188
- 2,
189
- 101,
190
- 101,
191
- 1,
192
- 102,
193
- 104,
194
- 2,
195
- 105,
196
- 105,
197
- 1,
198
- 106,
199
- 110,
200
- 2,
201
- 111,
202
- 111,
203
- 1,
204
- 112,
205
- 116,
206
- 2,
207
- 117,
208
- 117,
209
- 1,
210
- 118,
211
- 120,
212
- 2,
213
- 121,
214
- 121,
215
- 1,
216
- 122,
217
- 122,
218
- 2,
219
- 133,
220
- 133,
221
- 22,
222
- 160,
223
- 160,
224
- 22,
225
- 170,
226
- 170,
227
- 2,
228
- 173,
229
- 173,
230
- 21,
231
- 181,
232
- 181,
233
- 17,
234
- 186,
235
- 186,
236
- 2,
237
- 192,
238
- 198,
239
- 1,
240
- 199,
241
- 199,
242
- 2,
243
- 200,
244
- 207,
245
- 1,
246
- 208,
247
- 209,
248
- 2,
249
- 210,
250
- 214,
251
- 1,
252
- 216,
253
- 221,
254
- 1,
255
- 222,
256
- 223,
257
- 2,
258
- 224,
259
- 230,
260
- 1,
261
- 231,
262
- 231,
263
- 2,
264
- 232,
265
- 239,
266
- 1,
267
- 240,
268
- 241,
269
- 2,
270
- 242,
271
- 246,
272
- 1,
273
- 248,
274
- 253,
275
- 1,
276
- 254,
277
- 254,
278
- 2,
279
- 255,
280
- 261,
281
- 1,
282
- 262,
283
- 273,
284
- 2,
285
- 274,
286
- 283,
287
- 1,
288
- 284,
289
- 295,
290
- 2,
291
- 296,
292
- 305,
293
- 1,
294
- 306,
295
- 331,
296
- 2,
297
- 332,
298
- 339,
299
- 1,
300
- 340,
301
- 359,
302
- 2,
303
- 360,
304
- 371,
305
- 1,
306
- 372,
307
- 373,
308
- 2,
309
- 374,
310
- 376,
311
- 1,
312
- 377,
313
- 415,
314
- 2,
315
- 416,
316
- 417,
317
- 1,
318
- 418,
319
- 430,
320
- 2,
321
- 431,
322
- 432,
323
- 1,
324
- 433,
325
- 460,
326
- 2,
327
- 461,
328
- 476,
329
- 1,
330
- 477,
331
- 477,
332
- 2,
333
- 478,
334
- 483,
335
- 1,
336
- 484,
337
- 489,
338
- 2,
339
- 490,
340
- 493,
341
- 1,
342
- 494,
343
- 505,
344
- 2,
345
- 506,
346
- 527,
347
- 1,
348
- 528,
349
- 531,
350
- 2,
351
- 532,
352
- 535,
353
- 1,
354
- 536,
355
- 549,
356
- 2,
357
- 550,
358
- 563,
359
- 1,
360
- 564,
361
- 696,
362
- 2,
363
- 697,
364
- 699,
365
- 17,
366
- 700,
367
- 700,
368
- 21,
369
- 701,
370
- 705,
371
- 17,
372
- 710,
373
- 721,
374
- 17,
375
- 736,
376
- 740,
377
- 2,
378
- 748,
379
- 748,
380
- 17,
381
- 750,
382
- 750,
383
- 17,
384
- 768,
385
- 879,
386
- 16,
387
- 880,
388
- 884,
389
- 17,
390
- 886,
391
- 893,
392
- 17,
393
- 895,
394
- 895,
395
- 17,
396
- 902,
397
- 902,
398
- 17,
399
- 904,
400
- 1013,
401
- 17,
402
- 1015,
403
- 1023,
404
- 17,
405
- 1024,
406
- 1025,
407
- 3,
408
- 1026,
409
- 1027,
410
- 4,
411
- 1028,
412
- 1028,
413
- 3,
414
- 1029,
415
- 1029,
416
- 4,
417
- 1030,
418
- 1031,
419
- 3,
420
- 1032,
421
- 1036,
422
- 4,
423
- 1037,
424
- 1038,
425
- 3,
426
- 1039,
427
- 1039,
428
- 4,
429
- 1040,
430
- 1040,
431
- 3,
432
- 1041,
433
- 1044,
434
- 4,
435
- 1045,
436
- 1045,
437
- 3,
438
- 1046,
439
- 1047,
440
- 4,
441
- 1048,
442
- 1048,
443
- 3,
444
- 1049,
445
- 1053,
446
- 4,
447
- 1054,
448
- 1054,
449
- 3,
450
- 1055,
451
- 1058,
452
- 4,
453
- 1059,
454
- 1059,
455
- 3,
456
- 1060,
457
- 1066,
458
- 4,
459
- 1067,
460
- 1067,
461
- 3,
462
- 1068,
463
- 1068,
464
- 4,
465
- 1069,
466
- 1072,
467
- 3,
468
- 1073,
469
- 1076,
470
- 4,
471
- 1077,
472
- 1077,
473
- 3,
474
- 1078,
475
- 1079,
476
- 4,
477
- 1080,
478
- 1080,
479
- 3,
480
- 1081,
481
- 1085,
482
- 4,
483
- 1086,
484
- 1086,
485
- 3,
486
- 1087,
487
- 1090,
488
- 4,
489
- 1091,
490
- 1091,
491
- 3,
492
- 1092,
493
- 1098,
494
- 4,
495
- 1099,
496
- 1099,
497
- 3,
498
- 1100,
499
- 1100,
500
- 4,
501
- 1101,
502
- 1105,
503
- 3,
504
- 1106,
505
- 1107,
506
- 4,
507
- 1108,
508
- 1108,
509
- 3,
510
- 1109,
511
- 1109,
512
- 4,
513
- 1110,
514
- 1111,
515
- 3,
516
- 1112,
517
- 1116,
518
- 4,
519
- 1117,
520
- 1118,
521
- 3,
522
- 1119,
523
- 1153,
524
- 4,
525
- 1155,
526
- 1161,
527
- 16,
528
- 1162,
529
- 1231,
530
- 4,
531
- 1232,
532
- 1235,
533
- 3,
534
- 1236,
535
- 1237,
536
- 4,
537
- 1238,
538
- 1239,
539
- 3,
540
- 1240,
541
- 1249,
542
- 4,
543
- 1250,
544
- 1255,
545
- 3,
546
- 1256,
547
- 1259,
548
- 4,
549
- 1260,
550
- 1267,
551
- 3,
552
- 1268,
553
- 1271,
554
- 4,
555
- 1272,
556
- 1273,
557
- 3,
558
- 1274,
559
- 1327,
560
- 4,
561
- 1329,
562
- 1369,
563
- 17,
564
- 1376,
565
- 1416,
566
- 17,
567
- 1425,
568
- 1469,
569
- 17,
570
- 1471,
571
- 1471,
572
- 17,
573
- 1473,
574
- 1474,
575
- 17,
576
- 1476,
577
- 1477,
578
- 17,
579
- 1479,
580
- 1522,
581
- 17,
582
- 1548,
583
- 1548,
584
- 19,
585
- 1552,
586
- 1562,
587
- 16,
588
- 1563,
589
- 1563,
590
- 19,
591
- 1567,
592
- 1567,
593
- 20,
594
- 1568,
595
- 1599,
596
- 11,
597
- 1600,
598
- 1600,
599
- 16,
600
- 1601,
601
- 1610,
602
- 11,
603
- 1611,
604
- 1616,
605
- 12,
606
- 1617,
607
- 1631,
608
- 16,
609
- 1632,
610
- 1641,
611
- 18,
612
- 1646,
613
- 1647,
614
- 11,
615
- 1648,
616
- 1648,
617
- 12,
618
- 1649,
619
- 1747,
620
- 11,
621
- 1748,
622
- 1748,
623
- 20,
624
- 1749,
625
- 1749,
626
- 11,
627
- 1750,
628
- 1756,
629
- 16,
630
- 1759,
631
- 1764,
632
- 16,
633
- 1765,
634
- 1766,
635
- 11,
636
- 1767,
637
- 1768,
638
- 16,
639
- 1770,
640
- 1773,
641
- 16,
642
- 1774,
643
- 1775,
644
- 11,
645
- 1776,
646
- 1785,
647
- 18,
648
- 1786,
649
- 1788,
650
- 11,
651
- 1791,
652
- 1791,
653
- 11,
654
- 1808,
655
- 1871,
656
- 17,
657
- 1872,
658
- 1919,
659
- 11,
660
- 1920,
661
- 2037,
662
- 17,
663
- 2042,
664
- 2045,
665
- 17,
666
- 2048,
667
- 2093,
668
- 17,
669
- 2112,
670
- 2139,
671
- 17,
672
- 2144,
673
- 2154,
674
- 17,
675
- 2160,
676
- 2183,
677
- 11,
678
- 2185,
679
- 2191,
680
- 11,
681
- 2199,
682
- 2207,
683
- 16,
684
- 2208,
685
- 2249,
686
- 11,
687
- 2250,
688
- 2273,
689
- 16,
690
- 2275,
691
- 2303,
692
- 16,
693
- 2304,
694
- 2384,
695
- 17,
696
- 2385,
697
- 2388,
698
- 16,
699
- 2389,
700
- 2403,
701
- 17,
702
- 2404,
703
- 2405,
704
- 20,
705
- 2406,
706
- 2415,
707
- 17,
708
- 2417,
709
- 2545,
710
- 17,
711
- 2556,
712
- 2556,
713
- 17,
714
- 2558,
715
- 2677,
716
- 17,
717
- 2689,
718
- 2799,
719
- 17,
720
- 2809,
721
- 2927,
722
- 17,
723
- 2929,
724
- 2929,
725
- 17,
726
- 2946,
727
- 3055,
728
- 17,
729
- 3072,
730
- 3183,
731
- 17,
732
- 3200,
733
- 3203,
734
- 17,
735
- 3205,
736
- 3406,
737
- 17,
738
- 3412,
739
- 3415,
740
- 17,
741
- 3423,
742
- 3439,
743
- 17,
744
- 3450,
745
- 3571,
746
- 17,
747
- 3585,
748
- 3630,
749
- 13,
750
- 3631,
751
- 3631,
752
- 16,
753
- 3632,
754
- 3641,
755
- 15,
756
- 3642,
757
- 3642,
758
- 16,
759
- 3648,
760
- 3652,
761
- 14,
762
- 3653,
763
- 3654,
764
- 16,
765
- 3655,
766
- 3655,
767
- 15,
768
- 3656,
769
- 3660,
770
- 16,
771
- 3661,
772
- 3661,
773
- 15,
774
- 3662,
775
- 3662,
776
- 16,
777
- 3664,
778
- 3673,
779
- 18,
780
- 3713,
781
- 3840,
782
- 17,
783
- 3864,
784
- 3865,
785
- 17,
786
- 3872,
787
- 3881,
788
- 17,
789
- 3893,
790
- 3893,
791
- 17,
792
- 3895,
793
- 3895,
794
- 17,
795
- 3897,
796
- 3897,
797
- 17,
798
- 3902,
799
- 3972,
800
- 17,
801
- 3974,
802
- 4028,
803
- 17,
804
- 4038,
805
- 4038,
806
- 17,
807
- 4096,
808
- 4169,
809
- 17,
810
- 4176,
811
- 4253,
812
- 17,
813
- 4256,
814
- 4346,
815
- 17,
816
- 4348,
817
- 4959,
818
- 17,
819
- 4992,
820
- 5007,
821
- 17,
822
- 5024,
823
- 5117,
824
- 17,
825
- 5121,
826
- 5740,
827
- 17,
828
- 5743,
829
- 5759,
830
- 17,
831
- 5760,
832
- 5760,
833
- 22,
834
- 5761,
835
- 5786,
836
- 17,
837
- 5792,
838
- 5866,
839
- 17,
840
- 5873,
841
- 5940,
842
- 17,
843
- 5952,
844
- 6099,
845
- 17,
846
- 6103,
847
- 6103,
848
- 17,
849
- 6108,
850
- 6121,
851
- 17,
852
- 6155,
853
- 6157,
854
- 17,
855
- 6159,
856
- 6459,
857
- 17,
858
- 6470,
859
- 6617,
860
- 17,
861
- 6656,
862
- 6683,
863
- 17,
864
- 6688,
865
- 6809,
866
- 17,
867
- 6823,
868
- 6823,
869
- 17,
870
- 6832,
871
- 6891,
872
- 16,
873
- 6912,
874
- 6988,
875
- 17,
876
- 6992,
877
- 7001,
878
- 17,
879
- 7019,
880
- 7027,
881
- 17,
882
- 7040,
883
- 7155,
884
- 17,
885
- 7168,
886
- 7223,
887
- 17,
888
- 7232,
889
- 7293,
890
- 17,
891
- 7296,
892
- 7306,
893
- 4,
894
- 7312,
895
- 7359,
896
- 17,
897
- 7376,
898
- 7378,
899
- 16,
900
- 7380,
901
- 7392,
902
- 16,
903
- 7393,
904
- 7393,
905
- 17,
906
- 7394,
907
- 7400,
908
- 16,
909
- 7401,
910
- 7404,
911
- 17,
912
- 7405,
913
- 7405,
914
- 16,
915
- 7406,
916
- 7411,
917
- 17,
918
- 7412,
919
- 7412,
920
- 16,
921
- 7413,
922
- 7415,
923
- 17,
924
- 7416,
925
- 7417,
926
- 16,
927
- 7418,
928
- 7418,
929
- 17,
930
- 7424,
931
- 7461,
932
- 2,
933
- 7462,
934
- 7466,
935
- 17,
936
- 7467,
937
- 7467,
938
- 4,
939
- 7468,
940
- 7516,
941
- 2,
942
- 7517,
943
- 7521,
944
- 17,
945
- 7522,
946
- 7525,
947
- 2,
948
- 7526,
949
- 7530,
950
- 17,
951
- 7531,
952
- 7543,
953
- 2,
954
- 7544,
955
- 7544,
956
- 4,
957
- 7545,
958
- 7614,
959
- 2,
960
- 7615,
961
- 7615,
962
- 17,
963
- 7616,
964
- 7679,
965
- 16,
966
- 7680,
967
- 7681,
968
- 1,
969
- 7682,
970
- 7699,
971
- 2,
972
- 7700,
973
- 7709,
974
- 1,
975
- 7710,
976
- 7723,
977
- 2,
978
- 7724,
979
- 7727,
980
- 1,
981
- 7728,
982
- 7755,
983
- 2,
984
- 7756,
985
- 7763,
986
- 1,
987
- 7764,
988
- 7793,
989
- 2,
990
- 7794,
991
- 7803,
992
- 1,
993
- 7804,
994
- 7821,
995
- 2,
996
- 7822,
997
- 7823,
998
- 1,
999
- 7824,
1000
- 7832,
1001
- 2,
1002
- 7833,
1003
- 7833,
1004
- 1,
1005
- 7834,
1006
- 7839,
1007
- 2,
1008
- 7840,
1009
- 7929,
1010
- 1,
1011
- 7930,
1012
- 7935,
1013
- 2,
1014
- 7936,
1015
- 8124,
1016
- 17,
1017
- 8126,
1018
- 8126,
1019
- 17,
1020
- 8130,
1021
- 8140,
1022
- 17,
1023
- 8144,
1024
- 8155,
1025
- 17,
1026
- 8160,
1027
- 8172,
1028
- 17,
1029
- 8178,
1030
- 8188,
1031
- 17,
1032
- 8192,
1033
- 8202,
1034
- 22,
1035
- 8204,
1036
- 8205,
1037
- 21,
1038
- 8211,
1039
- 8212,
1040
- 19,
1041
- 8217,
1042
- 8217,
1043
- 21,
1044
- 8230,
1045
- 8230,
1046
- 20,
1047
- 8232,
1048
- 8233,
1049
- 22,
1050
- 8239,
1051
- 8239,
1052
- 22,
1053
- 8253,
1054
- 8253,
1055
- 20,
1056
- 8263,
1057
- 8265,
1058
- 20,
1059
- 8287,
1060
- 8287,
1061
- 22,
1062
- 8305,
1063
- 8305,
1064
- 2,
1065
- 8319,
1066
- 8319,
1067
- 2,
1068
- 8336,
1069
- 8348,
1070
- 2,
1071
- 8400,
1072
- 8432,
1073
- 16,
1074
- 8450,
1075
- 8450,
1076
- 17,
1077
- 8455,
1078
- 8455,
1079
- 17,
1080
- 8458,
1081
- 8467,
1082
- 17,
1083
- 8469,
1084
- 8469,
1085
- 17,
1086
- 8473,
1087
- 8477,
1088
- 17,
1089
- 8484,
1090
- 8484,
1091
- 17,
1092
- 8486,
1093
- 8486,
1094
- 17,
1095
- 8488,
1096
- 8488,
1097
- 17,
1098
- 8490,
1099
- 8490,
1100
- 2,
1101
- 8491,
1102
- 8491,
1103
- 1,
1104
- 8492,
1105
- 8493,
1106
- 17,
1107
- 8495,
1108
- 8497,
1109
- 17,
1110
- 8498,
1111
- 8498,
1112
- 2,
1113
- 8499,
1114
- 8505,
1115
- 17,
1116
- 8508,
1117
- 8511,
1118
- 17,
1119
- 8517,
1120
- 8521,
1121
- 17,
1122
- 8526,
1123
- 8526,
1124
- 2,
1125
- 8579,
1126
- 8580,
1127
- 2,
1128
- 11264,
1129
- 11359,
1130
- 17,
1131
- 11360,
1132
- 11391,
1133
- 2,
1134
- 11392,
1135
- 11492,
1136
- 17,
1137
- 11499,
1138
- 11507,
1139
- 17,
1140
- 11520,
1141
- 11631,
1142
- 17,
1143
- 11647,
1144
- 11742,
1145
- 17,
1146
- 11744,
1147
- 11775,
1148
- 16,
1149
- 11823,
1150
- 11823,
1151
- 17,
1152
- 12288,
1153
- 12288,
1154
- 22,
1155
- 12289,
1156
- 12289,
1157
- 19,
1158
- 12290,
1159
- 12290,
1160
- 20,
1161
- 12293,
1162
- 12293,
1163
- 5,
1164
- 12294,
1165
- 12294,
1166
- 17,
1167
- 12330,
1168
- 12335,
1169
- 16,
1170
- 12337,
1171
- 12341,
1172
- 17,
1173
- 12347,
1174
- 12347,
1175
- 5,
1176
- 12348,
1177
- 12348,
1178
- 17,
1179
- 12353,
1180
- 12353,
1181
- 7,
1182
- 12354,
1183
- 12354,
1184
- 6,
1185
- 12355,
1186
- 12355,
1187
- 7,
1188
- 12356,
1189
- 12356,
1190
- 6,
1191
- 12357,
1192
- 12357,
1193
- 7,
1194
- 12358,
1195
- 12358,
1196
- 6,
1197
- 12359,
1198
- 12359,
1199
- 7,
1200
- 12360,
1201
- 12360,
1202
- 6,
1203
- 12361,
1204
- 12361,
1205
- 7,
1206
- 12362,
1207
- 12386,
1208
- 6,
1209
- 12387,
1210
- 12387,
1211
- 8,
1212
- 12388,
1213
- 12418,
1214
- 6,
1215
- 12419,
1216
- 12419,
1217
- 7,
1218
- 12420,
1219
- 12420,
1220
- 6,
1221
- 12421,
1222
- 12421,
1223
- 7,
1224
- 12422,
1225
- 12422,
1226
- 6,
1227
- 12423,
1228
- 12423,
1229
- 7,
1230
- 12424,
1231
- 12429,
1232
- 6,
1233
- 12430,
1234
- 12430,
1235
- 7,
1236
- 12431,
1237
- 12436,
1238
- 6,
1239
- 12437,
1240
- 12438,
1241
- 7,
1242
- 12441,
1243
- 12444,
1244
- 16,
1245
- 12445,
1246
- 12447,
1247
- 6,
1248
- 12449,
1249
- 12449,
1250
- 7,
1251
- 12450,
1252
- 12450,
1253
- 6,
1254
- 12451,
1255
- 12451,
1256
- 7,
1257
- 12452,
1258
- 12452,
1259
- 6,
1260
- 12453,
1261
- 12453,
1262
- 7,
1263
- 12454,
1264
- 12454,
1265
- 6,
1266
- 12455,
1267
- 12455,
1268
- 7,
1269
- 12456,
1270
- 12456,
1271
- 6,
1272
- 12457,
1273
- 12457,
1274
- 7,
1275
- 12458,
1276
- 12482,
1277
- 6,
1278
- 12483,
1279
- 12483,
1280
- 8,
1281
- 12484,
1282
- 12514,
1283
- 6,
1284
- 12515,
1285
- 12515,
1286
- 7,
1287
- 12516,
1288
- 12516,
1289
- 6,
1290
- 12517,
1291
- 12517,
1292
- 7,
1293
- 12518,
1294
- 12518,
1295
- 6,
1296
- 12519,
1297
- 12519,
1298
- 7,
1299
- 12520,
1300
- 12525,
1301
- 6,
1302
- 12526,
1303
- 12526,
1304
- 7,
1305
- 12527,
1306
- 12538,
1307
- 6,
1308
- 12540,
1309
- 12540,
1310
- 9,
1311
- 12541,
1312
- 12543,
1313
- 6,
1314
- 12549,
1315
- 12686,
1316
- 17,
1317
- 12704,
1318
- 12735,
1319
- 17,
1320
- 12784,
1321
- 12799,
1322
- 7,
1323
- 13312,
1324
- 19903,
1325
- 5,
1326
- 19968,
1327
- 40959,
1328
- 5,
1329
- 40960,
1330
- 42124,
1331
- 17,
1332
- 42192,
1333
- 42237,
1334
- 17,
1335
- 42240,
1336
- 42508,
1337
- 17,
1338
- 42512,
1339
- 42539,
1340
- 17,
1341
- 42560,
1342
- 42606,
1343
- 4,
1344
- 42607,
1345
- 42610,
1346
- 16,
1347
- 42612,
1348
- 42621,
1349
- 16,
1350
- 42623,
1351
- 42653,
1352
- 4,
1353
- 42654,
1354
- 42655,
1355
- 16,
1356
- 42656,
1357
- 42725,
1358
- 17,
1359
- 42736,
1360
- 42737,
1361
- 17,
1362
- 42775,
1363
- 42783,
1364
- 17,
1365
- 42786,
1366
- 42887,
1367
- 2,
1368
- 42888,
1369
- 42888,
1370
- 17,
1371
- 42891,
1372
- 43007,
1373
- 2,
1374
- 43008,
1375
- 43047,
1376
- 17,
1377
- 43052,
1378
- 43052,
1379
- 17,
1380
- 43072,
1381
- 43123,
1382
- 17,
1383
- 43136,
1384
- 43205,
1385
- 17,
1386
- 43216,
1387
- 43255,
1388
- 17,
1389
- 43259,
1390
- 43259,
1391
- 17,
1392
- 43261,
1393
- 43309,
1394
- 17,
1395
- 43312,
1396
- 43347,
1397
- 17,
1398
- 43360,
1399
- 43456,
1400
- 17,
1401
- 43471,
1402
- 43481,
1403
- 17,
1404
- 43488,
1405
- 43609,
1406
- 17,
1407
- 43616,
1408
- 43638,
1409
- 17,
1410
- 43642,
1411
- 43741,
1412
- 17,
1413
- 43744,
1414
- 43759,
1415
- 17,
1416
- 43762,
1417
- 43822,
1418
- 17,
1419
- 43824,
1420
- 43866,
1421
- 2,
1422
- 43868,
1423
- 43876,
1424
- 2,
1425
- 43877,
1426
- 43877,
1427
- 17,
1428
- 43878,
1429
- 43881,
1430
- 2,
1431
- 43888,
1432
- 44010,
1433
- 17,
1434
- 44012,
1435
- 44025,
1436
- 17,
1437
- 44032,
1438
- 55203,
1439
- 10,
1440
- 55216,
1441
- 55291,
1442
- 17,
1443
- 63744,
1444
- 64217,
1445
- 5,
1446
- 64256,
1447
- 64262,
1448
- 2,
1449
- 64275,
1450
- 64296,
1451
- 17,
1452
- 64298,
1453
- 64335,
1454
- 17,
1455
- 64336,
1456
- 64433,
1457
- 11,
1458
- 64467,
1459
- 64829,
1460
- 11,
1461
- 64848,
1462
- 64911,
1463
- 11,
1464
- 64914,
1465
- 64967,
1466
- 11,
1467
- 65008,
1468
- 65019,
1469
- 11,
1470
- 65024,
1471
- 65039,
1472
- 16,
1473
- 65056,
1474
- 65071,
1475
- 16,
1476
- 65104,
1477
- 65105,
1478
- 19,
1479
- 65136,
1480
- 65276,
1481
- 11,
1482
- 65281,
1483
- 65281,
1484
- 20,
1485
- 65292,
1486
- 65292,
1487
- 19,
1488
- 65294,
1489
- 65294,
1490
- 20,
1491
- 65296,
1492
- 65305,
1493
- 18,
1494
- 65306,
1495
- 65307,
1496
- 19,
1497
- 65311,
1498
- 65311,
1499
- 20,
1500
- 65313,
1501
- 65338,
1502
- 2,
1503
- 65345,
1504
- 65370,
1505
- 2,
1506
- 65377,
1507
- 65377,
1508
- 20,
1509
- 65380,
1510
- 65380,
1511
- 19,
1512
- 65382,
1513
- 65382,
1514
- 6,
1515
- 65383,
1516
- 65390,
1517
- 7,
1518
- 65391,
1519
- 65391,
1520
- 8,
1521
- 65392,
1522
- 65392,
1523
- 9,
1524
- 65393,
1525
- 65437,
1526
- 6,
1527
- 65438,
1528
- 65439,
1529
- 16,
1530
- 65440,
1531
- 65500,
1532
- 17,
1533
- 65536,
1534
- 65786,
1535
- 17,
1536
- 66045,
1537
- 66045,
1538
- 16,
1539
- 66176,
1540
- 66256,
1541
- 17,
1542
- 66272,
1543
- 66272,
1544
- 16,
1545
- 66304,
1546
- 66335,
1547
- 17,
1548
- 66349,
1549
- 66368,
1550
- 17,
1551
- 66370,
1552
- 66377,
1553
- 17,
1554
- 66384,
1555
- 66461,
1556
- 17,
1557
- 66464,
1558
- 66511,
1559
- 17,
1560
- 66560,
1561
- 66915,
1562
- 17,
1563
- 66928,
1564
- 67431,
1565
- 17,
1566
- 67456,
1567
- 67514,
1568
- 2,
1569
- 67584,
1570
- 67669,
1571
- 17,
1572
- 67680,
1573
- 67702,
1574
- 17,
1575
- 67712,
1576
- 67742,
1577
- 17,
1578
- 67808,
1579
- 67829,
1580
- 17,
1581
- 67840,
1582
- 67861,
1583
- 17,
1584
- 67872,
1585
- 67897,
1586
- 17,
1587
- 67904,
1588
- 68023,
1589
- 17,
1590
- 68030,
1591
- 68031,
1592
- 17,
1593
- 68096,
1594
- 68159,
1595
- 17,
1596
- 68192,
1597
- 68220,
1598
- 17,
1599
- 68224,
1600
- 68252,
1601
- 17,
1602
- 68288,
1603
- 68295,
1604
- 17,
1605
- 68297,
1606
- 68326,
1607
- 17,
1608
- 68352,
1609
- 68405,
1610
- 17,
1611
- 68416,
1612
- 68437,
1613
- 17,
1614
- 68448,
1615
- 68466,
1616
- 17,
1617
- 68480,
1618
- 68497,
1619
- 17,
1620
- 68608,
1621
- 68850,
1622
- 17,
1623
- 68864,
1624
- 68973,
1625
- 17,
1626
- 68975,
1627
- 68997,
1628
- 17,
1629
- 69248,
1630
- 69292,
1631
- 17,
1632
- 69296,
1633
- 69297,
1634
- 17,
1635
- 69314,
1636
- 69319,
1637
- 11,
1638
- 69370,
1639
- 69375,
1640
- 16,
1641
- 69376,
1642
- 69404,
1643
- 17,
1644
- 69415,
1645
- 69456,
1646
- 17,
1647
- 69488,
1648
- 69509,
1649
- 17,
1650
- 69552,
1651
- 69572,
1652
- 17,
1653
- 69600,
1654
- 69702,
1655
- 17,
1656
- 69734,
1657
- 69818,
1658
- 17,
1659
- 69826,
1660
- 69826,
1661
- 17,
1662
- 69840,
1663
- 69951,
1664
- 17,
1665
- 69956,
1666
- 70003,
1667
- 17,
1668
- 70006,
1669
- 70084,
1670
- 17,
1671
- 70089,
1672
- 70092,
1673
- 17,
1674
- 70094,
1675
- 70106,
1676
- 17,
1677
- 70108,
1678
- 70108,
1679
- 17,
1680
- 70144,
1681
- 70199,
1682
- 17,
1683
- 70206,
1684
- 70312,
1685
- 17,
1686
- 70320,
1687
- 70457,
1688
- 17,
1689
- 70459,
1690
- 70459,
1691
- 16,
1692
- 70460,
1693
- 70611,
1694
- 17,
1695
- 70625,
1696
- 70730,
1697
- 17,
1698
- 70736,
1699
- 70745,
1700
- 17,
1701
- 70750,
1702
- 70853,
1703
- 17,
1704
- 70855,
1705
- 71104,
1706
- 17,
1707
- 71128,
1708
- 71232,
1709
- 17,
1710
- 71236,
1711
- 71257,
1712
- 17,
1713
- 71296,
1714
- 71352,
1715
- 17,
1716
- 71360,
1717
- 71481,
1718
- 17,
1719
- 71488,
1720
- 71738,
1721
- 17,
1722
- 71840,
1723
- 71913,
1724
- 17,
1725
- 71935,
1726
- 72003,
1727
- 17,
1728
- 72016,
1729
- 72161,
1730
- 17,
1731
- 72163,
1732
- 72254,
1733
- 17,
1734
- 72263,
1735
- 72345,
1736
- 17,
1737
- 72349,
1738
- 72349,
1739
- 17,
1740
- 72368,
1741
- 72440,
1742
- 17,
1743
- 72544,
1744
- 72672,
1745
- 17,
1746
- 72688,
1747
- 72768,
1748
- 17,
1749
- 72784,
1750
- 72793,
1751
- 17,
1752
- 72818,
1753
- 73462,
1754
- 17,
1755
- 73472,
1756
- 73538,
1757
- 17,
1758
- 73552,
1759
- 73648,
1760
- 17,
1761
- 73728,
1762
- 74649,
1763
- 17,
1764
- 74880,
1765
- 77808,
1766
- 17,
1767
- 77824,
1768
- 78895,
1769
- 17,
1770
- 78912,
1771
- 92777,
1772
- 17,
1773
- 92784,
1774
- 92916,
1775
- 17,
1776
- 92928,
1777
- 92982,
1778
- 17,
1779
- 92992,
1780
- 92995,
1781
- 17,
1782
- 93008,
1783
- 93017,
1784
- 17,
1785
- 93027,
1786
- 93548,
1787
- 17,
1788
- 93552,
1789
- 93823,
1790
- 17,
1791
- 93856,
1792
- 94177,
1793
- 17,
1794
- 94179,
1795
- 94179,
1796
- 5,
1797
- 94180,
1798
- 94180,
1799
- 17,
1800
- 94192,
1801
- 94193,
1802
- 16,
1803
- 94194,
1804
- 94195,
1805
- 5,
1806
- 94208,
1807
- 101874,
1808
- 17,
1809
- 110576,
1810
- 110951,
1811
- 6,
1812
- 110960,
1813
- 113817,
1814
- 17,
1815
- 113821,
1816
- 113822,
1817
- 17,
1818
- 118e3,
1819
- 118009,
1820
- 17,
1821
- 118528,
1822
- 118598,
1823
- 16,
1824
- 119141,
1825
- 119142,
1826
- 17,
1827
- 119143,
1828
- 119145,
1829
- 16,
1830
- 119149,
1831
- 119154,
1832
- 17,
1833
- 119163,
1834
- 119170,
1835
- 16,
1836
- 119173,
1837
- 119179,
1838
- 16,
1839
- 119210,
1840
- 119213,
1841
- 16,
1842
- 119362,
1843
- 119364,
1844
- 17,
1845
- 119808,
1846
- 120512,
1847
- 17,
1848
- 120514,
1849
- 120538,
1850
- 17,
1851
- 120540,
1852
- 120570,
1853
- 17,
1854
- 120572,
1855
- 120596,
1856
- 17,
1857
- 120598,
1858
- 120628,
1859
- 17,
1860
- 120630,
1861
- 120654,
1862
- 17,
1863
- 120656,
1864
- 120686,
1865
- 17,
1866
- 120688,
1867
- 120712,
1868
- 17,
1869
- 120714,
1870
- 120744,
1871
- 17,
1872
- 120746,
1873
- 120770,
1874
- 17,
1875
- 120772,
1876
- 120831,
1877
- 17,
1878
- 121344,
1879
- 121398,
1880
- 17,
1881
- 121403,
1882
- 121452,
1883
- 17,
1884
- 121461,
1885
- 121461,
1886
- 17,
1887
- 121476,
1888
- 121476,
1889
- 17,
1890
- 121499,
1891
- 121519,
1892
- 17,
1893
- 122624,
1894
- 122666,
1895
- 2,
1896
- 122880,
1897
- 122922,
1898
- 17,
1899
- 122928,
1900
- 122989,
1901
- 4,
1902
- 123023,
1903
- 123023,
1904
- 16,
1905
- 123136,
1906
- 123214,
1907
- 17,
1908
- 123536,
1909
- 123641,
1910
- 17,
1911
- 124112,
1912
- 124410,
1913
- 17,
1914
- 124608,
1915
- 125124,
1916
- 17,
1917
- 125136,
1918
- 125273,
1919
- 17,
1920
- 126464,
1921
- 126651,
1922
- 11,
1923
- 130032,
1924
- 130041,
1925
- 17,
1926
- 131072,
1927
- 210041,
1928
- 5,
1929
- 917760,
1930
- 917999,
1931
- 16
1932
- ];
1933
-
1934
- // src/speech.ts
1935
- var SPEECH_DIGIT_WEIGHT = 1.5;
1936
- var SPEECH_KANJI_WEIGHT = 2;
1937
- var SPEECH_PAUSE_SHORT_WEIGHT = 1;
1938
- var SPEECH_PAUSE_LONG_WEIGHT = 2;
1939
- var at = (a, j) => a[j] ?? -1;
1940
- function classOf(cp) {
1941
- let lo = 0, hi = SPEECH_RANGES.length / 3 - 1;
1942
- while (lo <= hi) {
1943
- const mid = lo + hi >> 1;
1944
- if (cp < at(SPEECH_RANGES, mid * 3)) hi = mid - 1;
1945
- else if (cp > at(SPEECH_RANGES, mid * 3 + 1)) lo = mid + 1;
1946
- else return at(SPEECH_RANGES, mid * 3 + 2);
1947
- }
1948
- return SpeechClass.NONE;
1949
- }
1950
- function languageOf(locale) {
1951
- return ((locale ?? "").split(/[-_]/)[0] ?? "").toLowerCase();
1952
- }
1953
- var isAsciiLetter = (cp) => cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122;
1954
- var isAsciiDigit = (cp) => cp >= 48 && cp <= 57;
1955
- function markupEnd(cps, i) {
1956
- const cp = (j) => at(cps, j);
1957
- if (cp(i) === 60) {
1958
- let j = i + 1;
1959
- if (cp(j) === 47) j++;
1960
- const from = j;
1961
- while (isAsciiLetter(cp(j))) j++;
1962
- return j > from && cp(j) === 62 ? j + 1 : i;
1963
- }
1964
- if (cp(i) === 38) {
1965
- let j = i + 1;
1966
- const numeric = cp(j) === 35;
1967
- if (numeric) j++;
1968
- const from = j;
1969
- while (numeric ? isAsciiDigit(cp(j)) : isAsciiLetter(cp(j))) j++;
1970
- return j > from && cp(j) === 59 ? j + 1 : i;
1971
- }
1972
- return i;
1973
- }
1974
- var LATIN = /* @__PURE__ */ new Set([SpeechClass.LATIN_VOWEL, SpeechClass.LATIN_LETTER]);
1975
- var CYRILLIC = /* @__PURE__ */ new Set([SpeechClass.CYRILLIC_VOWEL, SpeechClass.CYRILLIC_LETTER]);
1976
- var ARABIC = /* @__PURE__ */ new Set([SpeechClass.ARABIC_LETTER, SpeechClass.ARABIC_VOWEL]);
1977
- var THAI = /* @__PURE__ */ new Set([SpeechClass.THAI_CONSONANT, SpeechClass.THAI_LEAD, SpeechClass.THAI_VOWEL]);
1978
- var OTHER = /* @__PURE__ */ new Set([SpeechClass.OTHER_LETTER]);
1979
- var KANA_CLASSES = /* @__PURE__ */ new Set([SpeechClass.KANA, SpeechClass.KANA_SMALL, SpeechClass.KANA_SOKUON, SpeechClass.KANA_LONG]);
1980
- function speechUnits(text, locale) {
1981
- const cps = Array.from(text ?? "", (ch) => ch.codePointAt(0));
1982
- const cls = cps.map(classOf);
1983
- const n = cps.length;
1984
- const lang = languageOf(locale);
1985
- const japanese = lang === "ja" || cls.some((k) => KANA_CLASSES.has(k));
1986
- const units = [];
1987
- const syllable = (start, end, weight = 1) => {
1988
- units.push({ kind: "syllable", weight, start, end });
1989
- };
1990
- const classAt = (j) => j >= 0 && j < n ? at(cls, j) : SpeechClass.NONE;
1991
- const marksEnd = (j) => {
1992
- while (j < n && at(cls, j) === SpeechClass.MARK) j++;
1993
- return j;
1994
- };
1995
- const wordEnd = (i2, family) => {
1996
- let j = i2 + 1;
1997
- while (j < n && (family.has(at(cls, j)) || at(cls, j) === SpeechClass.MARK || at(cls, j) === SpeechClass.JOINER && family.has(classAt(j + 1)))) j++;
1998
- return j;
1999
- };
2000
- const fromAnchors = (start, end, anchors) => {
2001
- const sorted = [...new Set(anchors.map((a) => Math.min(marksEnd(a + 1), end) - 1))].sort((a, b) => a - b);
2002
- sorted.forEach((a, j) => syllable(j === 0 ? start : at(sorted, j - 1) + 1, j === sorted.length - 1 ? end : a + 1));
2003
- };
2004
- const spread = (letters, count, step) => Array.from({ length: count }, (_, j) => at(letters, Math.min(step * j + step - 1, letters.length - 1)));
2005
- let i = 0;
2006
- while (i < n) {
2007
- const k = at(cls, i);
2008
- const skip = markupEnd(cps, i);
2009
- if (skip > i) {
2010
- i = skip;
2011
- continue;
2012
- }
2013
- if (LATIN.has(k)) {
2014
- const end = wordEnd(i, LATIN);
2015
- const lasts = [], sizes = [];
2016
- let inGroup = false;
2017
- for (let j = i; j < end; j++) {
2018
- if (at(cls, j) === SpeechClass.LATIN_VOWEL) {
2019
- if (inGroup) {
2020
- lasts[lasts.length - 1] = j;
2021
- sizes[sizes.length - 1] = at(sizes, sizes.length - 1) + 1;
2022
- } else {
2023
- lasts.push(j);
2024
- sizes.push(1);
2025
- }
2026
- inGroup = true;
2027
- } else if (at(cls, j) !== SpeechClass.MARK) inGroup = false;
2028
- }
2029
- if (lasts.length >= 2 && at(sizes, sizes.length - 1) === 1 && silentE(cps, cls, i, end, at(lasts, lasts.length - 1), lang)) lasts.pop();
2030
- fromAnchors(i, end, lasts.length ? lasts : [end - 1]);
2031
- i = end;
2032
- } else if (CYRILLIC.has(k)) {
2033
- const end = wordEnd(i, CYRILLIC);
2034
- const vowels = [];
2035
- for (let j = i; j < end; j++) if (at(cls, j) === SpeechClass.CYRILLIC_VOWEL) vowels.push(j);
2036
- fromAnchors(i, end, vowels.length ? vowels : [end - 1]);
2037
- i = end;
2038
- } else if (ARABIC.has(k)) {
2039
- const end = wordEnd(i, ARABIC);
2040
- const vowels = [], letters = [];
2041
- for (let j = i; j < end; j++) {
2042
- if (at(cls, j) === SpeechClass.ARABIC_VOWEL) vowels.push(j);
2043
- else if (at(cls, j) === SpeechClass.ARABIC_LETTER) letters.push(j);
2044
- }
2045
- fromAnchors(i, end, vowels.length ? vowels : spread(letters, Math.max(1, Math.ceil(letters.length / 2)), 2));
2046
- i = end;
2047
- } else if (THAI.has(k)) {
2048
- const end = wordEnd(i, THAI);
2049
- fromAnchors(i, end, thaiAnchors(cls, i, end));
2050
- i = end;
2051
- } else if (OTHER.has(k)) {
2052
- const end = wordEnd(i, OTHER);
2053
- const letters = [];
2054
- for (let j = i; j < end; j++) if (at(cls, j) === SpeechClass.OTHER_LETTER) letters.push(j);
2055
- fromAnchors(i, end, spread(letters, Math.max(1, Math.ceil(letters.length / 3)), 3));
2056
- i = end;
2057
- } else if (k === SpeechClass.HAN) {
2058
- const end = marksEnd(i + 1);
2059
- syllable(i, end, japanese ? SPEECH_KANJI_WEIGHT : 1);
2060
- i = end;
2061
- } else if (k === SpeechClass.KANA || k === SpeechClass.HANGUL) {
2062
- const end = marksEnd(i + 1);
2063
- syllable(i, end);
2064
- i = end;
2065
- } else if (k === SpeechClass.KANA_SMALL || k === SpeechClass.KANA_LONG) {
2066
- const end = marksEnd(i + 1);
2067
- const last = units[units.length - 1];
2068
- if (last && last.kind === "syllable" && last.end === i) {
2069
- last.end = end;
2070
- if (k === SpeechClass.KANA_LONG) last.weight += 1;
2071
- } else if (k === SpeechClass.KANA_SMALL) syllable(i, end);
2072
- i = end;
2073
- } else if (k === SpeechClass.KANA_SOKUON) {
2074
- const end = marksEnd(i + 1);
2075
- units.push({ kind: "closed", weight: 1, start: i, end });
2076
- i = end;
2077
- } else if (k === SpeechClass.DIGIT) {
2078
- const end = marksEnd(i + 1);
2079
- syllable(i, end, SPEECH_DIGIT_WEIGHT);
2080
- i = end;
2081
- } else if (k === SpeechClass.PAUSE_SHORT || k === SpeechClass.PAUSE_LONG) {
2082
- const inNumber = (at(cps, i) === 46 || at(cps, i) === 44) && classAt(i - 1) === SpeechClass.DIGIT && classAt(i + 1) === SpeechClass.DIGIT;
2083
- if (!inNumber) units.push({ kind: "pause", weight: k === SpeechClass.PAUSE_LONG ? SPEECH_PAUSE_LONG_WEIGHT : SPEECH_PAUSE_SHORT_WEIGHT, start: i, end: i + 1 });
2084
- i++;
2085
- } else if (k === SpeechClass.SPACE) {
2086
- let end = i + 1;
2087
- while (end < n && at(cls, end) === SpeechClass.SPACE) end++;
2088
- if (thaiBefore(cls, i - 1) && THAI.has(classAt(end))) units.push({ kind: "pause", weight: SPEECH_PAUSE_SHORT_WEIGHT, start: i, end });
2089
- i = end;
2090
- } else {
2091
- i++;
2092
- }
2093
- }
2094
- return tidyPauses(units);
2095
- }
2096
- function thaiBefore(cls, j) {
2097
- while (j >= 0 && at(cls, j) === SpeechClass.MARK) j--;
2098
- return j >= 0 && THAI.has(at(cls, j));
2099
- }
2100
- function silentE(cps, cls, start, end, e, lang) {
2101
- if (lang !== "en" && lang !== "fr") return false;
2102
- if (at(cps, e) !== 101 && at(cps, e) !== 69) return false;
2103
- let after = e + 1;
2104
- if (after < end && at(cls, after) === SpeechClass.MARK) return false;
2105
- if (lang === "fr" && after < end && (at(cps, after) === 115 || at(cps, after) === 83)) after++;
2106
- if (after !== end) return false;
2107
- if (lang === "en" && e - 2 >= start && (at(cps, e - 1) === 108 || at(cps, e - 1) === 76) && at(cls, e - 2) === SpeechClass.LATIN_LETTER) return false;
2108
- return true;
2109
- }
2110
- function thaiAnchors(cls, start, end) {
2111
- const anchors = [];
2112
- let consonants = [];
2113
- let leadOpen = false;
2114
- const implicit = () => {
2115
- for (let j = 0; j < Math.floor((consonants.length - 1) / 2); j++) anchors.push(at(consonants, 2 * j + 1));
2116
- };
2117
- for (let p = start; p < end; p++) {
2118
- const k = at(cls, p);
2119
- if (k === SpeechClass.THAI_CONSONANT) consonants.push(p);
2120
- else if (k === SpeechClass.THAI_LEAD) {
2121
- implicit();
2122
- anchors.push(p + 1 < end && at(cls, p + 1) === SpeechClass.THAI_CONSONANT ? p + 1 : p);
2123
- consonants = [];
2124
- leadOpen = true;
2125
- } else if (k === SpeechClass.THAI_VOWEL) {
2126
- if (consonants.length === 0) continue;
2127
- if (leadOpen && consonants.length <= 2) {
2128
- leadOpen = false;
2129
- consonants = [];
2130
- continue;
2131
- }
2132
- implicit();
2133
- anchors.push(p);
2134
- consonants = [];
2135
- leadOpen = false;
2136
- }
2137
- }
2138
- if (anchors.length === 0) {
2139
- const count = Math.max(1, Math.ceil(consonants.length / 2));
2140
- for (let j = 0; j < count; j++) anchors.push(consonants.length ? at(consonants, Math.min(2 * j + 1, consonants.length - 1)) : end - 1);
2141
- } else implicit();
2142
- return anchors;
2143
- }
2144
- function tidyPauses(units) {
2145
- const out = [];
2146
- for (const u of units) {
2147
- const last = out[out.length - 1];
2148
- if (u.kind === "pause" && last?.kind === "pause") {
2149
- last.weight = Math.max(last.weight, u.weight);
2150
- last.end = u.end;
2151
- } else out.push({ ...u });
2152
- }
2153
- while (out[0]?.kind === "pause") out.shift();
2154
- while (out[out.length - 1]?.kind === "pause") out.pop();
2155
- return out;
2156
- }
2157
- function countSyllables(text, locale) {
2158
- let total = 0;
2159
- for (const u of speechUnits(text, locale)) if (u.kind !== "pause") total += u.weight;
2160
- return total;
2161
- }
2162
-
2163
- // src/index.ts
2164
89
  var import_expr = require("@wildwinter/expr");
2165
90
  function walkNodes(nodes, visit) {
2166
91
  for (const node of nodes) {
@@ -2259,17 +184,49 @@ function textIsAction(project, scene) {
2259
184
  var DEFAULT_PAD_AFTER = 0.6;
2260
185
  var PAD_AFTER_MIN = -10;
2261
186
  var PAD_AFTER_MAX = 60;
2262
- var DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND = 4;
2263
- var ESTIMATE_SYLLABLES_PER_SECOND_MIN = 2;
2264
- var ESTIMATE_SYLLABLES_PER_SECOND_MAX = 10;
187
+ var DEFAULT_ESTIMATE_SPEED = 1;
188
+ var ESTIMATE_SPEED_MIN = 0.5;
189
+ var ESTIMATE_SPEED_MAX = 2.5;
190
+ var LINE_CHARS_PER_SECOND = 14;
2265
191
  var LINE_DURATION_MIN = 0.5;
2266
192
  var LINE_DURATION_MAX = 18;
2267
193
  var SUBTITLE_READING_MIN = 1.5;
2268
- function estimateLineDuration(text, locale, syllablesPerSecond) {
2269
- const rate = typeof syllablesPerSecond === "number" && Number.isFinite(syllablesPerSecond) && syllablesPerSecond > 0 ? syllablesPerSecond : DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND;
194
+ function normaliseEstimateSpeed(project) {
195
+ const obj = project;
196
+ if (!("estimateSyllablesPerSecond" in obj)) return project;
197
+ const old = obj["estimateSyllablesPerSecond"];
198
+ delete obj["estimateSyllablesPerSecond"];
199
+ if (obj["estimateSpeed"] === void 0 && old !== void 0) obj["estimateSpeed"] = typeof old === "number" ? old / 4 : old;
200
+ return project;
201
+ }
202
+ var LINE_CHAR_WEIGHTS = [
203
+ [173, 173, 0],
204
+ [12352, 12543, 2],
205
+ [12784, 12799, 2],
206
+ [13312, 19903, 3],
207
+ [19968, 40959, 3],
208
+ [44032, 55203, 2.5],
209
+ [63744, 64255, 3],
210
+ [65382, 65439, 2],
211
+ [131072, 201551, 3]
212
+ ];
213
+ function estimateLineDuration(text, locale, speed) {
214
+ void locale;
215
+ const s = typeof speed === "number" && Number.isFinite(speed) && speed > 0 ? speed : DEFAULT_ESTIMATE_SPEED;
2270
216
  let weight = 0;
2271
- for (const u of speechUnits(text ?? "", locale)) weight += u.weight;
2272
- return Math.min(Math.max(weight / rate, LINE_DURATION_MIN), LINE_DURATION_MAX);
217
+ for (const ch of text ?? "") {
218
+ const cp = ch.codePointAt(0);
219
+ let w = 1;
220
+ for (const [lo, hi, cw] of LINE_CHAR_WEIGHTS) {
221
+ if (cp < lo) break;
222
+ if (cp <= hi) {
223
+ w = cw;
224
+ break;
225
+ }
226
+ }
227
+ weight += w;
228
+ }
229
+ return Math.min(Math.max(weight / (LINE_CHARS_PER_SECOND * s), LINE_DURATION_MIN), LINE_DURATION_MAX);
2273
230
  }
2274
231
  var DEFAULT_WRITING_STATUSES = [
2275
232
  { name: "stub", colour: 0 },
@@ -2318,13 +275,13 @@ function sceneFolderLayout(project, sceneIds) {
2318
275
  const folderParent = /* @__PURE__ */ new Map();
2319
276
  for (const f of folders) folderParent.set(f.id, f.parent !== void 0 && known.has(f.parent) && f.parent !== f.id ? f.parent : void 0);
2320
277
  for (const f of folders) {
2321
- let at2 = folderParent.get(f.id);
2322
- for (let steps = 0; at2 !== void 0 && steps <= folders.length; steps++) {
2323
- if (at2 === f.id) {
278
+ let at = folderParent.get(f.id);
279
+ for (let steps = 0; at !== void 0 && steps <= folders.length; steps++) {
280
+ if (at === f.id) {
2324
281
  folderParent.set(f.id, void 0);
2325
282
  break;
2326
283
  }
2327
- at2 = folderParent.get(at2);
284
+ at = folderParent.get(at);
2328
285
  }
2329
286
  }
2330
287
  const sceneFolder = /* @__PURE__ */ new Map();
@@ -2363,7 +320,7 @@ function sceneFolderLayout(project, sceneIds) {
2363
320
  function sceneFolderPath(project, layout, sceneId) {
2364
321
  const names = new Map((project.sceneFolders ?? []).map((f) => [f.id, f.name]));
2365
322
  const parts = [];
2366
- for (let at2 = layout.sceneFolder.get(sceneId), n = 0; at2 !== void 0 && n <= names.size; at2 = layout.folderParent.get(at2), n++) parts.unshift(names.get(at2) ?? "");
323
+ for (let at = layout.sceneFolder.get(sceneId), n = 0; at !== void 0 && n <= names.size; at = layout.folderParent.get(at), n++) parts.unshift(names.get(at) ?? "");
2367
324
  return parts.join(" / ");
2368
325
  }
2369
326
  var PROJECT_LOCALE_SCENE = "@project";
@@ -2407,20 +364,22 @@ var UNRESOLVED_KEY = "unresolved";
2407
364
  DEFAULT_CAPTION_CHARACTER,
2408
365
  DEFAULT_CAPTION_DELIMITERS,
2409
366
  DEFAULT_DOCUMENTATION_CLASSES,
2410
- DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND,
367
+ DEFAULT_ESTIMATE_SPEED,
2411
368
  DEFAULT_LAYOUT,
2412
369
  DEFAULT_PAD_AFTER,
2413
370
  DEFAULT_QUALIFIERS,
2414
371
  DEFAULT_RECORDING_STATUSES,
2415
372
  DEFAULT_SPEAKER_PATTERN,
2416
373
  DEFAULT_WRITING_STATUSES,
2417
- ESTIMATE_SYLLABLES_PER_SECOND_MAX,
2418
- ESTIMATE_SYLLABLES_PER_SECOND_MIN,
374
+ ESTIMATE_SPEED_MAX,
375
+ ESTIMATE_SPEED_MIN,
2419
376
  EXTENSIONS_DIR,
2420
377
  EXTENSION_SCHEMA,
2421
378
  EXTENSION_SHARD,
2422
379
  FLOW_SCHEMA,
2423
380
  HANDOFF_SCHEMA,
381
+ LINE_CHARS_PER_SECOND,
382
+ LINE_CHAR_WEIGHTS,
2424
383
  LINE_DURATION_MAX,
2425
384
  LINE_DURATION_MIN,
2426
385
  MANIFEST_EXTENSION,
@@ -2435,15 +394,10 @@ var UNRESOLVED_KEY = "unresolved";
2435
394
  SAVE_SCHEMA,
2436
395
  SAVE_VERSION,
2437
396
  SPEAKER_PATTERN_KEY,
2438
- SPEECH_DIGIT_WEIGHT,
2439
- SPEECH_KANJI_WEIGHT,
2440
- SPEECH_PAUSE_LONG_WEIGHT,
2441
- SPEECH_PAUSE_SHORT_WEIGHT,
2442
397
  STRINGS_SCHEMA,
2443
398
  SUBTITLE_READING_MIN,
2444
399
  UNRESOLVED_KEY,
2445
400
  castStringKey,
2446
- countSyllables,
2447
401
  deriveRecordingFolders,
2448
402
  effectiveGameId,
2449
403
  estimateLineDuration,
@@ -2454,6 +408,7 @@ var UNRESOLVED_KEY = "unresolved";
2454
408
  isDialogueScene,
2455
409
  isValidGameId,
2456
410
  isValidPropertyName,
411
+ normaliseEstimateSpeed,
2457
412
  projectLayout,
2458
413
  projectQualifiers,
2459
414
  propertyNameify,
@@ -2463,7 +418,6 @@ var UNRESOLVED_KEY = "unresolved";
2463
418
  sceneFolderLayout,
2464
419
  sceneFolderPath,
2465
420
  speakerLabelKey,
2466
- speechUnits,
2467
421
  textIsAction,
2468
422
  usedQualifiers,
2469
423
  usedSpeakerPairs,