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