-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
util.ts
642 lines (636 loc) · 19.4 KB
/
util.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { tmpdir } from 'os';
import { lstat } from 'fs/promises';
import { mkdirp } from 'mkdirp';
type Model = {
"language": string
"url": string
"name": string
"label": string
"size": number
"notes": string
"type": string
}
export const videoExtensions = ["mp4", "mov", "mkv", "avi", "webm"];
export const audioExtensions = [
"wav",
"mp3",
"ogg",
"flac",
"aac",
"wma",
"m4a",
];
export const __filename = fileURLToPath(import.meta.url);
export const __dirname = dirname(__filename);
export const workingDir = join(tmpdir(), "gen-subs")
export const getModelDir = async () => {
try {
await lstat(join(workingDir, "models"))
return join(workingDir, "models")
} catch {
await mkdirp(join(workingDir, "models"))
return join(workingDir, "models")
}
}
export const isModelDownloaded = async (name: string) => {
return await lstat(join(workingDir, "models", name))
.then(() => true)
.catch(() => false);
}
export const formatSize = (size: number) => {
if (size < 1024) {
return size + 'MB';
} else {
// Divide by 1024 and fix to 2 decimal places
return (size / 1024).toFixed(2) + 'GB';
}
}
export const models: Model[] = [
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip",
"name": "vosk-model-small-en-us-0.15",
"label": "small-en-us-0.15",
"size": 40,
"notes": "Lightweight wideband model for Android and RPi",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-0.22.zip",
"name": "vosk-model-en-us-0.22",
"label": "en-us-0.22",
"size": 1800,
"notes": "Accurate generic US English model",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-0.22-lgraph.zip",
"name": "vosk-model-en-us-0.22-lgraph",
"label": "en-us-0.22-lgraph",
"size": 128,
"notes": "Big US English model with dynamic graph",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-0.42-gigaspeech.zip",
"name": "vosk-model-en-us-0.42-gigaspeech",
"label": "en-us-0.42-gigaspeech",
"size": 2300,
"notes": "Accurate generic US English model trained by Kaldi on Gigaspeech. Mostly for podcasts, not for telephony",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-daanzu-20200905.zip",
"name": "vosk-model-en-us-daanzu-20200905",
"label": "en-us-daanzu-20200905",
"size": 1000,
"notes": "Wideband model for dictation from Kaldi-active-grammar project",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-daanzu-20200905-lgraph.zip",
"name": "vosk-model-en-us-daanzu-20200905-lgraph",
"label": "en-us-daanzu-20200905-lgraph",
"size": 129,
"notes": "Wideband model for dictation from Kaldi-active-grammar project with configurable graph",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-librispeech-0.2.zip",
"name": "vosk-model-en-us-librispeech-0.2",
"label": "en-us-librispeech-0.2",
"size": 845,
"notes": "Repackaged Librispeech model from Kaldi, not very accurate",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-en-us-zamia-0.5.zip",
"name": "vosk-model-small-en-us-zamia-0.5",
"label": "small-en-us-zamia-0.5",
"size": 49,
"notes": "Repackaged Zamia model f_250, mainly for research",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-aspire-0.2.zip",
"name": "vosk-model-en-us-aspire-0.2",
"label": "en-us-aspire-0.2",
"size": 1400,
"notes": "Kaldi original ASPIRE model, not very accurate",
"type": "local"
},
{
"language": "English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-us-0.21.zip",
"name": "vosk-model-en-us-0.21",
"label": "en-us-0.21",
"size": 1600,
"notes": "Wideband model previous generation",
"type": "local"
},
{
"language": "Indian English",
"url": "https://alphacephei.com/vosk/models/vosk-model-en-in-0.5.zip",
"name": "vosk-model-en-in-0.5",
"label": "en-in-0.5",
"size": 1000,
"notes": "Generic Indian English model for telecom and broadcast",
"type": "local"
},
{
"language": "Indian English",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-en-in-0.4.zip",
"name": "vosk-model-small-en-in-0.4",
"label": "small-en-in-0.4",
"size": 36,
"notes": "Lightweight Indian English model for mobile applications",
"type": "local"
},
{
"language": "Chinese",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-cn-0.22.zip",
"name": "vosk-model-small-cn-0.22",
"label": "small-cn-0.22",
"size": 42,
"notes": "Lightweight model for Android and RPi",
"type": "local"
},
{
"language": "Chinese",
"url": "https://alphacephei.com/vosk/models/vosk-model-cn-0.22.zip",
"name": "vosk-model-cn-0.22",
"label": "cn-0.22",
"size": 1300,
"notes": "Big generic Chinese model for server processing",
"type": "local"
},
{
"language": "Chinese",
"url": "https://alphacephei.com/vosk/models/vosk-model-cn-kaldi-multicn-0.15.zip",
"name": "vosk-model-cn-kaldi-multicn-0.15",
"label": "cn-kaldi-multicn-0.15",
"size": 1500,
"notes": "Original Wideband Kaldi multi-cn model from Kaldi with Vosk LM",
"type": "local"
},
{
"language": "Russian",
"url": "https://alphacephei.com/vosk/models/vosk-model-ru-0.42.zip",
"name": "vosk-model-ru-0.42",
"label": "ru-0.42",
"size": 1800,
"notes": "Big mixed band Russian model for servers",
"type": "local"
},
{
"language": "Russian",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-ru-0.22.zip",
"name": "vosk-model-small-ru-0.22",
"label": "small-ru-0.22",
"size": 45,
"notes": "Lightweight wideband model for Android/iOS and RPi",
"type": "local"
},
{
"language": "Russian",
"url": "https://alphacephei.com/vosk/models/vosk-model-ru-0.22.zip",
"name": "vosk-model-ru-0.22",
"label": "ru-0.22",
"size": 1500,
"notes": "Big mixed band Russian model for servers",
"type": "local"
},
{
"language": "Russian",
"url": "https://alphacephei.com/vosk/models/vosk-model-ru-0.10.zip",
"name": "vosk-model-ru-0.10",
"label": "ru-0.10",
"size": 2500,
"notes": "Big narrowband Russian model for servers",
"type": "local"
},
{
"language": "French",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-fr-0.22.zip",
"name": "vosk-model-small-fr-0.22",
"label": "small-fr-0.22",
"size": 41,
"notes": "Lightweight wideband model for Android/iOS and RPi",
"type": "local"
},
{
"language": "French",
"url": "https://alphacephei.com/vosk/models/vosk-model-fr-0.22.zip",
"name": "vosk-model-fr-0.22",
"label": "fr-0.22",
"size": 1400,
"notes": "Big accurate model for servers",
"type": "local"
},
{
"language": "French",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-fr-pguyot-0.3.zip",
"name": "vosk-model-small-fr-pguyot-0.3",
"label": "small-fr-pguyot-0.3",
"size": 39,
"notes": "Lightweight wideband model for Android and RPi trained by Paul Guyot",
"type": "local"
},
{
"language": "French",
"url": "https://alphacephei.com/vosk/models/vosk-model-fr-0.6-linto-2.2.0.zip",
"name": "vosk-model-fr-0.6-linto-2.2.0",
"label": "fr-0.6-linto-2.2.0",
"size": 1500,
"notes": "Model from LINTO project",
"type": "local"
},
{
"language": "German",
"url": "https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip",
"name": "vosk-model-de-0.21",
"label": "de-0.21",
"size": 1900,
"notes": "Big German model for telephony and server",
"type": "local"
},
{
"language": "German",
"url": "https://alphacephei.com/vosk/models/vosk-model-de-tuda-0.6-900k.zip",
"name": "vosk-model-de-tuda-0.6-900k",
"label": "de-tuda-0.6-900k",
"size": 4400,
"notes": "Latest big wideband model from Tuda-DE project",
"type": "local"
},
{
"language": "German",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-de-zamia-0.3.zip",
"name": "vosk-model-small-de-zamia-0.3",
"label": "small-de-zamia-0.3",
"size": 49,
"notes": "Zamia f_250 small model repackaged (not recommended)",
"type": "local"
},
{
"language": "German",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-de-0.15.zip",
"name": "vosk-model-small-de-0.15",
"label": "small-de-0.15",
"size": 45,
"notes": "Lightweight wideband model for Android and RPi",
"type": "local"
},
{
"language": "Spanish",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-es-0.42.zip",
"name": "vosk-model-small-es-0.42",
"label": "small-es-0.42",
"size": 39,
"notes": "Lightweight wideband model for Android and RPi",
"type": "local"
},
{
"language": "Spanish",
"url": "https://alphacephei.com/vosk/models/vosk-model-es-0.42.zip",
"name": "vosk-model-es-0.42",
"label": "es-0.42",
"size": 1400,
"notes": "Big model for Spanish",
"type": "local"
},
{
"language": "Portuguese/Brazilian",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-pt-0.3.zip",
"name": "vosk-model-small-pt-0.3",
"label": "small-pt-0.3",
"size": 31,
"notes": "Lightweight wideband model for Android and RPi",
"type": "local"
},
{
"language": "Portuguese/Brazilian",
"url": "https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-20220516_2113.zip",
"name": "vosk-model-pt-fb-v0.1.1-20220516_2113",
"label": "pt-fb-v0.1.1-20220516_2113",
"size": 1600,
"notes": "Big model from FalaBrazil",
"type": "local"
},
{
"language": "Greek",
"url": "https://alphacephei.com/vosk/models/vosk-model-el-gr-0.7.zip",
"name": "vosk-model-el-gr-0.7",
"label": "el-gr-0.7",
"size": 1100,
"notes": "Big narrowband Greek model for server processing, not extremely accurate though",
"type": "local"
},
{
"language": "Turkish",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-tr-0.3.zip",
"name": "vosk-model-small-tr-0.3",
"label": "small-tr-0.3",
"size": 35,
"notes": "Lightweight wideband model for Android and RPi",
"type": "local"
},
{
"language": "Vietnamese",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-vn-0.4.zip",
"name": "vosk-model-small-vn-0.4",
"label": "small-vn-0.4",
"size": 32,
"notes": "Lightweight Vietnamese model",
"type": "local"
},
{
"language": "Vietnamese",
"url": "https://alphacephei.com/vosk/models/vosk-model-vn-0.4.zip",
"name": "vosk-model-vn-0.4",
"label": "vn-0.4",
"size": 78,
"notes": "Bigger Vietnamese model for server",
"type": "local"
},
{
"language": "Italian",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-it-0.22.zip",
"name": "vosk-model-small-it-0.22",
"label": "small-it-0.22",
"size": 48,
"notes": "Lightweight model for Android and RPi",
"type": "local"
},
{
"language": "Italian",
"url": "https://alphacephei.com/vosk/models/vosk-model-it-0.22.zip",
"name": "vosk-model-it-0.22",
"label": "it-0.22",
"size": 1200,
"notes": "Big generic Italian model for servers",
"type": "local"
},
{
"language": "Dutch",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-nl-0.22.zip",
"name": "vosk-model-small-nl-0.22",
"label": "small-nl-0.22",
"size": 39,
"notes": "Lightweight model for Dutch",
"type": "local"
},
{
"language": "Dutch",
"url": "https://alphacephei.com/vosk/models/vosk-model-nl-spraakherkenning-0.6.zip",
"name": "vosk-model-nl-spraakherkenning-0.6",
"label": "nl-spraakherkenning-0.6",
"size": 860,
"notes": "Medium Dutch model from Kaldi_NL",
"type": "local"
},
{
"language": "Dutch",
"url": "https://alphacephei.com/vosk/models/vosk-model-nl-spraakherkenning-0.6-lgraph.zip",
"name": "vosk-model-nl-spraakherkenning-0.6-lgraph",
"label": "nl-spraakherkenning-0.6-lgraph",
"size": 100,
"notes": "Smaller model with dynamic graph",
"type": "local"
},
{
"language": "Catalan",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-ca-0.4.zip",
"name": "vosk-model-small-ca-0.4",
"label": "small-ca-0.4",
"size": 42,
"notes": "Lightweight wideband model for Android and RPi for Catalan",
"type": "local"
},
{
"language": "Arabic",
"url": "https://alphacephei.com/vosk/models/vosk-model-ar-mgb2-0.4.zip",
"name": "vosk-model-ar-mgb2-0.4",
"label": "ar-mgb2-0.4",
"size": 318,
"notes": "Repackaged Arabic model trained on MGB2 dataset from Kaldi",
"type": "local"
},
{
"language": "Arabic",
"url": "https://alphacephei.com/vosk/models/vosk-model-ar-0.22-linto-1.1.0.zip",
"name": "vosk-model-ar-0.22-linto-1.1.0",
"label": "ar-0.22-linto-1.1.0",
"size": 1300,
"notes": "Big model from LINTO project",
"type": "local"
},
{
"language": "Farsi",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-fa-0.4.zip",
"name": "vosk-model-small-fa-0.4",
"label": "small-fa-0.4",
"size": 47,
"notes": "Lightweight wideband model for Android and RPi for Farsi (Persian)",
"type": "local"
},
{
"language": "Farsi",
"url": "https://alphacephei.com/vosk/models/vosk-model-fa-0.5.zip",
"name": "vosk-model-fa-0.5",
"label": "fa-0.5",
"size": 1000,
"notes": "Model with large vocabulary, not yet accurate but better than before (Persian)",
"type": "local"
},
{
"language": "Farsi",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-fa-0.5.zip",
"name": "vosk-model-small-fa-0.5",
"label": "small-fa-0.5",
"size": 60,
"notes": "Bigger small model for desktop application (Persian)",
"type": "local"
},
{
"language": "Filipino",
"url": "https://alphacephei.com/vosk/models/vosk-model-tl-ph-generic-0.6.zip",
"name": "vosk-model-tl-ph-generic-0.6",
"label": "tl-ph-generic-0.6",
"size": 320,
"notes": "Medium wideband model for Filipino (Tagalog) by feddybear",
"type": "local"
},
{
"language": "Ukrainian",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-uk-v3-nano.zip",
"name": "vosk-model-small-uk-v3-nano",
"label": "small-uk-v3-nano",
"size": 73,
"notes": "Nano model from Speech Recognition for Ukrainian",
"type": "local"
},
{
"language": "Ukrainian",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-uk-v3-small.zip",
"name": "vosk-model-small-uk-v3-small",
"label": "small-uk-v3-small",
"size": 133,
"notes": "Small model from Speech Recognition for Ukrainian",
"type": "local"
},
{
"language": "Ukrainian",
"url": "https://alphacephei.com/vosk/models/vosk-model-uk-v3.zip",
"name": "vosk-model-uk-v3",
"label": "uk-v3",
"size": 343,
"notes": "Bigger model from Speech Recognition for Ukrainian",
"type": "local"
},
{
"language": "Ukrainian",
"url": "https://alphacephei.com/vosk/models/vosk-model-uk-v3-lgraph.zip",
"name": "vosk-model-uk-v3-lgraph",
"label": "uk-v3-lgraph",
"size": 325,
"notes": "Big dynamic model from Speech Recognition for Ukrainian",
"type": "local"
},
{
"language": "Kazakh",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-kz-0.15.zip",
"name": "vosk-model-small-kz-0.15",
"label": "small-kz-0.15",
"size": 42,
"notes": "Small mobile model from SAIDA_Kazakh",
"type": "local"
},
{
"language": "Kazakh",
"url": "https://alphacephei.com/vosk/models/vosk-model-kz-0.15.zip",
"name": "vosk-model-kz-0.15",
"label": "kz-0.15",
"size": 378,
"notes": "Bigger wideband model SAIDA_Kazakh",
"type": "local"
},
{
"language": "Swedish",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-sv-rhasspy-0.15.zip",
"name": "vosk-model-small-sv-rhasspy-0.15",
"label": "small-sv-rhasspy-0.15",
"size": 289,
"notes": "Repackaged model from Rhasspy project",
"type": "local"
},
{
"language": "Japanese",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-ja-0.22.zip",
"name": "vosk-model-small-ja-0.22",
"label": "small-ja-0.22",
"size": 48,
"notes": "Lightweight wideband model for Japanese",
"type": "local"
},
{
"language": "Japanese",
"url": "https://alphacephei.com/vosk/models/vosk-model-ja-0.22.zip",
"name": "vosk-model-ja-0.22",
"label": "ja-0.22",
"size": 1024,
"notes": "Big model for Japanese",
"type": "local"
},
{
"language": "Esperanto",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-eo-0.42.zip",
"name": "vosk-model-small-eo-0.42",
"label": "small-eo-0.42",
"size": 42,
"notes": "Lightweight model for Esperanto",
"type": "local"
},
{
"language": "Hindi",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-hi-0.22.zip",
"name": "vosk-model-small-hi-0.22",
"label": "small-hi-0.22",
"size": 42,
"notes": "Lightweight model for Hindi",
"type": "local"
},
{
"language": "Hindi",
"url": "https://alphacephei.com/vosk/models/vosk-model-hi-0.22.zip",
"name": "vosk-model-hi-0.22",
"label": "hi-0.22",
"size": 1536,
"notes": "Big accurate model for servers",
"type": "local"
},
{
"language": "Czech",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-cs-0.4-rhasspy.zip",
"name": "vosk-model-small-cs-0.4-rhasspy",
"label": "small-cs-0.4-rhasspy",
"size": 44,
"notes": "Lightweight model for Czech from Rhasspy project",
"type": "local"
},
{
"language": "Polish",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-pl-0.22.zip",
"name": "vosk-model-small-pl-0.22",
"label": "small-pl-0.22",
"size": 50,
"notes": "Lightweight model for Polish",
"type": "local"
},
{
"language": "Uzbek",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-uz-0.22.zip",
"name": "vosk-model-small-uz-0.22",
"label": "small-uz-0.22",
"size": 49,
"notes": "Lightweight model for Uzbek",
"type": "local"
},
{
"language": "Korean",
"url": "https://alphacephei.com/vosk/models/vosk-model-small-ko-0.22.zip",
"name": "vosk-model-small-ko-0.22",
"label": "small-ko-0.22",
"size": 82,
"notes": "Lightweight model for Korean",
"type": "local"
},
{
"language": "Breton",
"url": "https://alphacephei.com/vosk/models/vosk-model-br-0.8.zip",
"name": "vosk-model-br-0.8",
"label": "br-0.8",
"size": 70,
"notes": "Breton model from vosk-br project",
"type": "local"
},
{
"language": "Speaker identification model",
"url": "https://alphacephei.com/vosk/models/vosk-model-spk-0.4.zip",
"name": "vosk-model-spk-0.4",
"label": "spk-0.4",
"size": 13,
"notes": "Model for speaker identification, should work for all languages",
"type": "local"
}
];