runonweb 0.0.1

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.
@@ -0,0 +1,133 @@
1
+ // Generated by scripts/translate-models.mjs from Mozilla's Firefox Translations registry.
2
+ // Source: https://storage.googleapis.com/moz-fx-translations-data--303e-prod-translations-data/db/models.json
3
+ // Registry generated 2026-09-11T00:34:07Z. Do not edit by hand.
4
+
5
+ export type Architecture = 'tiny' | 'base' | 'base-memory'
6
+
7
+ export type PairEntry = {
8
+ from: string
9
+ to: string
10
+ architecture: Architecture
11
+ /** Mozilla training run id. Part of the download URL so updated weights bust the cache. */
12
+ revision: string
13
+ /** Uncompressed model size in bytes (shortlist + vocab add ~5 MB). */
14
+ bytes: number
15
+ params: number
16
+ /** COMET-22 on FLORES-200+ as reported by Mozilla, when available. */
17
+ comet: number | null
18
+ files: { model: string; lex: string; vocab?: string; srcvocab?: string; trgvocab?: string }
19
+ }
20
+
21
+ /** Bergamot runtime (Marian in WASM) that runs these models. */
22
+ export const RUNTIME_VERSION = '0.4.16'
23
+ export const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/@mkljczk/bergamot-translator@0.4.16/worker/'
24
+
25
+ /** Every released language pair, keyed `<from>-<to>`. */
26
+ export const PAIRS: Record<string, PairEntry> = {
27
+ 'af-en': { from: 'af', to: 'en', architecture: 'base-memory', revision: 'next26_HIyjLJaNReijN0eJouAJBw', bytes: 31561787, params: 31248966, comet: 0.8831, files: { model: 'model.afen.intgemm.alphas.bin', lex: 'lex.50.50.afen.s2t.bin', vocab: 'vocab.afen.spm' } },
28
+ 'ar-en': { from: 'ar', to: 'en', architecture: 'base-memory', revision: 'retrain_base-memory_X9fDxFreTOCslPKzb1CXTg', bytes: 31561787, params: 31248966, comet: 0.8597, files: { model: 'model.aren.intgemm.alphas.bin', lex: 'lex.50.50.aren.s2t.bin', vocab: 'vocab.aren.spm' } },
29
+ 'bg-en': { from: 'bg', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_WvwHu4k6TgmJ2YTvL4Mu2g', bytes: 31561787, params: 31248966, comet: 0.8719, files: { model: 'model.bgen.intgemm.alphas.bin', lex: 'lex.50.50.bgen.s2t.bin', vocab: 'vocab.bgen.spm' } },
30
+ 'bn-en': { from: 'bn', to: 'en', architecture: 'tiny', revision: 'h1-2025_XcpBlhA1SyOJCH2UzoIMyQ', bytes: 17141051, params: 16907062, comet: 0.8547, files: { model: 'model.bnen.intgemm.alphas.bin', lex: 'lex.50.50.bnen.s2t.bin', vocab: 'vocab.bnen.spm' } },
31
+ 'ca-en': { from: 'ca', to: 'en', architecture: 'base-memory', revision: 'target-side-dedup_xxxxxxxxRxSxxxxxxxxxxA', bytes: 31561787, params: 31248966, comet: 0.8777, files: { model: 'model.caen.intgemm.alphas.bin', lex: 'lex.50.50.caen.s2t.bin', vocab: 'vocab.caen.spm' } },
32
+ 'cs-en': { from: 'cs', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_EwWhUov8TP6D_oolATvbUA', bytes: 31561787, params: 31248966, comet: 0.8748, files: { model: 'model.csen.intgemm.alphas.bin', lex: 'lex.50.50.csen.s2t.bin', vocab: 'vocab.csen.spm' } },
33
+ 'da-en': { from: 'da', to: 'en', architecture: 'tiny', revision: 'spring-2024_U1vVpsWWT-K4L9pRfP1K1g', bytes: 17141051, params: 16907062, comet: 0.8915, files: { model: 'model.daen.intgemm.alphas.bin', lex: 'lex.50.50.daen.s2t.bin', vocab: 'vocab.daen.spm' } },
34
+ 'de-en': { from: 'de', to: 'en', architecture: 'base-memory', revision: 'retrain_hr2_WZOW24i4QJmIib61LeHfwg', bytes: 31561787, params: 31248966, comet: 0.8813, files: { model: 'model.deen.intgemm.alphas.bin', lex: 'lex.50.50.deen.s2t.bin', vocab: 'vocab.deen.spm' } },
35
+ 'el-en': { from: 'el', to: 'en', architecture: 'tiny', revision: 'spring-2024_RJucgx7LRMKB9E4oSSzdtA', bytes: 17141051, params: 16907062, comet: 0.8550, files: { model: 'model.elen.intgemm.alphas.bin', lex: 'lex.50.50.elen.s2t.bin', vocab: 'vocab.elen.spm' } },
36
+ 'en-af': { from: 'en', to: 'af', architecture: 'base-memory', revision: 'next26_CqoXSiBvSUq9Co3ePAYA1w', bytes: 31561787, params: 31248966, comet: 0.8654, files: { model: 'model.enaf.intgemm.alphas.bin', lex: 'lex.50.50.enaf.s2t.bin', vocab: 'vocab.enaf.spm' } },
37
+ 'en-ar': { from: 'en', to: 'ar', architecture: 'base-memory', revision: 'retrain_base-memory_G3CmhwG_TZext3cys-udHg', bytes: 31561787, params: 31248966, comet: 0.8596, files: { model: 'model.enar.intgemm.alphas.bin', lex: 'lex.50.50.enar.s2t.bin', vocab: 'vocab.enar.spm' } },
38
+ 'en-az': { from: 'en', to: 'az', architecture: 'tiny', revision: 'h1-2025_fu1HFuR0QY-zVBcKYQkJIA', bytes: 17141051, params: 16907062, comet: 0.8372, files: { model: 'model.enaz.intgemm.alphas.bin', lex: 'lex.50.50.enaz.s2t.bin', vocab: 'vocab.enaz.spm' } },
39
+ 'en-bg': { from: 'en', to: 'bg', architecture: 'base-memory', revision: 'retrain_hr_eAF9fkYRScmBmvvfdT4XWw', bytes: 31561787, params: 31248966, comet: 0.8985, files: { model: 'model.enbg.intgemm.alphas.bin', lex: 'lex.50.50.enbg.s2t.bin', vocab: 'vocab.enbg.spm' } },
40
+ 'en-bn': { from: 'en', to: 'bn', architecture: 'tiny', revision: 'h1-2025_TYlSskC_Sk6lBlfWRetXmg', bytes: 17141051, params: 16907062, comet: 0.8471, files: { model: 'model.enbn.intgemm.alphas.bin', lex: 'lex.50.50.enbn.s2t.bin', vocab: 'vocab.enbn.spm' } },
41
+ 'en-bs': { from: 'en', to: 'bs', architecture: 'base-memory', revision: 'hbs-topk10_HBBkp2ozSYaY9f7WVGRtpA', bytes: 31561787, params: 31248966, comet: 0.8960, files: { model: 'model.enbs.intgemm.alphas.bin', lex: 'lex.50.50.enbs.s2t.bin', vocab: 'vocab.enbs.spm' } },
42
+ 'en-ca': { from: 'en', to: 'ca', architecture: 'base-memory', revision: 'short-sentences_dqpjVFEaT2WLVB2nV0_H2g', bytes: 31561787, params: 31248966, comet: 0.8696, files: { model: 'model.enca.intgemm.alphas.bin', lex: 'lex.50.50.enca.s2t.bin', vocab: 'vocab.enca.spm' } },
43
+ 'en-cs': { from: 'en', to: 'cs', architecture: 'base-memory', revision: 'retrain_hr_F_JF0vqvSjSwn3caQQcicA', bytes: 31561787, params: 31248966, comet: 0.8908, files: { model: 'model.encs.intgemm.alphas.bin', lex: 'lex.50.50.encs.s2t.bin', vocab: 'vocab.encs.spm' } },
44
+ 'en-da': { from: 'en', to: 'da', architecture: 'tiny', revision: 'spring-2024_XUm0Ij8WSfabkKeKA_Xv_g', bytes: 17141051, params: 16907062, comet: 0.8908, files: { model: 'model.enda.intgemm.alphas.bin', lex: 'lex.50.50.enda.s2t.bin', vocab: 'vocab.enda.spm' } },
45
+ 'en-de': { from: 'en', to: 'de', architecture: 'base-memory', revision: 'retrain_hr_fix_names_SCgGhxUPQ2WAECHLRtzrMg', bytes: 31561787, params: 31248966, comet: 0.8670, files: { model: 'model.ende.intgemm.alphas.bin', lex: 'lex.50.50.ende.s2t.bin', vocab: 'vocab.ende.spm' } },
46
+ 'en-el': { from: 'en', to: 'el', architecture: 'tiny', revision: 'spring-2024_Y3ThG3XkTxG4ROUQK2LpVg', bytes: 17141051, params: 16907062, comet: 0.8721, files: { model: 'model.enel.intgemm.alphas.bin', lex: 'lex.50.50.enel.s2t.bin', vocab: 'vocab.enel.spm' } },
47
+ 'en-es': { from: 'en', to: 'es', architecture: 'base-memory', revision: 'retrain_hr_fix_names_CUAEXUHoQum_cFqh-ZAryw', bytes: 31561787, params: 31248966, comet: 0.8540, files: { model: 'model.enes.intgemm.alphas.bin', lex: 'lex.50.50.enes.s2t.bin', vocab: 'vocab.enes.spm' } },
48
+ 'en-et': { from: 'en', to: 'et', architecture: 'base-memory', revision: 'retrain_hr_GubU3EaMRY2VkR8p1dPUNw', bytes: 31561787, params: 31248966, comet: 0.9040, files: { model: 'model.enet.intgemm.alphas.bin', lex: 'lex.50.50.enet.s2t.bin', vocab: 'vocab.enet.spm' } },
49
+ 'en-eu': { from: 'en', to: 'eu', architecture: 'base-memory', revision: 'eneu-baseline_IXuA7hOrQPCVZJOp6LIYVw', bytes: 31561787, params: 31248966, comet: 0.8634, files: { model: 'model.eneu.intgemm.alphas.bin', lex: 'lex.50.50.eneu.s2t.bin', vocab: 'vocab.eneu.spm' } },
50
+ 'en-fa': { from: 'en', to: 'fa', architecture: 'tiny', revision: 'h1-2025_c_TYU1BOTByxOnnkAunO7g', bytes: 17141051, params: 16907062, comet: 0.8462, files: { model: 'model.enfa.intgemm.alphas.bin', lex: 'lex.50.50.enfa.s2t.bin', vocab: 'vocab.enfa.spm' } },
51
+ 'en-fi': { from: 'en', to: 'fi', architecture: 'base-memory', revision: 'retrain_hr_b45LsGaNQFyDRhHAvBbKrA', bytes: 31561787, params: 31248966, comet: 0.9079, files: { model: 'model.enfi.intgemm.alphas.bin', lex: 'lex.50.50.enfi.s2t.bin', vocab: 'vocab.enfi.spm' } },
52
+ 'en-fr': { from: 'en', to: 'fr', architecture: 'base-memory', revision: 'retrain_hr_NLIxDbE1TBGyOTI-zwZagw', bytes: 31561787, params: 31248966, comet: 0.8653, files: { model: 'model.enfr.intgemm.alphas.bin', lex: 'lex.50.50.enfr.s2t.bin', vocab: 'vocab.enfr.spm' } },
53
+ 'en-gl': { from: 'en', to: 'gl', architecture: 'base-memory', revision: 'engl-finetranslations_d_vpGU94Qz-VGUAvC-QW1w', bytes: 31561787, params: 31248966, comet: 0.8616, files: { model: 'model.engl.intgemm.alphas.bin', lex: 'lex.50.50.engl.s2t.bin', vocab: 'vocab.engl.spm' } },
54
+ 'en-gu': { from: 'en', to: 'gu', architecture: 'tiny', revision: 'h1-2025_Na2-WpCIR1Sdy17l-XDeLA', bytes: 17141051, params: 16907062, comet: 0.8606, files: { model: 'model.engu.intgemm.alphas.bin', lex: 'lex.50.50.engu.s2t.bin', vocab: 'vocab.engu.spm' } },
55
+ 'en-he': { from: 'en', to: 'he', architecture: 'tiny', revision: 'h1-2025_QtanzRiDRISacRVw4WzWYQ', bytes: 17141051, params: 16907062, comet: 0.8681, files: { model: 'model.enhe.intgemm.alphas.bin', lex: 'lex.50.50.enhe.s2t.bin', vocab: 'vocab.enhe.spm' } },
56
+ 'en-hi': { from: 'en', to: 'hi', architecture: 'tiny', revision: 'h1-2025_KoJuCNf_Q42R2Bz6j2jlOQ', bytes: 17141051, params: 16907062, comet: 0.7902, files: { model: 'model.enhi.intgemm.alphas.bin', lex: 'lex.50.50.enhi.s2t.bin', vocab: 'vocab.enhi.spm' } },
57
+ 'en-hr': { from: 'en', to: 'hr', architecture: 'base-memory', revision: 'hbs-topk10_PLHJ-5OxSNyWlwZM12Kghw', bytes: 31561787, params: 31248966, comet: 0.8957, files: { model: 'model.enhr.intgemm.alphas.bin', lex: 'lex.50.50.enhr.s2t.bin', vocab: 'vocab.enhr.spm' } },
58
+ 'en-hu': { from: 'en', to: 'hu', architecture: 'base-memory', revision: 'next26_Tzv045N-SASkA8X287pEqg', bytes: 31561787, params: 31248966, comet: 0.8857, files: { model: 'model.enhu.intgemm.alphas.bin', lex: 'lex.50.50.enhu.s2t.bin', vocab: 'vocab.enhu.spm' } },
59
+ 'en-id': { from: 'en', to: 'id', architecture: 'tiny', revision: 'spring-2024_bbjDBFoDTNGSUo2if3ET_A', bytes: 17141051, params: 16907062, comet: 0.9053, files: { model: 'model.enid.intgemm.alphas.bin', lex: 'lex.50.50.enid.s2t.bin', vocab: 'vocab.enid.spm' } },
60
+ 'en-is': { from: 'en', to: 'is', architecture: 'base-memory', revision: 'docmt-vocab_EkZBaZqDS5Cce_lC2BpxlA', bytes: 31561787, params: 31248966, comet: 0.8374, files: { model: 'model.enis.intgemm.alphas.bin', lex: 'lex.50.50.enis.s2t.bin', vocab: 'vocab.enis.spm' } },
61
+ 'en-it': { from: 'en', to: 'it', architecture: 'base-memory', revision: 'retrain_hr_fix_names_GPSr_u8PSmC9fOx1ZDCHoA', bytes: 31561787, params: 31248966, comet: 0.8655, files: { model: 'model.enit.intgemm.alphas.bin', lex: 'lex.50.50.enit.s2t.bin', vocab: 'vocab.enit.spm' } },
62
+ 'en-ja': { from: 'en', to: 'ja', architecture: 'base-memory', revision: 'llmaat_finetune10M_qe8_f2_ApiGGQIwTKuF9i_k3n9Q2Q', bytes: 43849787, params: 43536965, comet: 0.9003, files: { model: 'model.enja.intgemm.alphas.bin', lex: 'lex.50.50.enja.s2t.bin', srcvocab: 'srcvocab.enja.spm', trgvocab: 'trgvocab.enja.spm' } },
63
+ 'en-kn': { from: 'en', to: 'kn', architecture: 'tiny', revision: 'h1-2025_DDVsjRwsQ8GL3-JAiAmmfQ', bytes: 17141051, params: 16907062, comet: 0.8433, files: { model: 'model.enkn.intgemm.alphas.bin', lex: 'lex.50.50.enkn.s2t.bin', vocab: 'vocab.enkn.spm' } },
64
+ 'en-ko': { from: 'en', to: 'ko', architecture: 'base-memory', revision: 'cjk_retrain_base-memory_GP50C3MpQ9apCWZOW-f3PA', bytes: 43849787, params: 43536965, comet: 0.8708, files: { model: 'model.enko.intgemm.alphas.bin', lex: 'lex.50.50.enko.s2t.bin', srcvocab: 'srcvocab.enko.spm', trgvocab: 'trgvocab.enko.spm' } },
65
+ 'en-lt': { from: 'en', to: 'lt', architecture: 'base-memory', revision: 'h1-2025_CpawQ31iTrmnax9Xi0DkBw', bytes: 31561787, params: 31248966, comet: 0.8830, files: { model: 'model.enlt.intgemm.alphas.bin', lex: 'lex.50.50.enlt.s2t.bin', vocab: 'vocab.enlt.spm' } },
66
+ 'en-lv': { from: 'en', to: 'lv', architecture: 'base-memory', revision: 'h1-2025_L9sajlF2TCKfEzDro4tK3Q', bytes: 31561787, params: 31248966, comet: 0.8686, files: { model: 'model.enlv.intgemm.alphas.bin', lex: 'lex.50.50.enlv.s2t.bin', vocab: 'vocab.enlv.spm' } },
67
+ 'en-ml': { from: 'en', to: 'ml', architecture: 'tiny', revision: 'h1-2025_UylcthuMRoelqd6lsCbXJw', bytes: 17141051, params: 16907062, comet: 0.8676, files: { model: 'model.enml.intgemm.alphas.bin', lex: 'lex.50.50.enml.s2t.bin', vocab: 'vocab.enml.spm' } },
68
+ 'en-mr': { from: 'en', to: 'mr', architecture: 'base-memory', revision: 'indictrans2-teacher_YxWwPatgTHy0imIiIafh5A', bytes: 31561787, params: 31248966, comet: 0.7599, files: { model: 'model.enmr.intgemm.alphas.bin', lex: 'lex.50.50.enmr.s2t.bin', vocab: 'vocab.enmr.spm' } },
69
+ 'en-ms': { from: 'en', to: 'ms', architecture: 'tiny', revision: 'h1-2025_Ba76abX1Qtums6Vbv95tzg', bytes: 17141051, params: 16907062, comet: 0.8813, files: { model: 'model.enms.intgemm.alphas.bin', lex: 'lex.50.50.enms.s2t.bin', vocab: 'vocab.enms.spm' } },
70
+ 'en-nb': { from: 'en', to: 'nb', architecture: 'tiny', revision: 'h1-2025_A0d8NsivR6Szy2dI4Nz6FQ', bytes: 17141051, params: 16907062, comet: 0.9010, files: { model: 'model.ennb.intgemm.alphas.bin', lex: 'lex.50.50.ennb.s2t.bin', vocab: 'vocab.ennb.spm' } },
71
+ 'en-nl': { from: 'en', to: 'nl', architecture: 'base-memory', revision: 'retrain_hr_fix_names_fR8XhBiBQniIbi4I_ebJ2Q', bytes: 31561787, params: 31248966, comet: 0.8650, files: { model: 'model.ennl.intgemm.alphas.bin', lex: 'lex.50.50.ennl.s2t.bin', vocab: 'vocab.ennl.spm' } },
72
+ 'en-no': { from: 'en', to: 'no', architecture: 'tiny', revision: 'h1-2025_A0d8NsivR6Szy2dI4Nz6FQ', bytes: 17141051, params: 16907062, comet: 0.9010, files: { model: 'model.enno.intgemm.alphas.bin', lex: 'lex.50.50.enno.s2t.bin', vocab: 'vocab.enno.spm' } },
73
+ 'en-pl': { from: 'en', to: 'pl', architecture: 'base-memory', revision: 'retrain_hr_fix_names_YmTlfuUsSKCbUp75UXaUuw', bytes: 31561787, params: 31248966, comet: 0.8683, files: { model: 'model.enpl.intgemm.alphas.bin', lex: 'lex.50.50.enpl.s2t.bin', vocab: 'vocab.enpl.spm' } },
74
+ 'en-pt': { from: 'en', to: 'pt', architecture: 'base-memory', revision: 'retrain_hr_fix_names_Vnb0RUXTTd67hR-oLHM3eg', bytes: 31561787, params: 31248966, comet: 0.8889, files: { model: 'model.enpt.intgemm.alphas.bin', lex: 'lex.50.50.enpt.s2t.bin', vocab: 'vocab.enpt.spm' } },
75
+ 'en-ro': { from: 'en', to: 'ro', architecture: 'tiny', revision: 'spring-2024_Ov3G4D_DRJa-4qTlILkPhg', bytes: 17141051, params: 16907062, comet: 0.8846, files: { model: 'model.enro.intgemm.alphas.bin', lex: 'lex.50.50.enro.s2t.bin', vocab: 'vocab.enro.spm' } },
76
+ 'en-ru': { from: 'en', to: 'ru', architecture: 'base-memory', revision: 'retrain_base-memory_KJ23-iDVTcymG1ZldWY17w', bytes: 31561787, params: 31248966, comet: 0.8745, files: { model: 'model.enru.intgemm.alphas.bin', lex: 'lex.50.50.enru.s2t.bin', vocab: 'vocab.enru.spm' } },
77
+ 'en-sk': { from: 'en', to: 'sk', architecture: 'base-memory', revision: 'h1-2025_NbGVkenLTPiss8w800509A', bytes: 31561787, params: 31248966, comet: 0.8864, files: { model: 'model.ensk.intgemm.alphas.bin', lex: 'lex.50.50.ensk.s2t.bin', vocab: 'vocab.ensk.spm' } },
78
+ 'en-sl': { from: 'en', to: 'sl', architecture: 'base-memory', revision: 'h1-2025_Ph0DK4RhRMe7z4cLk-f7eg', bytes: 31561787, params: 31248966, comet: 0.8789, files: { model: 'model.ensl.intgemm.alphas.bin', lex: 'lex.50.50.ensl.s2t.bin', vocab: 'vocab.ensl.spm' } },
79
+ 'en-sr': { from: 'en', to: 'sr', architecture: 'base-memory', revision: 'hbs-topk10_KZK68xhrQWWeK6xcMRtd9A', bytes: 31561787, params: 31248966, comet: 0.8850, files: { model: 'model.ensr.intgemm.alphas.bin', lex: 'lex.50.50.ensr.s2t.bin', vocab: 'vocab.ensr.spm' } },
80
+ 'en-sv': { from: 'en', to: 'sv', architecture: 'tiny', revision: 'spring-2024_bQQme71PS4eZRDl3NM-kgA', bytes: 17141051, params: 16907062, comet: 0.8918, files: { model: 'model.ensv.intgemm.alphas.bin', lex: 'lex.50.50.ensv.s2t.bin', vocab: 'vocab.ensv.spm' } },
81
+ 'en-ta': { from: 'en', to: 'ta', architecture: 'base-memory', revision: 'next26-nobcbpcc_RgO3iURPQH2EjhUm533NWA', bytes: 31561787, params: 31248966, comet: 0.8855, files: { model: 'model.enta.intgemm.alphas.bin', lex: 'lex.50.50.enta.s2t.bin', vocab: 'vocab.enta.spm' } },
82
+ 'en-te': { from: 'en', to: 'te', architecture: 'tiny', revision: 'h1-2025_J_7yoPHaRJqsevUR512RsQ', bytes: 17141051, params: 16907062, comet: 0.8507, files: { model: 'model.ente.intgemm.alphas.bin', lex: 'lex.50.50.ente.s2t.bin', vocab: 'vocab.ente.spm' } },
83
+ 'en-th': { from: 'en', to: 'th', architecture: 'base-memory', revision: 'new-opuscleaner-en-th-onestage-topk10_WIvJuHhrSyiXLtJBJOUrsA', bytes: 31561787, params: 31248966, comet: 0.8593, files: { model: 'model.enth.intgemm.alphas.bin', lex: 'lex.50.50.enth.s2t.bin', vocab: 'vocab.enth.spm' } },
84
+ 'en-tr': { from: 'en', to: 'tr', architecture: 'tiny', revision: 'spring-2024_LiFGeNrEQpKdNlziG2qP_A', bytes: 17141051, params: 16907062, comet: 0.8750, files: { model: 'model.entr.intgemm.alphas.bin', lex: 'lex.50.50.entr.s2t.bin', vocab: 'vocab.entr.spm' } },
85
+ 'en-uk': { from: 'en', to: 'uk', architecture: 'base-memory', revision: 'docmt-vocab_a2OVwdI-Sg-SBZ_0Joqb0w', bytes: 31561787, params: 31248966, comet: 0.8785, files: { model: 'model.enuk.intgemm.alphas.bin', lex: 'lex.50.50.enuk.s2t.bin', vocab: 'vocab.enuk.spm' } },
86
+ 'en-ur': { from: 'en', to: 'ur', architecture: 'base-memory', revision: 'indictrans2_SUOSu0mESlOMc6IkS5_3sQ', bytes: 31561787, params: 31248966, comet: 0.8316, files: { model: 'model.enur.intgemm.alphas.bin', lex: 'lex.50.50.enur.s2t.bin', vocab: 'vocab.enur.spm' } },
87
+ 'en-vi': { from: 'en', to: 'vi', architecture: 'base-memory', revision: 'test_prompsit_Ep8JhBQ3QRizDT91JVy8KQ', bytes: 31561787, params: 31248966, comet: 0.8712, files: { model: 'model.envi.intgemm.alphas.bin', lex: 'lex.50.50.envi.s2t.bin', vocab: 'vocab.envi.spm' } },
88
+ 'en-zh': { from: 'en', to: 'zh', architecture: 'base-memory', revision: 'llmaat_finetune10M_qe8_f2_ByQcSxGXQRqGi-UTxYE43g', bytes: 43849787, params: 43536965, comet: 0.8628, files: { model: 'model.enzh.intgemm.alphas.bin', lex: 'lex.50.50.enzh.s2t.bin', srcvocab: 'srcvocab.enzh.spm', trgvocab: 'trgvocab.enzh.spm' } },
89
+ 'en-zh-Hant': { from: 'en', to: 'zh-Hant', architecture: 'base-memory', revision: 'zh_hant_llmaat_finetune10M_qe8_f2_aQ8azdOMQOSBVjBDOVDIZQ', bytes: 43849787, params: 43536965, comet: 0.8697, files: { model: 'model.enzh_hant.intgemm.alphas.bin', lex: 'lex.50.50.enzh_hant.s2t.bin', srcvocab: 'srcvocab.enzh_hant.spm', trgvocab: 'trgvocab.enzh_hant.spm' } },
90
+ 'es-en': { from: 'es', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_HbNjJ60BTwmVTbhfFxuduA', bytes: 31561787, params: 31248966, comet: 0.8572, files: { model: 'model.esen.intgemm.alphas.bin', lex: 'lex.50.50.esen.s2t.bin', vocab: 'vocab.esen.spm' } },
91
+ 'et-en': { from: 'et', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_RNXxp-Q9Q4GRExCoMAT77Q', bytes: 31561787, params: 31248966, comet: 0.8812, files: { model: 'model.eten.intgemm.alphas.bin', lex: 'lex.50.50.eten.s2t.bin', vocab: 'vocab.eten.spm' } },
92
+ 'eu-en': { from: 'eu', to: 'en', architecture: 'base-memory', revision: 'euen-finetranslations_Blfz7PCVT4qOGYPj9q6oMg', bytes: 31561787, params: 31248966, comet: 0.8617, files: { model: 'model.euen.intgemm.alphas.bin', lex: 'lex.50.50.euen.s2t.bin', vocab: 'vocab.euen.spm' } },
93
+ 'fa-en': { from: 'fa', to: 'en', architecture: 'tiny', revision: 'h1-2025_dyvKzoMQToKWHx7bbP-TtQ', bytes: 17141051, params: 16907062, comet: 0.8574, files: { model: 'model.faen.intgemm.alphas.bin', lex: 'lex.50.50.faen.s2t.bin', vocab: 'vocab.faen.spm' } },
94
+ 'fi-en': { from: 'fi', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_C7-zSzS7Tm6zkOfVP7k0Gw', bytes: 31561787, params: 31248966, comet: 0.8864, files: { model: 'model.fien.intgemm.alphas.bin', lex: 'lex.50.50.fien.s2t.bin', vocab: 'vocab.fien.spm' } },
95
+ 'fr-en': { from: 'fr', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_EFgIftH_RrCyzl5gjemVNg', bytes: 31561787, params: 31248966, comet: 0.8860, files: { model: 'model.fren.intgemm.alphas.bin', lex: 'lex.50.50.fren.s2t.bin', vocab: 'vocab.fren.spm' } },
96
+ 'gl-en': { from: 'gl', to: 'en', architecture: 'base-memory', revision: 'gl-finetranslations_M9yGl6Y4Q5ysCI8bqEZfTQ', bytes: 31561787, params: 31248966, comet: 0.8730, files: { model: 'model.glen.intgemm.alphas.bin', lex: 'lex.50.50.glen.s2t.bin', vocab: 'vocab.glen.spm' } },
97
+ 'gu-en': { from: 'gu', to: 'en', architecture: 'tiny', revision: 'h1-2025_AbHCTUgSSguJ1-Pq-XLnVA', bytes: 17141051, params: 16907062, comet: 0.8695, files: { model: 'model.guen.intgemm.alphas.bin', lex: 'lex.50.50.guen.s2t.bin', vocab: 'vocab.guen.spm' } },
98
+ 'hbs-en': { from: 'hbs', to: 'en', architecture: 'base-memory', revision: 'hbs_d85wHYN_SUmGIqekvLSNjA', bytes: 31561787, params: 31248966, comet: null, files: { model: 'model.hbsen.intgemm.alphas.bin', lex: 'lex.50.50.hbsen.s2t.bin', vocab: 'vocab.hbsen.spm' } },
99
+ 'he-en': { from: 'he', to: 'en', architecture: 'tiny', revision: 'h1-2025_IZKPrf3xQaKu56F3zmH0cw', bytes: 17141051, params: 16907062, comet: 0.8573, files: { model: 'model.heen.intgemm.alphas.bin', lex: 'lex.50.50.heen.s2t.bin', vocab: 'vocab.heen.spm' } },
100
+ 'hi-en': { from: 'hi', to: 'en', architecture: 'tiny', revision: 'h1-2025_IcUQD-GbSJWB6WV08oDoEw', bytes: 17141051, params: 16907062, comet: 0.8724, files: { model: 'model.hien.intgemm.alphas.bin', lex: 'lex.50.50.hien.s2t.bin', vocab: 'vocab.hien.spm' } },
101
+ 'hu-en': { from: 'hu', to: 'en', architecture: 'base-memory', revision: 'next26_ehk9UNnTTNCsQ0eZhWcNXg', bytes: 31561787, params: 31248966, comet: 0.8736, files: { model: 'model.huen.intgemm.alphas.bin', lex: 'lex.50.50.huen.s2t.bin', vocab: 'vocab.huen.spm' } },
102
+ 'id-en': { from: 'id', to: 'en', architecture: 'tiny', revision: 'spring-2024_Yl0wXq-iQE6G9PpA3AQfcg', bytes: 17141051, params: 16907062, comet: 0.8738, files: { model: 'model.iden.intgemm.alphas.bin', lex: 'lex.50.50.iden.s2t.bin', vocab: 'vocab.iden.spm' } },
103
+ 'is-en': { from: 'is', to: 'en', architecture: 'base-memory', revision: 'docmt-vocab_I4Fy2MnOQHSOT4SYlCjPWw', bytes: 31561787, params: 31248966, comet: 0.8473, files: { model: 'model.isen.intgemm.alphas.bin', lex: 'lex.50.50.isen.s2t.bin', vocab: 'vocab.isen.spm' } },
104
+ 'it-en': { from: 'it', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_d1nPDwVeSD6t-HdtWA4xNg', bytes: 31561787, params: 31248966, comet: 0.8691, files: { model: 'model.iten.intgemm.alphas.bin', lex: 'lex.50.50.iten.s2t.bin', vocab: 'vocab.iten.spm' } },
105
+ 'ja-en': { from: 'ja', to: 'en', architecture: 'base-memory', revision: 'cjk_retrain_base-memory_NLRJLD_pQFyrvgKtbie2nA', bytes: 43977787, params: 43568966, comet: 0.8620, files: { model: 'model.jaen.intgemm.alphas.bin', lex: 'lex.50.50.jaen.s2t.bin', vocab: 'vocab.jaen.spm' } },
106
+ 'kn-en': { from: 'kn', to: 'en', architecture: 'tiny', revision: 'h1-2025_Ql24XjW0Sp-zWsmLrV5TGQ', bytes: 17141051, params: 16907062, comet: 0.8434, files: { model: 'model.knen.intgemm.alphas.bin', lex: 'lex.50.50.knen.s2t.bin', vocab: 'vocab.knen.spm' } },
107
+ 'ko-en': { from: 'ko', to: 'en', architecture: 'base-memory', revision: 'cjk_retrain_base-memory_QgYNtG3BTzKBFSV1wl06Pg', bytes: 43977787, params: 43568966, comet: 0.8635, files: { model: 'model.koen.intgemm.alphas.bin', lex: 'lex.50.50.koen.s2t.bin', vocab: 'vocab.koen.spm' } },
108
+ 'lt-en': { from: 'lt', to: 'en', architecture: 'tiny', revision: 'spring-2024_aAroslw9Ru-c5cam6SvLBg', bytes: 17141051, params: 16907062, comet: 0.8365, files: { model: 'model.lten.intgemm.alphas.bin', lex: 'lex.50.50.lten.s2t.bin', vocab: 'vocab.lten.spm' } },
109
+ 'lv-en': { from: 'lv', to: 'en', architecture: 'tiny', revision: 'spring-2024_fkUrjGNcQiWrTQ5BcYbkgg', bytes: 17141051, params: 16907062, comet: 0.8502, files: { model: 'model.lven.intgemm.alphas.bin', lex: 'lex.50.50.lven.s2t.bin', vocab: 'vocab.lven.spm' } },
110
+ 'ml-en': { from: 'ml', to: 'en', architecture: 'tiny', revision: 'h1-2025_Ahkzk6jNTAut7rz6laKkGQ', bytes: 17141051, params: 16907062, comet: 0.8485, files: { model: 'model.mlen.intgemm.alphas.bin', lex: 'lex.50.50.mlen.s2t.bin', vocab: 'vocab.mlen.spm' } },
111
+ 'mr-en': { from: 'mr', to: 'en', architecture: 'base-memory', revision: 'indictrans2_TZJkvk4_Qy6353ek8nD7cw', bytes: 31561787, params: 31248966, comet: 0.8641, files: { model: 'model.mren.intgemm.alphas.bin', lex: 'lex.50.50.mren.s2t.bin', vocab: 'vocab.mren.spm' } },
112
+ 'ms-en': { from: 'ms', to: 'en', architecture: 'tiny', revision: 'h1-2025_afzwIUAqQRWx5PtvozOHnw', bytes: 17141051, params: 16907062, comet: 0.8658, files: { model: 'model.msen.intgemm.alphas.bin', lex: 'lex.50.50.msen.s2t.bin', vocab: 'vocab.msen.spm' } },
113
+ 'nb-en': { from: 'nb', to: 'en', architecture: 'tiny', revision: 'h1-2025_YKogHXi6Q4es3P7fEWEaBw', bytes: 17141051, params: 16907062, comet: 0.8960, files: { model: 'model.nben.intgemm.alphas.bin', lex: 'lex.50.50.nben.s2t.bin', vocab: 'vocab.nben.spm' } },
114
+ 'nl-en': { from: 'nl', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_JbTCb42HREGvK8d6aOCjFQ', bytes: 31561787, params: 31248966, comet: 0.8655, files: { model: 'model.nlen.intgemm.alphas.bin', lex: 'lex.50.50.nlen.s2t.bin', vocab: 'vocab.nlen.spm' } },
115
+ 'no-en': { from: 'no', to: 'en', architecture: 'tiny', revision: 'h1-2025_YKogHXi6Q4es3P7fEWEaBw', bytes: 17141051, params: 16907062, comet: 0.8960, files: { model: 'model.noen.intgemm.alphas.bin', lex: 'lex.50.50.noen.s2t.bin', vocab: 'vocab.noen.spm' } },
116
+ 'pl-en': { from: 'pl', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_HLLa6ZwsSomB0kyBr7Iz6w', bytes: 31561787, params: 31248966, comet: 0.8469, files: { model: 'model.plen.intgemm.alphas.bin', lex: 'lex.50.50.plen.s2t.bin', vocab: 'vocab.plen.spm' } },
117
+ 'pt-en': { from: 'pt', to: 'en', architecture: 'base-memory', revision: 'retrain_hr_drxrs5bGSsOWvfK9lyZISw', bytes: 31561787, params: 31248966, comet: 0.8871, files: { model: 'model.pten.intgemm.alphas.bin', lex: 'lex.50.50.pten.s2t.bin', vocab: 'vocab.pten.spm' } },
118
+ 'ro-en': { from: 'ro', to: 'en', architecture: 'tiny', revision: 'spring-2024_RwH0W_MDRK2BmZA6VzAmBg', bytes: 17141051, params: 16907062, comet: 0.8773, files: { model: 'model.roen.intgemm.alphas.bin', lex: 'lex.50.50.roen.s2t.bin', vocab: 'vocab.roen.spm' } },
119
+ 'ru-en': { from: 'ru', to: 'en', architecture: 'base-memory', revision: 'next26_RSpwfHrcSUC_rKTnhOEXzw', bytes: 31561787, params: 31248966, comet: 0.8497, files: { model: 'model.ruen.intgemm.alphas.bin', lex: 'lex.50.50.ruen.s2t.bin', vocab: 'vocab.ruen.spm' } },
120
+ 'sk-en': { from: 'sk', to: 'en', architecture: 'tiny', revision: 'spring-2024_TD01UwWXRKacv3wnYeVKbg', bytes: 17141051, params: 16907062, comet: 0.8560, files: { model: 'model.sken.intgemm.alphas.bin', lex: 'lex.50.50.sken.s2t.bin', vocab: 'vocab.sken.spm' } },
121
+ 'sl-en': { from: 'sl', to: 'en', architecture: 'base-memory', revision: 'h1-2025_TCeLyjkQRL2YbTXrUhTlAg', bytes: 31561787, params: 31248966, comet: 0.8601, files: { model: 'model.slen.intgemm.alphas.bin', lex: 'lex.50.50.slen.s2t.bin', vocab: 'vocab.slen.spm' } },
122
+ 'sq-en': { from: 'sq', to: 'en', architecture: 'tiny', revision: 'h1-2025_I8xy7KMeQoe3mMEV3umzfQ', bytes: 17141051, params: 16907062, comet: 0.8623, files: { model: 'model.sqen.intgemm.alphas.bin', lex: 'lex.50.50.sqen.s2t.bin', vocab: 'vocab.sqen.spm' } },
123
+ 'sv-en': { from: 'sv', to: 'en', architecture: 'tiny', revision: 'spring-2024_ObaRXwXeSW6HA_-J5_dE-g', bytes: 17141051, params: 16907062, comet: 0.8855, files: { model: 'model.sven.intgemm.alphas.bin', lex: 'lex.50.50.sven.s2t.bin', vocab: 'vocab.sven.spm' } },
124
+ 'ta-en': { from: 'ta', to: 'en', architecture: 'base-memory', revision: 'next26_dwRqBIcMSDG7drW2_xDIMA', bytes: 31561787, params: 31248966, comet: 0.8425, files: { model: 'model.taen.intgemm.alphas.bin', lex: 'lex.50.50.taen.s2t.bin', vocab: 'vocab.taen.spm' } },
125
+ 'te-en': { from: 'te', to: 'en', architecture: 'tiny', revision: 'h1-2025_YEapi_rWRsSUVTqbBTqupw', bytes: 17141051, params: 16907062, comet: 0.8507, files: { model: 'model.teen.intgemm.alphas.bin', lex: 'lex.50.50.teen.s2t.bin', vocab: 'vocab.teen.spm' } },
126
+ 'th-en': { from: 'th', to: 'en', architecture: 'base-memory', revision: 'new-opuscleaner-en-th_aIiNAAZbRny4ODcYGOMlEA', bytes: 31561787, params: 31248966, comet: 0.8649, files: { model: 'model.then.intgemm.alphas.bin', lex: 'lex.50.50.then.s2t.bin', vocab: 'vocab.then.spm' } },
127
+ 'tr-en': { from: 'tr', to: 'en', architecture: 'tiny', revision: 'statmt_xxxxxxxxRxSxxxxxxxxxxA', bytes: 17140836, params: 16907062, comet: 0.8656, files: { model: 'model.tren.intgemm.alphas.bin', lex: 'lex.50.50.tren.s2t.bin', vocab: 'vocab.tren.spm' } },
128
+ 'uk-en': { from: 'uk', to: 'en', architecture: 'tiny', revision: 'spring-2024_WEPBsc-zQWSDn34b5KFscw', bytes: 17141051, params: 16907062, comet: 0.8463, files: { model: 'model.uken.intgemm.alphas.bin', lex: 'lex.50.50.uken.s2t.bin', vocab: 'vocab.uken.spm' } },
129
+ 'ur-en': { from: 'ur', to: 'en', architecture: 'base-memory', revision: 'indictrans2-bt_UkKC_Ph4SVqxtSbkfmVM2g', bytes: 31561787, params: 31248966, comet: 0.8482, files: { model: 'model.uren.intgemm.alphas.bin', lex: 'lex.50.50.uren.s2t.bin', vocab: 'vocab.uren.spm' } },
130
+ 'vi-en': { from: 'vi', to: 'en', architecture: 'tiny', revision: 'spring-2024_Nc0SHbrgQaiFt4_FmKBXOA', bytes: 17141051, params: 16907062, comet: 0.8487, files: { model: 'model.vien.intgemm.alphas.bin', lex: 'lex.50.50.vien.s2t.bin', vocab: 'vocab.vien.spm' } },
131
+ 'zh-Hant-en': { from: 'zh-Hant', to: 'en', architecture: 'base-memory', revision: 'zh_hant_openlid_zh_tw_lr0002_WJi5Ozi7SZWC6hgfD5GhTA', bytes: 43849787, params: 43536965, comet: 0.8487, files: { model: 'model.zh_hanten.intgemm.alphas.bin', lex: 'lex.50.50.zh_hanten.s2t.bin', srcvocab: 'srcvocab.zh_hanten.spm', trgvocab: 'trgvocab.zh_hanten.spm' } },
132
+ 'zh-en': { from: 'zh', to: 'en', architecture: 'base-memory', revision: 'cjk_retrain_base-memory_cNY_yaJCStGwnTeXgW8A5w', bytes: 43977787, params: 43568966, comet: 0.8596, files: { model: 'model.zhen.intgemm.alphas.bin', lex: 'lex.50.50.zhen.s2t.bin', vocab: 'vocab.zhen.spm' } },
133
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Source of the Web Worker that hosts the Bergamot (Marian) WASM runtime.
3
+ *
4
+ * Kept as a string so the SDK needs no bundler configuration: the main thread turns it into a
5
+ * Blob URL. The worker pulls the emscripten glue and the `.wasm` from `runtimePath` (jsDelivr by
6
+ * default, or a self-hosted copy), receives model files as ArrayBuffers and answers RPC calls.
7
+ *
8
+ * Adapted from `translator-worker.js` in bergamot-translator (MPL-2.0).
9
+ */
10
+ export const WORKER_SOURCE = String.raw`
11
+ 'use strict'
12
+ var Module = {}
13
+ self.Module = Module
14
+
15
+ var GEMM_FALLBACKS = {
16
+ int8_prepare_a: 'int8PrepareAFallback',
17
+ int8_prepare_b: 'int8PrepareBFallback',
18
+ int8_prepare_b_from_transposed: 'int8PrepareBFromTransposedFallback',
19
+ int8_prepare_b_from_quantized_transposed: 'int8PrepareBFromQuantizedTransposedFallback',
20
+ int8_prepare_bias: 'int8PrepareBiasFallback',
21
+ int8_multiply_and_add_bias: 'int8MultiplyAndAddBiasFallback',
22
+ int8_select_columns_of_b: 'int8SelectColumnsOfBFallback',
23
+ }
24
+
25
+ function fallbackGemm() {
26
+ var out = {}
27
+ Object.keys(GEMM_FALLBACKS).forEach(function (name) {
28
+ var target = GEMM_FALLBACKS[name]
29
+ out[name] = function () {
30
+ return Module.asm[target].apply(null, arguments)
31
+ }
32
+ })
33
+ return out
34
+ }
35
+
36
+ var service = null
37
+ var models = new Map()
38
+
39
+ async function init(args) {
40
+ var runtime = args.runtimePath
41
+ var response = await fetch(runtime + 'bergamot-translator-worker.wasm', { credentials: 'omit' })
42
+ if (!response.ok) throw new Error('Bergamot runtime: HTTP ' + response.status + ' for ' + runtime)
43
+
44
+ await new Promise(function (resolve, reject) {
45
+ Module.instantiateWasm = function (info, accept) {
46
+ var imports = Object.assign({}, info, { wasm_gemm: fallbackGemm() })
47
+ ;(async function () {
48
+ try {
49
+ return (await WebAssembly.instantiateStreaming(response.clone(), imports)).instance
50
+ } catch (_) {
51
+ return (await WebAssembly.instantiate(await response.arrayBuffer(), imports)).instance
52
+ }
53
+ })()
54
+ .then(accept)
55
+ .catch(reject)
56
+ return {}
57
+ }
58
+ Module.onRuntimeInitialized = function () {
59
+ resolve()
60
+ }
61
+ Module.onAbort = function (what) {
62
+ reject(new Error('Bergamot runtime aborted: ' + what))
63
+ }
64
+ try {
65
+ importScripts(runtime + 'bergamot-translator-worker.js')
66
+ } catch (err) {
67
+ reject(err)
68
+ }
69
+ })
70
+
71
+ service = new Module.BlockingService({ cacheSize: 0 })
72
+ return true
73
+ }
74
+
75
+ function alignedMemory(buffer, alignment) {
76
+ var bytes = new Int8Array(buffer)
77
+ var memory = new Module.AlignedMemory(bytes.byteLength, alignment)
78
+ memory.getByteArrayView().set(bytes)
79
+ return memory
80
+ }
81
+
82
+ function yaml(config) {
83
+ return Object.keys(config)
84
+ .map(function (key) {
85
+ return key + ': ' + config[key]
86
+ })
87
+ .join('\n') + '\n'
88
+ }
89
+
90
+ function loadModel(args) {
91
+ var key = args.key
92
+ if (models.has(key)) return true
93
+
94
+ var vocabs = new Module.AlignedMemoryList()
95
+ args.vocabs.forEach(function (buffer) {
96
+ vocabs.push_back(alignedMemory(buffer, 64))
97
+ })
98
+
99
+ var config = {
100
+ 'beam-size': 1,
101
+ normalize: 1.0,
102
+ 'word-penalty': 0,
103
+ 'cpu-threads': 0,
104
+ 'gemm-precision': args.modelName.endsWith('intgemm8.bin') ? 'int8shiftAll' : 'int8shiftAlphaAll',
105
+ 'skip-cost': true,
106
+ alignment: 'soft',
107
+ quiet: true,
108
+ 'quiet-translation': true,
109
+ 'max-length-break': 128,
110
+ 'mini-batch-words': 1024,
111
+ workspace: 128,
112
+ 'max-length-factor': 2.0,
113
+ }
114
+
115
+ models.set(
116
+ key,
117
+ new Module.TranslationModel(yaml(config), alignedMemory(args.model, 256), alignedMemory(args.lex, 64), vocabs, null)
118
+ )
119
+ return true
120
+ }
121
+
122
+ function hasModel(args) {
123
+ return models.has(args.key)
124
+ }
125
+
126
+ function freeModel(args) {
127
+ var model = models.get(args.key)
128
+ if (!model) return false
129
+ models.delete(args.key)
130
+ model.delete()
131
+ return true
132
+ }
133
+
134
+ function translate(args) {
135
+ var input = new Module.VectorString()
136
+ args.texts.forEach(function (text) {
137
+ input.push_back(text)
138
+ })
139
+ var options = new Module.VectorResponseOptions()
140
+ args.texts.forEach(function () {
141
+ options.push_back({ alignment: false, html: !!args.html, qualityScores: false })
142
+ })
143
+
144
+ var route = args.route.map(function (key) {
145
+ var model = models.get(key)
146
+ if (!model) throw new Error('Model not loaded: ' + key)
147
+ return model
148
+ })
149
+
150
+ var responses =
151
+ route.length > 1
152
+ ? service.translateViaPivoting(route[0], route[1], input, options)
153
+ : service.translate(route[0], input, options)
154
+
155
+ var out = []
156
+ for (var i = 0; i < args.texts.length; i++) out.push(responses.get(i).getTranslatedText())
157
+
158
+ input.delete()
159
+ options.delete()
160
+ responses.delete()
161
+ return out
162
+ }
163
+
164
+ var handlers = { init: init, loadModel: loadModel, hasModel: hasModel, freeModel: freeModel, translate: translate }
165
+
166
+ self.addEventListener('message', async function (event) {
167
+ var id = event.data.id
168
+ var name = event.data.name
169
+ try {
170
+ var handler = handlers[name]
171
+ if (!handler) throw new TypeError('Unknown worker call: ' + name)
172
+ var result = await handler(event.data.args || {})
173
+ self.postMessage({ id: id, result: result })
174
+ } catch (error) {
175
+ self.postMessage({
176
+ id: id,
177
+ error: { name: error && error.name, message: (error && error.message) || String(error), stack: error && error.stack },
178
+ })
179
+ }
180
+ })
181
+ `
@@ -0,0 +1,220 @@
1
+ import type { Device, ProgressCallback, ProgressInfo, ResolvedDevice } from '../core/index.ts'
2
+ import { disposeKitten, loadKitten, streamKitten, type LoadedKitten } from './kitten.ts'
3
+ import { disposeKokoro, loadKokoro, streamKokoro, type LoadedKokoro } from './kokoro.ts'
4
+ import { disposeSupertonic, loadSupertonic, streamSupertonic, type LoadedSupertonic } from './supertonic.ts'
5
+ import { DEFAULT_TTS_SIZE, type TTSSize } from './sizes.ts'
6
+ import { concatFloat32, float32ToWavBlob } from './wav.ts'
7
+ import { defaultVoiceFor } from './voices.ts'
8
+ import type { SpeakChunk, TTSResult } from './types.ts'
9
+
10
+ export {
11
+ DEFAULT_TTS_SIZE,
12
+ TTS_SIZES,
13
+ type TTSSize,
14
+ } from './sizes.ts'
15
+
16
+ export { SUPERTONIC_LANGUAGES, type SupertonicLanguage } from './supertonic.ts'
17
+
18
+ export {
19
+ DEFAULT_MULTI_VOICE,
20
+ DEFAULT_TINY_VOICE,
21
+ DEFAULT_VOICE,
22
+ TTS_LANGUAGES,
23
+ TTS_VOICE_GROUPS,
24
+ TTS_VOICES,
25
+ defaultVoiceFor,
26
+ getVoice,
27
+ voiceGroupsFor,
28
+ voiceLabel,
29
+ voicesFor,
30
+ type TTSGender,
31
+ type TTSLanguage,
32
+ type TTSLocale,
33
+ type TTSVoice,
34
+ } from './voices.ts'
35
+
36
+ export { float32ToWavBlob } from './wav.ts'
37
+ export type { SpeakChunk, TTSResult }
38
+
39
+ export type TTSOptions = {
40
+ /** `tiny` = KittenTTS (~28 MB). `small` = Kokoro 82M (default). `multi` = Supertonic 2 (5 languages). */
41
+ size?: TTSSize
42
+ /** Hugging Face model id. Kokoro / Supertonic only; ignored for `tiny`. */
43
+ model?: string
44
+ device?: Device
45
+ /** Voice id. Defaults to `af_heart` (small), `bella` (tiny) or `st_f1` (multi). See `TTS_VOICES`. */
46
+ voice?: string
47
+ /** Speaking speed. `1` is natural. */
48
+ speed?: number
49
+ /** Language for `multi` (`en`, `ko`, `es`, `pt`, `fr`). Kokoro / Kitten infer it from the voice. */
50
+ language?: string
51
+ /** Denoising steps for `multi`. Higher is slower and slightly cleaner. Default 5. */
52
+ steps?: number
53
+ onProgress?: ProgressCallback
54
+ }
55
+
56
+ export type SpeakOptions = {
57
+ voice?: string
58
+ speed?: number
59
+ language?: string
60
+ steps?: number
61
+ }
62
+
63
+ /**
64
+ * Text-to-speech that runs entirely in the browser.
65
+ *
66
+ * `small` (default) is Kokoro 82M: WebGPU, English / Spanish / French.
67
+ * `tiny` is KittenTTS nano: ~28 MB, 8 English voices, WASM.
68
+ * `multi` is Supertonic 2: ~262 MB, 44.1 kHz, English / Korean / Spanish / Portuguese / French.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { TextToSpeech } from 'runonweb/tts'
73
+ *
74
+ * const tts = new TextToSpeech({ voice: 'af_heart' })
75
+ * await tts.load()
76
+ * for await (const chunk of tts.speakStream('Hello from the browser')) {
77
+ * console.log(chunk.text, chunk.audio.length)
78
+ * }
79
+ * ```
80
+ */
81
+ export class TextToSpeech {
82
+ #size: TTSSize
83
+ #model?: string
84
+ #device: Device
85
+ #voice: string
86
+ #speed: number
87
+ #language: string
88
+ #steps?: number
89
+ #onProgress?: ProgressCallback
90
+ #kokoro: LoadedKokoro | null = null
91
+ #kitten: LoadedKitten | null = null
92
+ #supertonic: LoadedSupertonic | null = null
93
+ #loading: Promise<void> | null = null
94
+ #resolvedDevice: ResolvedDevice | null = null
95
+
96
+ constructor(options: TTSOptions = {}) {
97
+ this.#size = options.size ?? DEFAULT_TTS_SIZE
98
+ this.#model = options.model
99
+ this.#device = options.device ?? 'auto'
100
+ this.#voice = options.voice ?? defaultVoiceFor(this.#size)
101
+ this.#speed = options.speed ?? 1
102
+ this.#language = options.language ?? 'en'
103
+ this.#steps = options.steps
104
+ this.#onProgress = options.onProgress
105
+ }
106
+
107
+ get size(): TTSSize {
108
+ return this.#size
109
+ }
110
+
111
+ get device(): ResolvedDevice | null {
112
+ return this.#resolvedDevice
113
+ }
114
+
115
+ get voice(): string {
116
+ return this.#voice
117
+ }
118
+
119
+ async load(): Promise<void> {
120
+ if (this.#kokoro || this.#kitten || this.#supertonic) return
121
+ if (this.#loading) return this.#loading
122
+
123
+ this.#loading = this.#loadInternal()
124
+ try {
125
+ await this.#loading
126
+ } finally {
127
+ this.#loading = null
128
+ }
129
+ }
130
+
131
+ async #loadInternal(): Promise<void> {
132
+ if (this.#size === 'tiny') {
133
+ this.#kitten = await loadKitten(this.#onProgress)
134
+ this.#resolvedDevice = 'wasm'
135
+ return
136
+ }
137
+ if (this.#size === 'multi') {
138
+ this.#supertonic = await loadSupertonic({
139
+ model: this.#model,
140
+ device: this.#device,
141
+ onProgress: this.#onProgress,
142
+ })
143
+ this.#resolvedDevice = this.#supertonic.device
144
+ return
145
+ }
146
+ this.#kokoro = await loadKokoro({
147
+ model: this.#model,
148
+ device: this.#device,
149
+ onProgress: this.#onProgress,
150
+ })
151
+ this.#resolvedDevice = this.#kokoro.device
152
+ }
153
+
154
+ /** Yield PCM per sentence so the caller can play audio as it is generated. */
155
+ async *speakStream(text: string, options: SpeakOptions = {}): AsyncGenerator<SpeakChunk> {
156
+ await this.load()
157
+ if (!text.trim()) throw new Error('Text is empty')
158
+
159
+ this.#onProgress?.({ status: 'synthesizing' })
160
+ const voice = options.voice ?? this.#voice
161
+ const speed = options.speed ?? this.#speed
162
+
163
+ const language = options.language ?? this.#language
164
+ const steps = options.steps ?? this.#steps
165
+
166
+ const stream =
167
+ this.#size === 'tiny' && this.#kitten
168
+ ? streamKitten(this.#kitten, text, voice, speed)
169
+ : this.#size === 'multi' && this.#supertonic
170
+ ? streamSupertonic(this.#supertonic, text, voice, speed, language, steps)
171
+ : this.#kokoro
172
+ ? streamKokoro(this.#kokoro, text, voice, speed)
173
+ : null
174
+
175
+ if (!stream) throw new Error('TextToSpeech model failed to load')
176
+
177
+ for await (const chunk of stream) {
178
+ yield chunk
179
+ }
180
+ this.#onProgress?.({ status: 'done' })
181
+ }
182
+
183
+ /** Synthesize speech from text. Returns PCM samples + sample rate. */
184
+ async speak(text: string, options: SpeakOptions = {}): Promise<TTSResult> {
185
+ const chunks: Float32Array[] = []
186
+ let samplingRate = 24_000
187
+ for await (const chunk of this.speakStream(text, options)) {
188
+ chunks.push(chunk.audio)
189
+ samplingRate = chunk.samplingRate
190
+ }
191
+ return { audio: concatFloat32(chunks), samplingRate }
192
+ }
193
+
194
+ /** Synthesize and return a WAV Blob ready for playback / download. */
195
+ async speakToBlob(text: string, options?: SpeakOptions): Promise<Blob> {
196
+ const { audio, samplingRate } = await this.speak(text, options)
197
+ return float32ToWavBlob(audio, samplingRate)
198
+ }
199
+
200
+ dispose(): void {
201
+ disposeKokoro(this.#kokoro)
202
+ disposeKitten(this.#kitten)
203
+ disposeSupertonic(this.#supertonic)
204
+ this.#kokoro = null
205
+ this.#kitten = null
206
+ this.#supertonic = null
207
+ this.#resolvedDevice = null
208
+ }
209
+ }
210
+
211
+ export async function speak(text: string, options?: TTSOptions & SpeakOptions): Promise<TTSResult> {
212
+ const tts = new TextToSpeech(options)
213
+ try {
214
+ return await tts.speak(text, options)
215
+ } finally {
216
+ tts.dispose()
217
+ }
218
+ }
219
+
220
+ export type { ProgressInfo, Device }