echogarden 1.5.0 → 1.6.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.
Files changed (150) hide show
  1. package/data/schemas/options.json +43 -6
  2. package/dist/alignment/DTWMfccSequenceAlignment.d.ts +1 -1
  3. package/dist/alignment/DTWMfccSequenceAlignment.js +5 -5
  4. package/dist/alignment/DTWSequenceAlignmentWindowed.js +1 -3
  5. package/dist/alignment/DTWSequenceAlignmentWindowed.js.map +1 -1
  6. package/dist/alignment/SemanticTextAlignment.js +1 -1
  7. package/dist/alignment/SemanticTextAlignment.js.map +1 -1
  8. package/dist/alignment/SpeechAlignment.d.ts +2 -2
  9. package/dist/alignment/SpeechAlignment.js +26 -3
  10. package/dist/alignment/SpeechAlignment.js.map +1 -1
  11. package/dist/api/API.d.ts +0 -1
  12. package/dist/api/Synthesis.d.ts +0 -1
  13. package/dist/api/TextTranslation.d.ts +21 -1
  14. package/dist/api/TextTranslation.js +99 -2
  15. package/dist/api/TextTranslation.js.map +1 -1
  16. package/dist/api/TimelineTranslationAlignment.js +1 -1
  17. package/dist/api/TimelineTranslationAlignment.js.map +1 -1
  18. package/dist/audio/AudioBufferConversion.d.ts +0 -1
  19. package/dist/audio/AudioPlayer.d.ts +0 -1
  20. package/dist/audio/AudioPlayer.js +62 -41
  21. package/dist/audio/AudioPlayer.js.map +1 -1
  22. package/dist/audio/AudioUtilities.d.ts +0 -1
  23. package/dist/cli/CLI.d.ts +1 -0
  24. package/dist/cli/CLI.js +61 -4
  25. package/dist/cli/CLI.js.map +1 -1
  26. package/dist/codecs/FFMpegTranscoder.d.ts +0 -1
  27. package/dist/codecs/TIMITCodec.d.ts +0 -1
  28. package/dist/codecs/WaveCodec.d.ts +0 -1
  29. package/dist/math/VectorMath.d.ts +4 -4
  30. package/dist/math/VectorMath.js +6 -6
  31. package/dist/nlp/ChineseSegmentation.js +4 -4
  32. package/dist/nlp/ChineseSegmentation.js.map +1 -1
  33. package/dist/nlp/Segmentation.d.ts +2 -2
  34. package/dist/nlp/Segmentation.js +20 -13
  35. package/dist/nlp/Segmentation.js.map +1 -1
  36. package/dist/recognition/OpenAICloudSTT.d.ts +2 -1
  37. package/dist/recognition/OpenAICloudSTT.js +30 -19
  38. package/dist/recognition/OpenAICloudSTT.js.map +1 -1
  39. package/dist/recognition/SileroSTT.d.ts +0 -1
  40. package/dist/recognition/WhisperCppSTT.d.ts +2 -2
  41. package/dist/recognition/WhisperCppSTT.js +19 -7
  42. package/dist/recognition/WhisperCppSTT.js.map +1 -1
  43. package/dist/recognition/WhisperSTT.d.ts +9 -6
  44. package/dist/recognition/WhisperSTT.js +218 -40
  45. package/dist/recognition/WhisperSTT.js.map +1 -1
  46. package/dist/server/Client.d.ts +0 -2
  47. package/dist/server/Worker.d.ts +0 -1
  48. package/dist/source-separation/MDXNetSourceSeparation.d.ts +0 -1
  49. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts +0 -1
  50. package/dist/speech-language-detection/SileroLanguageDetection.d.ts +0 -1
  51. package/dist/subtitles/Subtitles.js +2 -2
  52. package/dist/subtitles/Subtitles.js.map +1 -1
  53. package/dist/synthesis/GoogleCloudTTS.d.ts +0 -1
  54. package/dist/synthesis/GoogleTranslateTTS.d.ts +0 -1
  55. package/dist/synthesis/GoogleTranslateTTS.js +6 -21
  56. package/dist/synthesis/GoogleTranslateTTS.js.map +1 -1
  57. package/dist/synthesis/StreamlabsPollyTTS.d.ts +0 -1
  58. package/dist/synthesis/VitsTTS.d.ts +0 -1
  59. package/dist/synthesis/VitsTTS.js +30 -0
  60. package/dist/synthesis/VitsTTS.js.map +1 -1
  61. package/dist/text-translation/DeepLTextTranslation.d.ts +2 -0
  62. package/dist/text-translation/DeepLTextTranslation.js +67 -0
  63. package/dist/text-translation/DeepLTextTranslation.js.map +1 -0
  64. package/dist/text-translation/GoogleTranslateTextTranslation.d.ts +10 -0
  65. package/dist/text-translation/GoogleTranslateTextTranslation.js +554 -0
  66. package/dist/text-translation/GoogleTranslateTextTranslation.js.map +1 -0
  67. package/dist/text-translation/NLLBTextTranslation.d.ts +2 -1
  68. package/dist/text-translation/NLLBTextTranslation.js +248 -18
  69. package/dist/text-translation/NLLBTextTranslation.js.map +1 -1
  70. package/dist/utilities/BinaryArrayConversion.d.ts +0 -1
  71. package/dist/utilities/BrowserRequestHeaders.d.ts +6 -0
  72. package/dist/utilities/BrowserRequestHeaders.js +52 -0
  73. package/dist/utilities/BrowserRequestHeaders.js.map +1 -0
  74. package/dist/utilities/BufferFileReadStream.d.ts +20 -0
  75. package/dist/utilities/BufferFileReadStream.js +81 -0
  76. package/dist/utilities/BufferFileReadStream.js.map +1 -0
  77. package/dist/utilities/DynamicUint8Array.d.ts +9 -0
  78. package/dist/utilities/DynamicUint8Array.js +31 -0
  79. package/dist/utilities/DynamicUint8Array.js.map +1 -0
  80. package/dist/utilities/FileSystem.d.ts +0 -2
  81. package/dist/utilities/Hashing.d.ts +3 -10
  82. package/dist/utilities/Hashing.js +10 -127
  83. package/dist/utilities/Hashing.js.map +1 -1
  84. package/dist/utilities/LEB128.d.ts +15 -5
  85. package/dist/utilities/LEB128.js +199 -119
  86. package/dist/utilities/LEB128.js.map +1 -1
  87. package/dist/utilities/LPVarInt.d.ts +11 -0
  88. package/dist/utilities/LPVarInt.js +187 -0
  89. package/dist/utilities/LPVarInt.js.map +1 -0
  90. package/dist/utilities/OnnxUtilities.d.ts +0 -1
  91. package/dist/utilities/PVarInt.d.ts +4 -0
  92. package/dist/utilities/PVarInt.js +166 -0
  93. package/dist/utilities/PVarInt.js.map +1 -0
  94. package/dist/utilities/PackageManager.js +43 -22
  95. package/dist/utilities/PackageManager.js.map +1 -1
  96. package/dist/utilities/RandomGenerator.d.ts +3 -17
  97. package/dist/utilities/RandomGenerator.js +12 -81
  98. package/dist/utilities/RandomGenerator.js.map +1 -1
  99. package/dist/utilities/Timeline.d.ts +1 -0
  100. package/dist/utilities/Timeline.js +117 -20
  101. package/dist/utilities/Timeline.js.map +1 -1
  102. package/dist/utilities/Utilities.d.ts +1 -3
  103. package/dist/utilities/Utilities.js +30 -3
  104. package/dist/utilities/Utilities.js.map +1 -1
  105. package/dist/utilities/VarInt.d.ts +4 -0
  106. package/dist/utilities/VarInt.js +166 -0
  107. package/dist/utilities/VarInt.js.map +1 -0
  108. package/dist/utilities/VirtualFileReadStream.d.ts +20 -0
  109. package/dist/utilities/VirtualFileReadStream.js +79 -0
  110. package/dist/utilities/VirtualFileReadStream.js.map +1 -0
  111. package/dist/utilities/WebReader.js +7 -23
  112. package/dist/utilities/WebReader.js.map +1 -1
  113. package/dist/voice-activity-detection/SileroVAD.d.ts +0 -1
  114. package/docs/API.md +24 -0
  115. package/docs/Engines.md +8 -3
  116. package/docs/Options.md +20 -11
  117. package/docs/Tasklist.md +1 -13
  118. package/package.json +20 -24
  119. package/src/alignment/DTWMfccSequenceAlignment.ts +5 -5
  120. package/src/alignment/DTWSequenceAlignmentWindowed.ts +1 -3
  121. package/src/alignment/SemanticTextAlignment.ts +1 -1
  122. package/src/alignment/SpeechAlignment.ts +37 -6
  123. package/src/api/TextTranslation.ts +170 -2
  124. package/src/api/TimelineTranslationAlignment.ts +1 -1
  125. package/src/audio/AudioPlayer.ts +2 -0
  126. package/src/cli/CLI.ts +101 -7
  127. package/src/math/VectorMath.ts +6 -6
  128. package/src/nlp/ChineseSegmentation.ts +6 -4
  129. package/src/nlp/Segmentation.ts +18 -13
  130. package/src/recognition/OpenAICloudSTT.ts +47 -29
  131. package/src/recognition/WhisperCppSTT.ts +24 -9
  132. package/src/recognition/WhisperSTT.ts +354 -43
  133. package/src/subtitles/Subtitles.ts +2 -2
  134. package/src/synthesis/GoogleTranslateTTS.ts +7 -21
  135. package/src/synthesis/VitsTTS.ts +31 -3
  136. package/src/text-translation/DeepLTextTranslation.ts +88 -0
  137. package/src/text-translation/GoogleTranslateTextTranslation.ts +667 -0
  138. package/src/text-translation/NLLBTextTranslation.ts +260 -20
  139. package/src/typings/Fillers.d.ts +25 -2
  140. package/src/utilities/BrowserRequestHeaders.ts +59 -0
  141. package/src/utilities/DynamicUint8Array.ts +39 -0
  142. package/src/utilities/Hashing.ts +14 -167
  143. package/src/utilities/LEB128.ts +273 -148
  144. package/src/utilities/LPVarInt.ts +292 -0
  145. package/src/utilities/PackageManager.ts +45 -27
  146. package/src/utilities/RandomGenerator.ts +12 -113
  147. package/src/utilities/Timeline.ts +148 -23
  148. package/src/utilities/Utilities.ts +40 -3
  149. package/src/utilities/VirtualFileReadStream.ts +109 -0
  150. package/src/utilities/WebReader.ts +9 -23
