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