@@ -10,12 +10,13 @@ import path from 'path';
10
10
  import { formatLanguageCodeWithName, getShortLanguageCode, languageCodeToName } from '../utilities/Locale.js';
11
11
  import { loadPackage } from '../utilities/PackageManager.js';
12
12
  import chalk from 'chalk';
13
- import { XorShift32RNG } from '../utilities/RandomGenerator.js';
13
+ import { XorShift32PRNG } from '../utilities/RandomGenerator.js';
14
14
  import { detectSpeechLanguageByParts } from '../api/SpeechLanguageDetection.js';
15
15
  import { isPunctuation, isWhitespace, isWord, splitToSentences, splitToWords } from '../nlp/Segmentation.js';
16
16
  import { medianOf5Filter } from '../math/MedianFilter.js';
17
17
  import { getDeflateCompressionMetricsForString } from '../utilities/Compression.js';
18
18
  import { getOnnxSessionOptions, makeOnnxLikeFloat32Tensor } from '../utilities/OnnxUtilities.js';
19
+ import { murmurHash3_int32Input } from '../utilities/Hashing.js';
19
20
  export async function recognize(sourceRawAudio, modelName, modelDir, task, sourceLanguage, options) {
20
21
  options = extendDeep(defaultWhisperOptions, options);
21
22
  if (sourceRawAudio.sampleRate != 16000) {
@@ -31,12 +32,16 @@ export async function recognize(sourceRawAudio, modelName, modelDir, task, sourc
31
32
  if (options.temperature && options.temperature < 0) {
32
33
  throw new Error(`Temperature can't be negative`);
33
34
  }
34
- let seed = options.seed;
35
- if (seed) {
36
- seed = Math.max(Math.floor(seed), 1) | 0;
35
+ // Workaround issue with large-v3-turbo that produces invalid results when a prompt is passed to it.
36
+ // Always disable autoprompting for that model.
37
+ if (options.autoPromptParts && modelName == 'large-v3-turbo') {
38
+ options.autoPromptParts = false;
37
39
  }
38
- const encoderProviders = options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu'];
39
- const decoderProviders = options.decoderProvider ? [options.decoderProvider] : [];
40
+ // Select encoder ONNX provider
41
+ const encoderProviders = options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName);
42
+ // Select decoder ONNX provider
43
+ const decoderProviders = options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName);
44
+ const seed = options.seed;
40
45
  const whisper = new Whisper(modelName, modelDir, encoderProviders, decoderProviders, seed);
41
46
  const result = await whisper.recognize(sourceRawAudio, task, sourceLanguage, options);
42
47
  return result;
@@ -53,8 +58,10 @@ export async function align(sourceRawAudio, transcript, modelName, modelDir, sou
53
58
  if (isEnglishOnlyModel(modelName) && sourceLanguage != 'en') {
54
59
  throw new Error(`The model '${modelName}' can only be used with English inputs. However, the given source language was ${languageCodeToName(sourceLanguage)}.`);
55
60
  }
56
- const encoderProviders = options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu'];
57
- const decoderProviders = options.decoderProvider ? [options.decoderProvider] : [];
61
+ // Select encoder ONNX provider
62
+ const encoderProviders = options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName);
63
+ // Select decoder ONNX provider
64
+ const decoderProviders = options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName);
58
65
  const whisper = new Whisper(modelName, modelDir, encoderProviders, decoderProviders);
59
66
  const timeline = await whisper.align(sourceRawAudio, transcript, sourceLanguage, 'transcribe', options);
60
67
  return timeline;
@@ -71,8 +78,10 @@ export async function alignEnglishTranslation(sourceRawAudio, translatedTranscri
71
78
  if (isEnglishOnlyModel(modelName)) {
72
79
  throw new Error(`Translation alignment can only be done with multilingual models.`);
73
80
  }
74
- const encoderProviders = options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu'];
75
- const decoderProviders = options.decoderProvider ? [options.decoderProvider] : [];
81
+ // Select encoder ONNX provider
82
+ const encoderProviders = options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName);
83
+ // Select decoder ONNX provider
84
+ const decoderProviders = options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName);
76
85
  const whisper = new Whisper(modelName, modelDir, encoderProviders, decoderProviders);
77
86
  const timeline = await whisper.align(sourceRawAudio, translatedTranscript, sourceLanguage, 'translate', options);
78
87
  return timeline;
@@ -88,7 +97,9 @@ export async function detectLanguage(sourceRawAudio, modelName, modelDir, option
88
97
  if (options.temperature < 0) {
89
98
  throw new Error(`Temperature cannot be negative`);
90
99
  }
91
- const encoderProviders = options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu'];
100
+ // Select encoder ONNX provider
101
+ const encoderProviders = options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName);
102
+ // Select decoder ONNX provider
92
103
  const decoderProviders = options.decoderProvider ? [options.decoderProvider] : [];
93
104
  const whisper = new Whisper(modelName, modelDir, encoderProviders, decoderProviders);
94
105
  async function detectLanguageForPart(partAudio) {
@@ -111,7 +122,9 @@ export async function detectVoiceActivity(sourceRawAudio, modelName, modelDir, o
111
122
  const audioSamples = sourceRawAudio.audioChannels[0];
112
123
  const partDuration = 5;
113
124
  const maxSamplesCountForPart = sourceRawAudio.sampleRate * partDuration;
114
- const encoderProviders = options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu'];
125
+ // Select encoder ONNX provider
126
+ const encoderProviders = options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName);
127
+ // Select decoder ONNX provider
115
128
  const decoderProviders = options.decoderProvider ? [options.decoderProvider] : [];
116
129
  const whisper = new Whisper(modelName, modelDir, encoderProviders, decoderProviders);
117
130
  const partProbabilities = [];
@@ -143,7 +156,7 @@ export class Whisper {
143
156
  tiktoken;
144
157
  tokenConfig;
145
158
  randomGen;
146
- constructor(modelName, modelDir, encoderExecutionProviders, decoderExecutionProviders, rngSeed = 461845907) {
159
+ constructor(modelName, modelDir, encoderExecutionProviders, decoderExecutionProviders, prngSeed = 1234) {
147
160
  this.modelName = modelName;
148
161
  this.modelDir = modelDir;
149
162
  this.encoderExecutionProviders = encoderExecutionProviders;
@@ -179,7 +192,7 @@ export class Whisper {
179
192
  timestampTokensEnd: 50363 + 1501,
180
193
  };
181
194
  }
182
- this.randomGen = new XorShift32RNG(rngSeed);
195
+ this.randomGen = new XorShift32PRNG(murmurHash3_int32Input(prngSeed));
183
196
  }
184
197
  async recognize(rawAudio, task, language, options, logitFilter) {
185
198
  await this.initializeIfNeeded();
@@ -242,7 +255,11 @@ export class Whisper {
242
255
  partTokensConfidence = partTokensConfidence.slice(initialTokens.length);
243
256
  partCrossAttentionQKs = partCrossAttentionQKs.slice(initialTokens.length);
244
257
  // Find alignment path
245
- const alignmentPath = await this.findAlignmentPathFromQKs(partCrossAttentionQKs, partTokens, 0, segmentFrameCount); //, alignmentHeadsIndexes[this.modelName])
258
+ let alignmentHeads = undefined;
259
+ if (this.modelName.startsWith('small') || this.modelName.startsWith('medium') || this.modelName.startsWith('large')) {
260
+ alignmentHeads = this.alignmentHeadIndexes;
261
+ }
262
+ const alignmentPath = await this.findAlignmentPathFromQKs(partCrossAttentionQKs, partTokens, 0, segmentFrameCount, alignmentHeads);
246
263
  // Generate timeline from alignment path
247
264
  const partTimeline = await this.getTokenTimelineFromAlignmentPath(alignmentPath, partTokens, segmentStartTime, segmentEndTime, partTokensConfidence);
248
265
  // Add tokens to output
@@ -504,14 +521,14 @@ export class Whisper {
504
521
  return false;
505
522
  }
506
523
  // Derive token probabilities
507
- const probabilities = softmax(allTokenLogits, 1.0);
508
- const logProbabilities = logOfVector(probabilities);
509
- const nonTimestampTokenLogProbs = logProbabilities.slice(0, timestampTokensStart);
524
+ const allTokenProbabilities = softmax(allTokenLogits, 1.0);
525
+ const allTokenLogProbabilities = logOfVector(allTokenProbabilities);
526
+ const nonTimestampTokenLogProbs = allTokenLogProbabilities.slice(0, timestampTokensStart);
510
527
  // Find highest non-timestamp token
511
528
  const indexOfMaxNonTimestampLogProb = indexOfMax(nonTimestampTokenLogProbs);
512
529
  const valueOfMaxNonTimestampLogProb = nonTimestampTokenLogProbs[indexOfMaxNonTimestampLogProb];
513
530
  // Find highest timestamp token
514
- const timestampTokenLogProbs = logProbabilities.slice(timestampTokensStart);
531
+ const timestampTokenLogProbs = allTokenLogProbabilities.slice(timestampTokensStart);
515
532
  const indexOfMaxTimestampLogProb = indexOfMax(timestampTokenLogProbs);
516
533
  // Compute the log of the sum of exponentials of the log probabilities
517
534
  // of the timestamp tokens
@@ -534,7 +551,7 @@ export class Whisper {
534
551
  else {
535
552
  // Otherwise decode the highest probability timestamp
536
553
  const timestampToken = timestampTokensStart + indexOfMaxTimestampLogProb;
537
- const confidence = probabilities[timestampToken];
554
+ const confidence = allTokenProbabilities[timestampToken];
538
555
  addToken(timestampToken, timestampTokenLogits, confidence, crossAttentionQKsForToken);
539
556
  }
540
557
  return true;
@@ -715,7 +732,8 @@ export class Whisper {
715
732
  const sampleRate = rawAudio.sampleRate;
716
733
  const fftOrder = 400;
717
734
  const hopLength = 160;
718
- const filterbankCount = 80;
735
+ const filterbankCount = this.filterbankCount;
736
+ const filterbanks = this.filterbanks;
719
737
  const maxAudioSamples = sampleRate * 30;
720
738
  const maxAudioFrames = 3000;
721
739
  if (sampleRate != 16000) {
@@ -1054,7 +1072,7 @@ export class Whisper {
1054
1072
  else if (modelName == 'medium' || modelName == 'medium.en') {
1055
1073
  return [48, groupCount, length, 1024];
1056
1074
  }
1057
- else if (modelName == 'large' || modelName == 'large-v1' || modelName == 'large-v2' || modelName == 'large-v3') {
1075
+ else if (modelName == 'large-v1' || modelName == 'large-v2' || modelName == 'large-v3' || modelName == 'large-v3-turbo') {
1058
1076
  return [64, groupCount, length, 1280];
1059
1077
  }
1060
1078
  else {
@@ -1149,7 +1167,16 @@ export class Whisper {
1149
1167
  get isEnglishOnlyModel() {
1150
1168
  return this.isMultiligualModel === false;
1151
1169
  }
1152
- getAlignmentHeadIndexes() {
1170
+ get isLargeModel() {
1171
+ return this.modelName.startsWith('large');
1172
+ }
1173
+ get filterbankCount() {
1174
+ return this.isLargeModel ? 128 : 80;
1175
+ }
1176
+ get filterbanks() {
1177
+ return this.isLargeModel ? filterbanks_128 : filterbanks_80;
1178
+ }
1179
+ get alignmentHeadIndexes() {
1153
1180
  return alignmentHeadsIndexes[this.modelName];
1154
1181
  }
1155
1182
  getSuppressedTokens() {
@@ -1235,8 +1262,8 @@ export async function loadPackagesAndGetPaths(modelName, languageCode) {
1235
1262
  modelName = 'tiny';
1236
1263
  }
1237
1264
  }
1238
- if (modelName.startsWith('large')) {
1239
- throw new Error(`Large models are not currently supported by the integrated Whisper engine due to model size restrictions of onnxruntime-node. To use large models, you can select the whisper.cpp engine instead.`);
1265
+ if (modelName.startsWith('large') && modelName !== 'large-v3-turbo') {
1266
+ throw new Error(`Models 'large-v1', 'large-v2', 'large-v3' are not currently supported by the integrated Whisper engine due to model size restrictions of onnxruntime-node. To use large models, you can either select large-v3-turbo use the whisper.cpp engine instead.`);
1240
1267
  }
1241
1268
  const packageName = modelNameToPackageName[modelName];
1242
1269
  const modelDir = await loadPackage(packageName);
@@ -1257,6 +1284,27 @@ export function isMultilingualModel(modelName) {
1257
1284
  export function isEnglishOnlyModel(modelName) {
1258
1285
  return modelName.endsWith('.en');
1259
1286
  }
1287
+ function getDefaultEncoderProvidersForModel(modelName) {
1288
+ if (process.platform === 'win32') {
1289
+ return ['dml', 'cpu'];
1290
+ }
1291
+ else {
1292
+ return [];
1293
+ }
1294
+ }
1295
+ function getDefaultDecoderProvidersForModel(modelName) {
1296
+ if (modelName.startsWith('small') || modelName.startsWith('medium') || modelName.startsWith('large')) {
1297
+ if (process.platform === 'win32') {
1298
+ return ['dml', 'cpu'];
1299
+ }
1300
+ else {
1301
+ return [];
1302
+ }
1303
+ }
1304
+ else {
1305
+ return [];
1306
+ }
1307
+ }
1260
1308
  export const modelNameToPackageName = {
1261
1309
  'tiny': 'whisper-tiny',
1262
1310
  'tiny.en': 'whisper-tiny.en',
@@ -1266,10 +1314,10 @@ export const modelNameToPackageName = {
1266
1314
  'small.en': 'whisper-small.en',
1267
1315
  'medium': 'whisper-medium',
1268
1316
  'medium.en': 'whisper-medium.en',
1269
- 'large': 'whisper-large-v3',
1270
1317
  'large-v1': 'whisper-large-v1',
1271
1318
  'large-v2': 'whisper-large-v2',
1272
- 'large-v3': 'whisper-large-v3'
1319
+ 'large-v3': 'whisper-large-v3',
1320
+ 'large-v3-turbo': 'whisper-large-v3-turbo-fp16',
1273
1321
  };
1274
1322
  export const tokenizerPackageName = 'whisper-tokenizer';
1275
1323
  const languageIdLookup = {
@@ -1374,20 +1422,20 @@ const languageIdLookup = {
1374
1422
  'su': 98,
1375
1423
  };
1376
1424
  const alignmentHeadsIndexes = {
1377
- 'tiny.en': [6, 12, 17, 18, 19, 20, 21, 22],
1378
- 'tiny': [14, 18, 20, 21, 22, 23],
1379
- 'base.en': [27, 39, 41, 45, 47],
1380
- 'base': [25, 34, 35, 39, 41, 42, 44, 46],
1381
- 'small.en': [78, 84, 87, 92, 98, 101, 103, 108, 112, 116, 118, 120, 121, 122, 123, 126, 131, 134, 136],
1382
- 'small': [63, 69, 96, 100, 103, 104, 108, 115, 117, 125],
1383
- 'medium.en': [180, 225, 236, 238, 244, 256, 260, 265, 284, 286, 295, 298, 303, 320, 323, 329, 334, 348],
1384
- 'medium': [223, 244, 255, 257, 320, 372],
1385
- 'large-v1': [199, 222, 224, 237, 447, 451, 457, 462, 475],
1386
- 'large-v2': [212, 277, 331, 332, 333, 355, 356, 364, 371, 379, 391, 422, 423, 443, 449, 452, 465, 467, 473, 505, 521, 532, 555],
1387
- 'large-v3': [212, 277, 331, 332, 333, 355, 356, 364, 371, 379, 391, 422, 423, 443, 449, 452, 465, 467, 473, 505, 521, 532, 555], // Temporary (may not be correct)
1388
- 'large': [212, 277, 331, 332, 333, 355, 356, 364, 371, 379, 391, 422, 423, 443, 449, 452, 465, 467, 473, 505, 521, 532, 555],
1425
+ 'tiny.en': [6, 12, 17, 18, 19, 20, 21, 22,],
1426
+ 'tiny': [14, 18, 20, 21, 22, 23,],
1427
+ 'base.en': [27, 39, 41, 45, 47,],
1428
+ 'base': [25, 34, 35, 39, 41, 42, 44, 46,],
1429
+ 'small.en': [78, 84, 87, 92, 98, 101, 103, 108, 112, 116, 118, 120, 121, 122, 123, 126, 131, 134, 136,],
1430
+ 'small': [63, 69, 96, 100, 103, 104, 108, 115, 117, 125,],
1431
+ 'medium.en': [180, 225, 236, 238, 244, 256, 260, 265, 284, 286, 295, 298, 303, 320, 323, 329, 334, 348,],
1432
+ 'medium': [223, 244, 255, 257, 320, 372,],
1433
+ 'large-v1': [199, 222, 224, 237, 447, 451, 457, 462, 475,],
1434
+ 'large-v2': [212, 277, 331, 332, 333, 355, 356, 364, 371, 379, 391, 422, 423, 443, 449, 452, 465, 467, 473, 505, 521, 532, 555,],
1435
+ 'large-v3': [140, 217, 258, 272, 321, 354, 391, 424, 481, 506,],
1436
+ 'large-v3-turbo': [44, 51, 63, 66, 71, 74,],
1389
1437
  };
1390
- const filterbanks = [
1438
+ const filterbanks_80 = [
1391
1439
  /* 0 */ { startIndex: 1, weights: [0.02486259490251541,] },
1392
1440
  /* 1 */ { startIndex: 1, weights: [0.001990821911022067, 0.022871771827340126,] },
1393
1441
  /* 2 */ { startIndex: 2, weights: [0.003981643822044134, 0.02088095061480999,] },
@@ -1469,6 +1517,136 @@ const filterbanks = [
1469
1517
  /* 78 */ { startIndex: 179, weights: [0.0003849811910185963, 0.0008885387214832008, 0.001392096164636314, 0.0018956535495817661, 0.00239921105094254, 0.002902768552303314, 0.0034063260536640882, 0.003132763085886836, 0.0026481777895241976, 0.0021635922603309155, 0.0016790067311376333, 0.0011944210855290294, 0.0007098356145434082, 0.00022525011445395648,] },
1470
1518
  /* 79 */ { startIndex: 186, weights: [0.000366741674952209, 0.0008330700220540166, 0.0012993983691558242, 0.0017657268326729536, 0.0022320549469441175, 0.002698383294045925, 0.0031647118739783764, 0.003141313325613737, 0.002692554146051407, 0.0022437951993197203, 0.00179503601975739, 0.0013462770730257034, 0.000897518009878695, 0.0004487590049393475,] },
1471
1519
  ];
1520
+ const filterbanks_128 = [
1521
+ /* 0 */ { startIndex: 1, weights: [0.012373986653983593,] },
1522
+ /* 1 */ { startIndex: 1, weights: [0.030392564833164215,] },
1523
+ /* 2 */ { startIndex: 2, weights: [0.024747973307967186,] },
1524
+ /* 3 */ { startIndex: 2, weights: [0.018018579110503197,] },
1525
+ /* 4 */ { startIndex: 3, weights: [0.037121959030628204,] },
1526
+ /* 5 */ { startIndex: 3, weights: [0.005644591990858316, 0.006729394197463989,] },
1527
+ /* 6 */ { startIndex: 4, weights: [0.03603715822100639,] },
1528
+ /* 7 */ { startIndex: 5, weights: [0.019103379920125008,] },
1529
+ /* 8 */ { startIndex: 5, weights: [0.023663168773055077,] },
1530
+ /* 9 */ { startIndex: 6, weights: [0.031477365642786026,] },
1531
+ /* 10 */ { startIndex: 6, weights: [0.011289183981716633, 0.0010848019737750292,] },
1532
+ /* 11 */ { startIndex: 7, weights: [0.04168175160884857,] },
1533
+ /* 12 */ { startIndex: 8, weights: [0.013458788394927979,] },
1534
+ /* 13 */ { startIndex: 8, weights: [0.029307762160897255,] },
1535
+ /* 14 */ { startIndex: 9, weights: [0.025832774117588997,] },
1536
+ /* 15 */ { startIndex: 9, weights: [0.016933776438236237,] },
1537
+ /* 16 */ { startIndex: 10, weights: [0.038206759840250015,] },
1538
+ /* 17 */ { startIndex: 10, weights: [0.004559790249913931, 0.007814195938408375,] },
1539
+ /* 18 */ { startIndex: 11, weights: [0.03495235741138458,] },
1540
+ /* 19 */ { startIndex: 12, weights: [0.020188182592391968,] },
1541
+ /* 20 */ { startIndex: 12, weights: [0.022578367963433266,] },
1542
+ /* 21 */ { startIndex: 13, weights: [0.032562170177698135,] },
1543
+ /* 22 */ { startIndex: 13, weights: [0.010204383172094822, 0.0021696039475500584,] },
1544
+ /* 23 */ { startIndex: 14, weights: [0.04059694707393646,] },
1545
+ /* 24 */ { startIndex: 15, weights: [0.01454358920454979,] },
1546
+ /* 25 */ { startIndex: 15, weights: [0.028222959488630295,] },
1547
+ /* 26 */ { startIndex: 16, weights: [0.026917576789855957,] },
1548
+ /* 27 */ { startIndex: 16, weights: [0.015848975628614426,] },
1549
+ /* 28 */ { startIndex: 17, weights: [0.039291560649871826,] },
1550
+ /* 29 */ { startIndex: 17, weights: [0.0034749882761389017, 0.008898998610675335,] },
1551
+ /* 30 */ { startIndex: 18, weights: [0.03386755287647247,] },
1552
+ /* 31 */ { startIndex: 19, weights: [0.021272985264658928,] },
1553
+ /* 32 */ { startIndex: 19, weights: [0.021493567153811455,] },
1554
+ /* 33 */ { startIndex: 20, weights: [0.033646970987319946,] },
1555
+ /* 34 */ { startIndex: 20, weights: [0.009119580499827862, 0.003254405688494444,] },
1556
+ /* 35 */ { startIndex: 21, weights: [0.03951214626431465,] },
1557
+ /* 36 */ { startIndex: 22, weights: [0.01562839187681675,] },
1558
+ /* 37 */ { startIndex: 22, weights: [0.027138158679008484,] },
1559
+ /* 38 */ { startIndex: 23, weights: [0.028002377599477768,] },
1560
+ /* 39 */ { startIndex: 23, weights: [0.014764172956347466,] },
1561
+ /* 40 */ { startIndex: 24, weights: [0.040376365184783936,] },
1562
+ /* 41 */ { startIndex: 24, weights: [0.0023806870449334383, 0.010202637873589993,] },
1563
+ /* 42 */ { startIndex: 25, weights: [0.03161146119236946,] },
1564
+ /* 43 */ { startIndex: 26, weights: [0.024547001346945763,] },
1565
+ /* 44 */ { startIndex: 26, weights: [0.015329193323850632, 0.001665837480686605,] },
1566
+ /* 45 */ { startIndex: 27, weights: [0.036729052662849426,] },
1567
+ /* 46 */ { startIndex: 28, weights: [0.020097099244594574,] },
1568
+ /* 47 */ { startIndex: 28, weights: [0.016931025311350822, 0.0029026553966104984,] },
1569
+ /* 48 */ { startIndex: 29, weights: [0.032844990491867065,] },
1570
+ /* 49 */ { startIndex: 30, weights: [0.023520048707723618,] },
1571
+ /* 50 */ { startIndex: 30, weights: [0.011038944125175476, 0.010725829750299454,] },
1572
+ /* 51 */ { startIndex: 31, weights: [0.022718291729688644,] },
1573
+ /* 52 */ { startIndex: 32, weights: [0.03227872774004936,] },
1574
+ /* 53 */ { startIndex: 32, weights: [0.00011626833293121308, 0.022853482514619827,] },
1575
+ /* 54 */ { startIndex: 33, weights: [0.008563440293073654, 0.014979788102209568,] },
1576
+ /* 55 */ { startIndex: 34, weights: [0.015513983555138111, 0.008514906279742718,] },
1577
+ /* 56 */ { startIndex: 35, weights: [0.02110680378973484, 0.003326520323753357,] },
1578
+ /* 57 */ { startIndex: 36, weights: [0.02547064796090126,] },
1579
+ /* 58 */ { startIndex: 37, weights: [0.02735907956957817,] },
1580
+ /* 59 */ { startIndex: 37, weights: [0.0006585361552424729, 0.02383812516927719,] },
1581
+ /* 60 */ { startIndex: 38, weights: [0.0034435924608260393, 0.021224552765488625,] },
1582
+ /* 61 */ { startIndex: 39, weights: [0.0053584217093884945, 0.019425557926297188,] },
1583
+ /* 62 */ { startIndex: 40, weights: [0.006493247114121914, 0.018355421721935272,] },
1584
+ /* 63 */ { startIndex: 41, weights: [0.006931380834430456, 0.017935046926140785,] },
1585
+ /* 64 */ { startIndex: 42, weights: [0.0067496825940907, 0.018091518431901932,] },
1586
+ /* 65 */ { startIndex: 43, weights: [0.006018991116434336, 0.018757672980427742,] },
1587
+ /* 66 */ { startIndex: 44, weights: [0.004804528318345547, 0.019871728494763374,] },
1588
+ /* 67 */ { startIndex: 45, weights: [0.0031662785913795233, 0.02137690968811512, 0.001253173453733325,] },
1589
+ /* 68 */ { startIndex: 46, weights: [0.0011593446834012866, 0.02080361731350422, 0.004044868052005768,] },
1590
+ /* 69 */ { startIndex: 48, weights: [0.017553631216287613, 0.007083200383931398,] },
1591
+ /* 70 */ { startIndex: 49, weights: [0.014075386337935925, 0.010326550342142582,] },
1592
+ /* 71 */ { startIndex: 50, weights: [0.010409214533865452, 0.013736963272094727,] },
1593
+ /* 72 */ { startIndex: 51, weights: [0.006591876968741417, 0.017279881983995438, 0.0014680421445518732,] },
1594
+ /* 73 */ { startIndex: 52, weights: [0.0026568188332021236, 0.01809193193912506, 0.005856557283550501,] },
1595
+ /* 74 */ { startIndex: 54, weights: [0.013342779129743576, 0.010282675735652447,] },
1596
+ /* 75 */ { startIndex: 55, weights: [0.00856800377368927, 0.01472230814397335, 0.001040398608893156,] },
1597
+ /* 76 */ { startIndex: 56, weights: [0.003790855873376131, 0.01714678481221199, 0.006116092670708895,] },
1598
+ /* 77 */ { startIndex: 58, weights: [0.011759290471673012, 0.011133937165141106,] },
1599
+ /* 78 */ { startIndex: 59, weights: [0.006438578478991985, 0.01607806235551834, 0.004239172209054232,] },
1600
+ /* 79 */ { startIndex: 60, weights: [0.0011998937698081136, 0.012756715528666973, 0.00965298991650343,] },
1601
+ /* 80 */ { startIndex: 62, weights: [0.007069352548569441, 0.014940546825528145, 0.004190248437225819,] },
1602
+ /* 81 */ { startIndex: 63, weights: [0.0015148338861763477, 0.012008999474346638, 0.009848233312368393,] },
1603
+ /* 82 */ { startIndex: 65, weights: [0.006102240178734064, 0.01533857174217701, 0.005576768424361944,] },
1604
+ /* 83 */ { startIndex: 66, weights: [0.00036827256553806365, 0.00989749375730753, 0.011353404261171818, 0.0020512230694293976,] },
1605
+ /* 84 */ { startIndex: 68, weights: [0.003892971435561776, 0.012973522767424583, 0.00806631613522768,] },
1606
+ /* 85 */ { startIndex: 70, weights: [0.006744932383298874, 0.013858746737241745, 0.005411905236542225,] },
1607
+ /* 86 */ { startIndex: 71, weights: [0.0007422015769407153, 0.008987790904939175, 0.011378713883459568, 0.003329580882564187,] },
1608
+ /* 87 */ { startIndex: 73, weights: [0.0028231353498995304, 0.010680492967367172, 0.00943340640515089, 0.0017632555682212114,] },
1609
+ /* 88 */ { startIndex: 75, weights: [0.0043901861645281315, 0.011877589859068394, 0.007970058359205723, 0.0006610470009036362,] },
1610
+ /* 89 */ { startIndex: 77, weights: [0.005494666751474142, 0.012629535980522633, 0.00693987961858511,] },
1611
+ /* 90 */ { startIndex: 79, weights: [0.006184019148349762, 0.0129347313195467, 0.00629778765141964,] },
1612
+ /* 91 */ { startIndex: 80, weights: [2.3252101527759805e-05, 0.006502066273242235, 0.0123266177251935, 0.006002165377140045,] },
1613
+ /* 92 */ { startIndex: 82, weights: [0.00031548753031529486, 0.006489255465567112, 0.012041302397847176, 0.006014628801494837,] },
1614
+ /* 93 */ { startIndex: 84, weights: [0.00029979555984027684, 0.006182880140841007, 0.012042728252708912, 0.006299811881035566, 0.0005568959750235081,] },
1615
+ /* 94 */ { startIndex: 86, weights: [1.1204706424905453e-05, 0.005617291666567326, 0.011223378591239452, 0.0068251630291342735, 0.0013526449911296368,] },
1616
+ /* 95 */ { startIndex: 89, weights: [0.004824100062251091, 0.010166232474148273, 0.007560755126178265, 0.002345903078094125,] },
1617
+ /* 96 */ { startIndex: 91, weights: [0.003832357469946146, 0.008922962471842766, 0.00847910437732935, 0.003509786445647478,] },
1618
+ /* 97 */ { startIndex: 93, weights: [0.0026687318459153175, 0.007519651670008898, 0.009555005468428135, 0.004819661378860474, 8.431751484749839e-05,] },
1619
+ /* 98 */ { startIndex: 95, weights: [0.001357673667371273, 0.005980195011943579, 0.01060271542519331, 0.0062529849819839, 0.0017405991675332189,] },
1620
+ /* 99 */ { startIndex: 98, weights: [0.004326442256569862, 0.008731318637728691, 0.007789165247231722, 0.003489238675683737,] },
1621
+ /* 100 */ { startIndex: 100, weights: [0.0025783509481698275, 0.006775828544050455, 0.00940941646695137, 0.005311945918947458, 0.0012144759530201554,] },
1622
+ /* 101 */ { startIndex: 102, weights: [0.0007541119121015072, 0.004753957036882639, 0.008753802627325058, 0.007192090153694153, 0.003287544008344412,] },
1623
+ /* 102 */ { startIndex: 105, weights: [0.0026817969046533108, 0.0064933146350085735, 0.009114579297602177, 0.005393873900175095, 0.0016731682699173689,] },
1624
+ /* 103 */ { startIndex: 107, weights: [0.0005739429616369307, 0.0042060003615915775, 0.007838058285415173, 0.007520230021327734, 0.003974708262830973, 0.00042918731924146414,] },
1625
+ /* 104 */ { startIndex: 110, weights: [0.0019046447705477476, 0.005365691613405943, 0.008826738223433495, 0.0062760948203504086, 0.0028975096065551043,] },
1626
+ /* 105 */ { startIndex: 113, weights: [0.0028988525737076998, 0.006196940783411264, 0.008566990494728088, 0.005347481928765774, 0.002127972897142172,] },
1627
+ /* 106 */ { startIndex: 115, weights: [0.0004475022724363953, 0.0035903039388358593, 0.006733105983585119, 0.007770236115902662, 0.004702313803136349, 0.0016343912575393915,] },
1628
+ /* 107 */ { startIndex: 118, weights: [0.0010153602343052626, 0.004010187461972237, 0.007005014456808567, 0.007234429940581322, 0.0043109566904604435, 0.0013874832075089216,] },
1629
+ /* 108 */ { startIndex: 121, weights: [0.0013334885006770492, 0.004187308251857758, 0.007041127886623144, 0.0069318837486207485, 0.004146058112382889, 0.0013602323597297072,] },
1630
+ /* 109 */ { startIndex: 124, weights: [0.0014287971425801516, 0.004148248583078384, 0.006867699790745974, 0.006837052758783102, 0.004182394593954086, 0.0015277357306331396,] },
1631
+ /* 110 */ { startIndex: 127, weights: [0.0013261043932288885, 0.003917513880878687, 0.006508923601359129, 0.006926396861672401, 0.0043967291712760925, 0.0018670617137104273,] },
1632
+ /* 111 */ { startIndex: 130, weights: [0.0010482777142897248, 0.0035176740493625402, 0.0059870705008506775, 0.007178240455687046, 0.004767679143697023, 0.002357117598876357,] },
1633
+ /* 112 */ { startIndex: 133, weights: [0.0006163640646263957, 0.0029694922268390656, 0.005322620272636414, 0.007572650909423828, 0.005275587551295757, 0.0029785241931676865, 0.0006814609514549375,] },
1634
+ /* 113 */ { startIndex: 136, weights: [4.9713995394995436e-05, 0.0022920481860637665, 0.004534382373094559, 0.006776716560125351, 0.0059024072252213955, 0.00371349835768342, 0.0015245892573148012,] },
1635
+ /* 114 */ { startIndex: 140, weights: [0.0015028533525764942, 0.0036396104842424393, 0.005776367150247097, 0.0066315908916294575, 0.004545743577182293, 0.002459896495565772, 0.00037404923932626843,] },
1636
+ /* 115 */ { startIndex: 143, weights: [0.0006179586052894592, 0.00265410915017128, 0.004690259229391813, 0.006726410239934921, 0.005460347048938274, 0.0034727093297988176, 0.0014850713778287172,] },
1637
+ /* 116 */ { startIndex: 147, weights: [0.001592335756868124, 0.0035326166544109583, 0.005472897551953793, 0.0064436825923621655, 0.004549629986286163, 0.002655577613040805, 0.0007615251233801246,] },
1638
+ /* 117 */ { startIndex: 150, weights: [0.00046749351895414293, 0.0023164190351963043, 0.004165344405919313, 0.0060142697766423225, 0.005678446963429451, 0.0038735736161470413, 0.002068700036033988, 0.0002638266596477479,] },
1639
+ /* 118 */ { startIndex: 154, weights: [0.0010534910252317786, 0.002815362298861146, 0.0045772334560751915, 0.006339104846119881, 0.0051281568594276905, 0.0034082632046192884, 0.0016883700154721737,] },
1640
+ /* 119 */ { startIndex: 158, weights: [0.0014335009036585689, 0.0031124167144298553, 0.00479133240878582, 0.00640943692997098, 0.004770522005856037, 0.0031316077802330256, 0.0014926930889487267,] },
1641
+ /* 120 */ { startIndex: 161, weights: [2.9323589842533693e-05, 0.001629189937375486, 0.003229056019335985, 0.00482892245054245, 0.006146714556962252, 0.004584966227412224, 0.0030232176650315523, 0.0014614691026508808,] },
1642
+ /* 121 */ { startIndex: 165, weights: [0.00013601698447018862, 0.001660555717535317, 0.003185094567015767, 0.004709633067250252, 0.006040723994374275, 0.0045525087043643, 0.003064292948693037, 0.001576077425852418, 8.786193211562932e-05,] },
1643
+ /* 122 */ { startIndex: 169, weights: [9.328097075922415e-05, 0.001546038780361414, 0.002998796757310629, 0.004451554734259844, 0.0059043122455477715, 0.0046556610614061356, 0.003237516153603792, 0.0018193712458014488, 0.00040122633799910545,] },
1644
+ /* 123 */ { startIndex: 174, weights: [0.0013026263331994414, 0.002686982974410057, 0.004071339499205351, 0.005455696024000645, 0.004878324922174215, 0.0035269514191895723, 0.0021755779162049294, 0.0008242045878432691,] },
1645
+ /* 124 */ { startIndex: 178, weights: [0.0009459502762183547, 0.002265126211568713, 0.0035843022633343935, 0.0049034785479307175, 0.005205697845667601, 0.0039179520681500435, 0.00263020652346313, 0.001342460629530251, 5.471494296216406e-05,] },
1646
+ /* 125 */ { startIndex: 182, weights: [0.0004903789376839995, 0.0017474433407187462, 0.003004507627338171, 0.004261571913957596, 0.005518636200577021, 0.004397072363644838, 0.0031699584797024727, 0.001942844595760107, 0.0007157306536100805,] },
1647
+ /* 126 */ { startIndex: 187, weights: [0.0011469805613160133, 0.002344857668504119, 0.0035427347756922245, 0.004740611650049686, 0.0049519846215844154, 0.003782647429034114, 0.002613310469314456, 0.0014439737424254417, 0.0002746368118096143,] },
1648
+ /* 127 */ { startIndex: 191, weights: [0.0004756950947921723, 0.0016171716852113605, 0.002758648479357362, 0.0039001251570880413, 0.005041601601988077, 0.004457120783627033, 0.003342840587720275, 0.0022285603918135166, 0.0011142801959067583,] },
1649
+ ];
1472
1650
  export const defaultWhisperOptions = {
1473
1651
  model: undefined,
1474
1652
  temperature: 0.1,