echogarden 1.4.4 → 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 (240) hide show
  1. package/data/schemas/options.json +310 -25
  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/{TextAlignment.d.ts → SemanticTextAlignment.d.ts} +4 -2
  7. package/dist/alignment/SemanticTextAlignment.js +336 -0
  8. package/dist/alignment/SemanticTextAlignment.js.map +1 -0
  9. package/dist/alignment/SpeechAlignment.d.ts +4 -3
  10. package/dist/alignment/SpeechAlignment.js +130 -39
  11. package/dist/alignment/SpeechAlignment.js.map +1 -1
  12. package/dist/api/API.d.ts +7 -3
  13. package/dist/api/API.js +7 -2
  14. package/dist/api/API.js.map +1 -1
  15. package/dist/api/APIOptions.d.ts +4 -1
  16. package/dist/api/Alignment.d.ts +1 -1
  17. package/dist/api/Alignment.js +13 -5
  18. package/dist/api/Alignment.js.map +1 -1
  19. package/dist/api/LanguageDetectionCommon.d.ts +6 -0
  20. package/dist/api/LanguageDetectionCommon.js +2 -0
  21. package/dist/api/LanguageDetectionCommon.js.map +1 -0
  22. package/dist/api/Recognition.js.map +1 -1
  23. package/dist/api/{LanguageDetection.d.ts → SpeechLanguageDetection.d.ts} +1 -25
  24. package/dist/api/{LanguageDetection.js → SpeechLanguageDetection.js} +1 -68
  25. package/dist/api/SpeechLanguageDetection.js.map +1 -0
  26. package/dist/api/{Translation.js → SpeechTranslation.js} +3 -3
  27. package/dist/api/SpeechTranslation.js.map +1 -0
  28. package/dist/api/Synthesis.d.ts +0 -1
  29. package/dist/api/Synthesis.js +4 -4
  30. package/dist/api/TextLanguageDetection.d.ts +21 -0
  31. package/dist/api/TextLanguageDetection.js +67 -0
  32. package/dist/api/TextLanguageDetection.js.map +1 -0
  33. package/dist/api/TextTranslation.d.ts +25 -0
  34. package/dist/api/TextTranslation.js +101 -0
  35. package/dist/api/TextTranslation.js.map +1 -0
  36. package/dist/api/TimelineTranslationAlignment.d.ts +23 -0
  37. package/dist/api/TimelineTranslationAlignment.js +92 -0
  38. package/dist/api/TimelineTranslationAlignment.js.map +1 -0
  39. package/dist/api/TranscriptAndTranslationAlignment.d.ts +35 -0
  40. package/dist/api/TranscriptAndTranslationAlignment.js +78 -0
  41. package/dist/api/TranscriptAndTranslationAlignment.js.map +1 -0
  42. package/dist/api/TranslationAlignment.d.ts +4 -3
  43. package/dist/api/TranslationAlignment.js +9 -8
  44. package/dist/api/TranslationAlignment.js.map +1 -1
  45. package/dist/api/VoiceActivityDetection.js +16 -1
  46. package/dist/api/VoiceActivityDetection.js.map +1 -1
  47. package/dist/audio/AudioBufferConversion.d.ts +0 -1
  48. package/dist/audio/AudioPlayer.d.ts +0 -1
  49. package/dist/audio/AudioPlayer.js +62 -41
  50. package/dist/audio/AudioPlayer.js.map +1 -1
  51. package/dist/audio/AudioUtilities.d.ts +0 -1
  52. package/dist/cli/CLI.d.ts +28 -7
  53. package/dist/cli/CLI.js +265 -37
  54. package/dist/cli/CLI.js.map +1 -1
  55. package/dist/codecs/FFMpegTranscoder.d.ts +0 -1
  56. package/dist/codecs/FFMpegTranscoder.js +7 -0
  57. package/dist/codecs/FFMpegTranscoder.js.map +1 -1
  58. package/dist/codecs/TIMITCodec.d.ts +0 -1
  59. package/dist/codecs/WaveCodec.d.ts +0 -1
  60. package/dist/dsp/FFT.d.ts +1 -1
  61. package/dist/dsp/FFT.js +6 -0
  62. package/dist/dsp/FFT.js.map +1 -1
  63. package/dist/dsp/KWeightingFilter.js +1 -1
  64. package/dist/dsp/KWeightingFilter.js.map +1 -1
  65. package/dist/dsp/MelSpectogram.d.ts +3 -2
  66. package/dist/dsp/MelSpectogram.js +14 -8
  67. package/dist/dsp/MelSpectogram.js.map +1 -1
  68. package/dist/math/VectorMath.d.ts +9 -9
  69. package/dist/math/VectorMath.js +10 -10
  70. package/dist/math/VectorMath.js.map +1 -1
  71. package/dist/nlp/ChineseSegmentation.js +4 -4
  72. package/dist/nlp/ChineseSegmentation.js.map +1 -1
  73. package/dist/nlp/Segmentation.d.ts +2 -2
  74. package/dist/nlp/Segmentation.js +20 -13
  75. package/dist/nlp/Segmentation.js.map +1 -1
  76. package/dist/recognition/OpenAICloudSTT.d.ts +2 -1
  77. package/dist/recognition/OpenAICloudSTT.js +30 -19
  78. package/dist/recognition/OpenAICloudSTT.js.map +1 -1
  79. package/dist/recognition/SileroSTT.d.ts +0 -1
  80. package/dist/recognition/WhisperCppSTT.d.ts +3 -3
  81. package/dist/recognition/WhisperCppSTT.js +21 -9
  82. package/dist/recognition/WhisperCppSTT.js.map +1 -1
  83. package/dist/recognition/WhisperSTT.d.ts +9 -6
  84. package/dist/recognition/WhisperSTT.js +227 -46
  85. package/dist/recognition/WhisperSTT.js.map +1 -1
  86. package/dist/server/Client.d.ts +3 -4
  87. package/dist/server/Client.js.map +1 -1
  88. package/dist/server/Worker.d.ts +3 -3
  89. package/dist/server/Worker.js +3 -2
  90. package/dist/server/Worker.js.map +1 -1
  91. package/dist/source-separation/MDXNetSourceSeparation.d.ts +0 -1
  92. package/dist/source-separation/MDXNetSourceSeparation.js +1 -1
  93. package/dist/source-separation/MDXNetSourceSeparation.js.map +1 -1
  94. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts +12 -0
  95. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js +68 -0
  96. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js.map +1 -0
  97. package/dist/speech-language-detection/SileroLanguageDetection.d.ts +1 -2
  98. package/dist/speech-language-detection/SileroLanguageDetection.js +1 -1
  99. package/dist/speech-language-detection/SileroLanguageDetection.js.map +1 -1
  100. package/dist/subtitles/Subtitles.js +2 -2
  101. package/dist/subtitles/Subtitles.js.map +1 -1
  102. package/dist/synthesis/GoogleCloudTTS.d.ts +0 -1
  103. package/dist/synthesis/GoogleTranslateTTS.d.ts +0 -1
  104. package/dist/synthesis/GoogleTranslateTTS.js +6 -21
  105. package/dist/synthesis/GoogleTranslateTTS.js.map +1 -1
  106. package/dist/synthesis/StreamlabsPollyTTS.d.ts +0 -1
  107. package/dist/synthesis/VitsTTS.d.ts +0 -1
  108. package/dist/synthesis/VitsTTS.js +30 -0
  109. package/dist/synthesis/VitsTTS.js.map +1 -1
  110. package/dist/tests/Test.js +0 -31
  111. package/dist/tests/Test.js.map +1 -1
  112. package/dist/text-language-detection/FastTextLanguageDetection.d.ts +1 -1
  113. package/dist/text-language-detection/FastTextLanguageDetection.js.map +1 -1
  114. package/dist/text-language-detection/TinyLDLanguageDetection.d.ts +1 -1
  115. package/dist/text-language-detection/TinyLDLanguageDetection.js.map +1 -1
  116. package/dist/text-translation/DeepLTextTranslation.d.ts +2 -0
  117. package/dist/text-translation/DeepLTextTranslation.js +67 -0
  118. package/dist/text-translation/DeepLTextTranslation.js.map +1 -0
  119. package/dist/text-translation/GoogleTranslateTextTranslation.d.ts +10 -0
  120. package/dist/text-translation/GoogleTranslateTextTranslation.js +554 -0
  121. package/dist/text-translation/GoogleTranslateTextTranslation.js.map +1 -0
  122. package/dist/text-translation/NLLBTextTranslation.d.ts +2 -1
  123. package/dist/text-translation/NLLBTextTranslation.js +249 -19
  124. package/dist/text-translation/NLLBTextTranslation.js.map +1 -1
  125. package/dist/utilities/BinaryArrayConversion.d.ts +0 -1
  126. package/dist/utilities/BrowserRequestHeaders.d.ts +6 -0
  127. package/dist/utilities/BrowserRequestHeaders.js +52 -0
  128. package/dist/utilities/BrowserRequestHeaders.js.map +1 -0
  129. package/dist/utilities/BufferFileReadStream.d.ts +20 -0
  130. package/dist/utilities/BufferFileReadStream.js +81 -0
  131. package/dist/utilities/BufferFileReadStream.js.map +1 -0
  132. package/dist/utilities/DynamicUint8Array.d.ts +9 -0
  133. package/dist/utilities/DynamicUint8Array.js +31 -0
  134. package/dist/utilities/DynamicUint8Array.js.map +1 -0
  135. package/dist/utilities/FileSystem.d.ts +0 -2
  136. package/dist/utilities/Hashing.d.ts +3 -10
  137. package/dist/utilities/Hashing.js +10 -127
  138. package/dist/utilities/Hashing.js.map +1 -1
  139. package/dist/utilities/LEB128.d.ts +15 -5
  140. package/dist/utilities/LEB128.js +199 -119
  141. package/dist/utilities/LEB128.js.map +1 -1
  142. package/dist/utilities/LPVarInt.d.ts +11 -0
  143. package/dist/utilities/LPVarInt.js +187 -0
  144. package/dist/utilities/LPVarInt.js.map +1 -0
  145. package/dist/utilities/Locale.d.ts +1 -1
  146. package/dist/utilities/Locale.js +1 -1
  147. package/dist/utilities/OnnxUtilities.d.ts +1 -2
  148. package/dist/utilities/PVarInt.d.ts +4 -0
  149. package/dist/utilities/PVarInt.js +166 -0
  150. package/dist/utilities/PVarInt.js.map +1 -0
  151. package/dist/utilities/PackageManager.js +48 -25
  152. package/dist/utilities/PackageManager.js.map +1 -1
  153. package/dist/utilities/RandomGenerator.d.ts +3 -17
  154. package/dist/utilities/RandomGenerator.js +12 -81
  155. package/dist/utilities/RandomGenerator.js.map +1 -1
  156. package/dist/utilities/Timeline.d.ts +2 -0
  157. package/dist/utilities/Timeline.js +129 -20
  158. package/dist/utilities/Timeline.js.map +1 -1
  159. package/dist/utilities/Utilities.d.ts +1 -3
  160. package/dist/utilities/Utilities.js +30 -3
  161. package/dist/utilities/Utilities.js.map +1 -1
  162. package/dist/utilities/VarInt.d.ts +4 -0
  163. package/dist/utilities/VarInt.js +166 -0
  164. package/dist/utilities/VarInt.js.map +1 -0
  165. package/dist/utilities/VirtualFileReadStream.d.ts +20 -0
  166. package/dist/utilities/VirtualFileReadStream.js +79 -0
  167. package/dist/utilities/VirtualFileReadStream.js.map +1 -0
  168. package/dist/utilities/WebReader.js +7 -23
  169. package/dist/utilities/WebReader.js.map +1 -1
  170. package/dist/voice-activity-detection/SileroVAD.d.ts +0 -1
  171. package/docs/API.md +105 -3
  172. package/docs/CLI.md +51 -1
  173. package/docs/Engines.md +32 -3
  174. package/docs/Options.md +53 -12
  175. package/docs/Tasklist.md +1 -13
  176. package/package.json +20 -24
  177. package/src/alignment/DTWMfccSequenceAlignment.ts +5 -5
  178. package/src/alignment/DTWSequenceAlignmentWindowed.ts +1 -3
  179. package/src/alignment/SemanticTextAlignment.ts +467 -0
  180. package/src/alignment/SpeechAlignment.ts +214 -56
  181. package/src/api/API.ts +18 -2
  182. package/src/api/APIOptions.ts +14 -1
  183. package/src/api/Alignment.ts +31 -9
  184. package/src/api/LanguageDetectionCommon.ts +7 -0
  185. package/src/api/Recognition.ts +2 -0
  186. package/src/api/{LanguageDetection.ts → SpeechLanguageDetection.ts} +1 -119
  187. package/src/api/{Translation.ts → SpeechTranslation.ts} +2 -2
  188. package/src/api/Synthesis.ts +4 -4
  189. package/src/api/TextLanguageDetection.ts +116 -0
  190. package/src/api/TextTranslation.ts +177 -0
  191. package/src/api/TimelineTranslationAlignment.ts +162 -0
  192. package/src/api/TranscriptAndTranslationAlignment.ts +164 -0
  193. package/src/api/TranslationAlignment.ts +12 -10
  194. package/src/api/VoiceActivityDetection.ts +24 -3
  195. package/src/audio/AudioPlayer.ts +2 -0
  196. package/src/cli/CLI.ts +376 -40
  197. package/src/codecs/FFMpegTranscoder.ts +6 -0
  198. package/src/dsp/FFT.ts +8 -2
  199. package/src/dsp/KWeightingFilter.ts +1 -1
  200. package/src/dsp/MelSpectogram.ts +17 -8
  201. package/src/math/VectorMath.ts +15 -15
  202. package/src/nlp/ChineseSegmentation.ts +6 -4
  203. package/src/nlp/Segmentation.ts +18 -13
  204. package/src/recognition/OpenAICloudSTT.ts +47 -29
  205. package/src/recognition/WhisperCppSTT.ts +26 -11
  206. package/src/recognition/WhisperSTT.ts +364 -49
  207. package/src/server/Client.ts +3 -2
  208. package/src/server/Worker.ts +3 -2
  209. package/src/source-separation/MDXNetSourceSeparation.ts +1 -1
  210. package/src/speech-embeddings/WavToVec2BertFeatureEmbeddings.ts +107 -0
  211. package/src/speech-language-detection/SileroLanguageDetection.ts +2 -1
  212. package/src/subtitles/Subtitles.ts +2 -2
  213. package/src/synthesis/GoogleTranslateTTS.ts +7 -21
  214. package/src/synthesis/VitsTTS.ts +31 -3
  215. package/src/tests/Test.ts +1 -38
  216. package/src/text-language-detection/FastTextLanguageDetection.ts +1 -1
  217. package/src/text-language-detection/TinyLDLanguageDetection.ts +1 -1
  218. package/src/text-translation/DeepLTextTranslation.ts +88 -0
  219. package/src/text-translation/GoogleTranslateTextTranslation.ts +667 -0
  220. package/src/text-translation/NLLBTextTranslation.ts +261 -21
  221. package/src/typings/Fillers.d.ts +25 -2
  222. package/src/utilities/BrowserRequestHeaders.ts +59 -0
  223. package/src/utilities/DynamicUint8Array.ts +39 -0
  224. package/src/utilities/Hashing.ts +14 -167
  225. package/src/utilities/LEB128.ts +273 -148
  226. package/src/utilities/LPVarInt.ts +292 -0
  227. package/src/utilities/Locale.ts +1 -1
  228. package/src/utilities/OnnxUtilities.ts +1 -1
  229. package/src/utilities/PackageManager.ts +51 -30
  230. package/src/utilities/RandomGenerator.ts +12 -113
  231. package/src/utilities/Timeline.ts +162 -23
  232. package/src/utilities/Utilities.ts +40 -3
  233. package/src/utilities/VirtualFileReadStream.ts +109 -0
  234. package/src/utilities/WebReader.ts +9 -23
  235. package/dist/alignment/TextAlignment.js +0 -156
  236. package/dist/alignment/TextAlignment.js.map +0 -1
  237. package/dist/api/LanguageDetection.js.map +0 -1
  238. package/dist/api/Translation.js.map +0 -1
  239. package/src/alignment/TextAlignment.ts +0 -234
  240. /package/dist/api/{Translation.d.ts → SpeechTranslation.d.ts} +0 -0
@@ -16,13 +16,14 @@ import type { LanguageDetectionResults } from '../api/API.js'
16
16
  import { formatLanguageCodeWithName, getShortLanguageCode, languageCodeToName } from '../utilities/Locale.js'
17
17
  import { loadPackage } from '../utilities/PackageManager.js'
18
18
  import chalk from 'chalk'
19
- import { XorShift32RNG } from '../utilities/RandomGenerator.js'
20
- import { detectSpeechLanguageByParts } from '../api/LanguageDetection.js'
19
+ import { XorShift32PRNG } from '../utilities/RandomGenerator.js'
20
+ import { detectSpeechLanguageByParts } from '../api/SpeechLanguageDetection.js'
21
21
  import { type Tiktoken } from 'tiktoken/lite'
22
22
  import { isPunctuation, isWhitespace, isWord, splitToSentences, splitToWords } from '../nlp/Segmentation.js'
23
23
  import { medianOf5Filter } from '../math/MedianFilter.js'
24
24
  import { getDeflateCompressionMetricsForString } from '../utilities/Compression.js'
25
25
  import { getOnnxSessionOptions, makeOnnxLikeFloat32Tensor, OnnxExecutionProvider, OnnxLikeFloat32Tensor } from '../utilities/OnnxUtilities.js'
26
+ import { murmurHash3_int32Input } from '../utilities/Hashing.js'
26
27
 
27
28
  export async function recognize(
28
29
  sourceRawAudio: RawAudio,
@@ -35,7 +36,7 @@ export async function recognize(
35
36
  options = extendDeep(defaultWhisperOptions, options)
36
37
 
37
38
  if (sourceRawAudio.sampleRate != 16000) {
38
- throw new Error('Source audio must have a sampling rate of 16000 Hz')
39
+ throw new Error('Source audio must have a sample rate of 16000 Hz')
39
40
  }
40
41
 
41
42
  sourceLanguage = getShortLanguageCode(sourceLanguage)
@@ -52,17 +53,21 @@ export async function recognize(
52
53
  throw new Error(`Temperature can't be negative`)
53
54
  }
54
55
 
55
- let seed = options.seed
56
-
57
- if (seed) {
58
- seed = Math.max(Math.floor(seed), 1) | 0
56
+ // Workaround issue with large-v3-turbo that produces invalid results when a prompt is passed to it.
57
+ // Always disable autoprompting for that model.
58
+ if (options.autoPromptParts && modelName == 'large-v3-turbo') {
59
+ options.autoPromptParts = false
59
60
  }
60
61
 
62
+ // Select encoder ONNX provider
61
63
  const encoderProviders: OnnxExecutionProvider[] =
62
- options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu']
64
+ options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName)
63
65
 
66
+ // Select decoder ONNX provider
64
67
  const decoderProviders: OnnxExecutionProvider[] =
65
- options.decoderProvider ? [options.decoderProvider] : []
68
+ options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName)
69
+
70
+ const seed = options.seed
66
71
 
67
72
  const whisper = new Whisper(
68
73
  modelName,
@@ -87,7 +92,7 @@ export async function align(
87
92
  options = extendDeep(defaultWhisperAlignmentOptions, options)
88
93
 
89
94
  if (sourceRawAudio.sampleRate != 16000) {
90
- throw new Error('Source audio must have a sampling rate of 16000')
95
+ throw new Error('Source audio must have a sample rate of 16000 Hz')
91
96
  }
92
97
 
93
98
  sourceLanguage = getShortLanguageCode(sourceLanguage)
@@ -100,11 +105,13 @@ export async function align(
100
105
  throw new Error(`The model '${modelName}' can only be used with English inputs. However, the given source language was ${languageCodeToName(sourceLanguage)}.`)
101
106
  }
102
107
 
108
+ // Select encoder ONNX provider
103
109
  const encoderProviders: OnnxExecutionProvider[] =
104
- options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu']
110
+ options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName)
105
111
 
112
+ // Select decoder ONNX provider
106
113
  const decoderProviders: OnnxExecutionProvider[] =
107
- options.decoderProvider ? [options.decoderProvider] : []
114
+ options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName)
108
115
 
109
116
  const whisper = new Whisper(
110
117
  modelName,
@@ -128,7 +135,7 @@ export async function alignEnglishTranslation(
128
135
  options = extendDeep(defaultWhisperAlignmentOptions, options)
129
136
 
130
137
  if (sourceRawAudio.sampleRate != 16000) {
131
- throw new Error('Source audio must have a sampling rate of 16000')
138
+ throw new Error('Source audio must have a sample rate of 16000 Hz')
132
139
  }
133
140
 
134
141
  sourceLanguage = getShortLanguageCode(sourceLanguage)
@@ -141,11 +148,13 @@ export async function alignEnglishTranslation(
141
148
  throw new Error(`Translation alignment can only be done with multilingual models.`)
142
149
  }
143
150
 
151
+ // Select encoder ONNX provider
144
152
  const encoderProviders: OnnxExecutionProvider[] =
145
- options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu']
153
+ options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName)
146
154
 
155
+ // Select decoder ONNX provider
147
156
  const decoderProviders: OnnxExecutionProvider[] =
148
- options.decoderProvider ? [options.decoderProvider] : []
157
+ options.decoderProvider ? [options.decoderProvider] : getDefaultDecoderProvidersForModel(modelName)
149
158
 
150
159
  const whisper = new Whisper(
151
160
  modelName,
@@ -167,7 +176,7 @@ export async function detectLanguage(
167
176
  options = extendDeep(defaultWhisperLanguageDetectionOptions, options)
168
177
 
169
178
  if (sourceRawAudio.sampleRate != 16000) {
170
- throw new Error('Source audio must have a sampling rate of 16000')
179
+ throw new Error('Source audio must have a sample rate of 16000 Hz')
171
180
  }
172
181
 
173
182
  if (!isMultilingualModel(modelName)) {
@@ -178,9 +187,11 @@ export async function detectLanguage(
178
187
  throw new Error(`Temperature cannot be negative`)
179
188
  }
180
189
 
190
+ // Select encoder ONNX provider
181
191
  const encoderProviders: OnnxExecutionProvider[] =
182
- options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu']
192
+ options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName)
183
193
 
194
+ // Select decoder ONNX provider
184
195
  const decoderProviders: OnnxExecutionProvider[] =
185
196
  options.decoderProvider ? [options.decoderProvider] : []
186
197
 
@@ -213,7 +224,7 @@ export async function detectVoiceActivity(
213
224
  options = extendDeep(defaultWhisperVADOptions, options)
214
225
 
215
226
  if (sourceRawAudio.sampleRate != 16000) {
216
- throw new Error('Source audio must have a sampling rate of 16000')
227
+ throw new Error('Source audio must have a sample rate of 16000 Hz')
217
228
  }
218
229
 
219
230
  if (options.temperature! < 0) {
@@ -225,9 +236,11 @@ export async function detectVoiceActivity(
225
236
  const partDuration = 5
226
237
  const maxSamplesCountForPart = sourceRawAudio.sampleRate * partDuration
227
238
 
239
+ // Select encoder ONNX provider
228
240
  const encoderProviders: OnnxExecutionProvider[] =
229
- options.encoderProvider ? [options.encoderProvider] : ['dml', 'cpu']
241
+ options.encoderProvider ? [options.encoderProvider] : getDefaultEncoderProvidersForModel(modelName)
230
242
 
243
+ // Select decoder ONNX provider
231
244
  const decoderProviders: OnnxExecutionProvider[] =
232
245
  options.decoderProvider ? [options.decoderProvider] : []
233
246
 
@@ -287,14 +300,14 @@ export class Whisper {
287
300
  timestampTokensEnd: number
288
301
  }
289
302
 
290
- randomGen: XorShift32RNG
303
+ randomGen: XorShift32PRNG
291
304
 
292
305
  constructor(
293
306
  public readonly modelName: WhisperModelName,
294
307
  public readonly modelDir: string,
295
308
  public readonly encoderExecutionProviders: OnnxExecutionProvider[],
296
309
  public readonly decoderExecutionProviders: OnnxExecutionProvider[],
297
- rngSeed = 461845907) {
310
+ prngSeed = 1234) {
298
311
 
299
312
  this.isMultiligualModel = isMultilingualModel(this.modelName)
300
313
 
@@ -334,7 +347,7 @@ export class Whisper {
334
347
  }
335
348
  }
336
349
 
337
- this.randomGen = new XorShift32RNG(rngSeed)
350
+ this.randomGen = new XorShift32PRNG(murmurHash3_int32Input(prngSeed))
338
351
  }
339
352
 
340
353
  async recognize(
@@ -443,7 +456,13 @@ export class Whisper {
443
456
  partCrossAttentionQKs = partCrossAttentionQKs.slice(initialTokens.length)
444
457
 
445
458
  // Find alignment path
446
- const alignmentPath = await this.findAlignmentPathFromQKs(partCrossAttentionQKs, partTokens, 0, segmentFrameCount) //, alignmentHeadsIndexes[this.modelName])
459
+ let alignmentHeads: number[] | undefined = undefined
460
+
461
+ if (this.modelName.startsWith('small') || this.modelName.startsWith('medium') || this.modelName.startsWith('large')) {
462
+ alignmentHeads = this.alignmentHeadIndexes
463
+ }
464
+
465
+ const alignmentPath = await this.findAlignmentPathFromQKs(partCrossAttentionQKs, partTokens, 0, segmentFrameCount, alignmentHeads)
447
466
 
448
467
  // Generate timeline from alignment path
449
468
  const partTimeline = await this.getTokenTimelineFromAlignmentPath(alignmentPath, partTokens, segmentStartTime, segmentEndTime, partTokensConfidence)
@@ -808,17 +827,17 @@ export class Whisper {
808
827
  }
809
828
 
810
829
  // Derive token probabilities
811
- const probabilities = softmax(allTokenLogits as any, 1.0)
812
- const logProbabilities = logOfVector(probabilities)
830
+ const allTokenProbabilities = softmax(allTokenLogits as any, 1.0)
831
+ const allTokenLogProbabilities = logOfVector(allTokenProbabilities)
813
832
 
814
- const nonTimestampTokenLogProbs = logProbabilities.slice(0, timestampTokensStart)
833
+ const nonTimestampTokenLogProbs = allTokenLogProbabilities.slice(0, timestampTokensStart)
815
834
 
816
835
  // Find highest non-timestamp token
817
836
  const indexOfMaxNonTimestampLogProb = indexOfMax(nonTimestampTokenLogProbs)
818
837
  const valueOfMaxNonTimestampLogProb = nonTimestampTokenLogProbs[indexOfMaxNonTimestampLogProb]
819
838
 
820
839
  // Find highest timestamp token
821
- const timestampTokenLogProbs = logProbabilities.slice(timestampTokensStart)
840
+ const timestampTokenLogProbs = allTokenLogProbabilities.slice(timestampTokensStart)
822
841
  const indexOfMaxTimestampLogProb = indexOfMax(timestampTokenLogProbs)
823
842
 
824
843
  // Compute the log of the sum of exponentials of the log probabilities
@@ -846,7 +865,7 @@ export class Whisper {
846
865
  } else {
847
866
  // Otherwise decode the highest probability timestamp
848
867
  const timestampToken = timestampTokensStart + indexOfMaxTimestampLogProb
849
- const confidence = probabilities[timestampToken]
868
+ const confidence = allTokenProbabilities[timestampToken]
850
869
 
851
870
  addToken(timestampToken, timestampTokenLogits, confidence, crossAttentionQKsForToken)
852
871
  }
@@ -1084,11 +1103,17 @@ export class Whisper {
1084
1103
 
1085
1104
  const fftOrder = 400
1086
1105
  const hopLength = 160
1087
- const filterbankCount = 80
1106
+
1107
+ const filterbankCount = this.filterbankCount
1108
+ const filterbanks = this.filterbanks
1088
1109
 
1089
1110
  const maxAudioSamples = sampleRate * 30
1090
1111
  const maxAudioFrames = 3000
1091
1112
 
1113
+ if (sampleRate != 16000) {
1114
+ throw new Error('Audio must have a sample rate of 16000 Hz')
1115
+ }
1116
+
1092
1117
  if (audioSamples.length > maxAudioSamples) {
1093
1118
  throw new Error(`Audio part is longer than 30 seconds`)
1094
1119
  }
@@ -1543,7 +1568,7 @@ export class Whisper {
1543
1568
  return [24, groupCount, length, 768]
1544
1569
  } else if (modelName == 'medium' || modelName == 'medium.en') {
1545
1570
  return [48, groupCount, length, 1024]
1546
- } else if (modelName == 'large' || modelName == 'large-v1' || modelName == 'large-v2' || modelName == 'large-v3') {
1571
+ } else if (modelName == 'large-v1' || modelName == 'large-v2' || modelName == 'large-v3' || modelName == 'large-v3-turbo') {
1547
1572
  return [64, groupCount, length, 1280]
1548
1573
  } else {
1549
1574
  throw new Error(`Unsupported model: ${modelName}`)
@@ -1665,7 +1690,19 @@ export class Whisper {
1665
1690
  return this.isMultiligualModel === false
1666
1691
  }
1667
1692
 
1668
- getAlignmentHeadIndexes() {
1693
+ get isLargeModel() {
1694
+ return this.modelName.startsWith('large')
1695
+ }
1696
+
1697
+ get filterbankCount() {
1698
+ return this.isLargeModel ? 128 : 80
1699
+ }
1700
+
1701
+ get filterbanks() {
1702
+ return this.isLargeModel ? filterbanks_128 : filterbanks_80
1703
+ }
1704
+
1705
+ get alignmentHeadIndexes() {
1669
1706
  return alignmentHeadsIndexes[this.modelName]
1670
1707
  }
1671
1708
 
@@ -1769,8 +1806,8 @@ export async function loadPackagesAndGetPaths(modelName: WhisperModelName | unde
1769
1806
  }
1770
1807
  }
1771
1808
 
1772
- if (modelName.startsWith('large')) {
1773
- 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.`)
1809
+ if (modelName.startsWith('large') && modelName !== 'large-v3-turbo') {
1810
+ 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.`)
1774
1811
  }
1775
1812
 
1776
1813
  const packageName = modelNameToPackageName[modelName]
@@ -1800,6 +1837,26 @@ export function isEnglishOnlyModel(modelName: WhisperModelName) {
1800
1837
  return modelName.endsWith('.en')
1801
1838
  }
1802
1839
 
1840
+ function getDefaultEncoderProvidersForModel(modelName: WhisperModelName): OnnxExecutionProvider[] {
1841
+ if (process.platform === 'win32') {
1842
+ return ['dml', 'cpu']
1843
+ } else {
1844
+ return []
1845
+ }
1846
+ }
1847
+
1848
+ function getDefaultDecoderProvidersForModel(modelName: WhisperModelName): OnnxExecutionProvider[] {
1849
+ if (modelName.startsWith('small') || modelName.startsWith('medium') || modelName.startsWith('large')) {
1850
+ if (process.platform === 'win32') {
1851
+ return ['dml', 'cpu']
1852
+ } else {
1853
+ return []
1854
+ }
1855
+ } else {
1856
+ return []
1857
+ }
1858
+ }
1859
+
1803
1860
  export type WhisperTokenData = {
1804
1861
  id: number
1805
1862
  text: string
@@ -1807,7 +1864,7 @@ export type WhisperTokenData = {
1807
1864
 
1808
1865
  export type WhisperLogitFilter = (logits: number[], decodedTokens: number[], isFirstPart: boolean, isFinalPart: boolean) => number[]
1809
1866
 
1810
- export type WhisperModelName = 'tiny' | 'tiny.en' | 'base' | 'base.en' | 'small' | 'small.en' | 'medium' | 'medium.en' | 'large' | 'large-v1' | 'large-v2' | 'large-v3'
1867
+ export type WhisperModelName = 'tiny' | 'tiny.en' | 'base' | 'base.en' | 'small' | 'small.en' | 'medium' | 'medium.en' | 'large-v1' | 'large-v2' | 'large-v3' | 'large-v3-turbo'
1811
1868
  export type WhisperTask = 'transcribe' | 'translate' | 'detect-language'
1812
1869
 
1813
1870
  export const modelNameToPackageName: { [modelName in WhisperModelName]: string } = {
@@ -1819,10 +1876,10 @@ export const modelNameToPackageName: { [modelName in WhisperModelName]: string }
1819
1876
  'small.en': 'whisper-small.en',
1820
1877
  'medium': 'whisper-medium',
1821
1878
  'medium.en': 'whisper-medium.en',
1822
- 'large': 'whisper-large-v3',
1823
1879
  'large-v1': 'whisper-large-v1',
1824
1880
  'large-v2': 'whisper-large-v2',
1825
- 'large-v3': 'whisper-large-v3'
1881
+ 'large-v3': 'whisper-large-v3',
1882
+ 'large-v3-turbo': 'whisper-large-v3-turbo-fp16',
1826
1883
  }
1827
1884
 
1828
1885
  export const tokenizerPackageName = 'whisper-tokenizer'
@@ -1930,21 +1987,21 @@ const languageIdLookup: { [s: string]: number } = {
1930
1987
  }
1931
1988
 
1932
1989
  const alignmentHeadsIndexes: { [name in WhisperModelName]: number[] } = {
1933
- 'tiny.en': [6, 12, 17, 18, 19, 20, 21, 22],
1934
- 'tiny': [14, 18, 20, 21, 22, 23],
1935
- 'base.en': [27, 39, 41, 45, 47],
1936
- 'base': [25, 34, 35, 39, 41, 42, 44, 46],
1937
- 'small.en': [78, 84, 87, 92, 98, 101, 103, 108, 112, 116, 118, 120, 121, 122, 123, 126, 131, 134, 136],
1938
- 'small': [63, 69, 96, 100, 103, 104, 108, 115, 117, 125],
1939
- 'medium.en': [180, 225, 236, 238, 244, 256, 260, 265, 284, 286, 295, 298, 303, 320, 323, 329, 334, 348],
1940
- 'medium': [223, 244, 255, 257, 320, 372],
1941
- 'large-v1': [199, 222, 224, 237, 447, 451, 457, 462, 475],
1942
- '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],
1943
- '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)
1944
- 'large': [212, 277, 331, 332, 333, 355, 356, 364, 371, 379, 391, 422, 423, 443, 449, 452, 465, 467, 473, 505, 521, 532, 555],
1990
+ 'tiny.en': [6, 12, 17, 18, 19, 20, 21, 22,],
1991
+ 'tiny': [14, 18, 20, 21, 22, 23,],
1992
+ 'base.en': [27, 39, 41, 45, 47,],
1993
+ 'base': [25, 34, 35, 39, 41, 42, 44, 46,],
1994
+ 'small.en': [78, 84, 87, 92, 98, 101, 103, 108, 112, 116, 118, 120, 121, 122, 123, 126, 131, 134, 136,],
1995
+ 'small': [63, 69, 96, 100, 103, 104, 108, 115, 117, 125,],
1996
+ 'medium.en': [180, 225, 236, 238, 244, 256, 260, 265, 284, 286, 295, 298, 303, 320, 323, 329, 334, 348,],
1997
+ 'medium': [223, 244, 255, 257, 320, 372,],
1998
+ 'large-v1': [199, 222, 224, 237, 447, 451, 457, 462, 475,],
1999
+ '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,],
2000
+ 'large-v3': [140, 217, 258, 272, 321, 354, 391, 424, 481, 506,],
2001
+ 'large-v3-turbo': [44, 51, 63, 66, 71, 74,],
1945
2002
  }
1946
2003
 
1947
- const filterbanks: Filterbank[] = [
2004
+ const filterbanks_80: Filterbank[] = [
1948
2005
  /* 0 */ { startIndex: 1, weights: [0.02486259490251541,] },
1949
2006
 
1950
2007
  /* 1 */ { startIndex: 1, weights: [0.001990821911022067, 0.022871771827340126,] },
@@ -2106,6 +2163,264 @@ const filterbanks: Filterbank[] = [
2106
2163
  /* 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,] },
2107
2164
  ]
2108
2165
 
2166
+ const filterbanks_128: Filterbank[] = [
2167
+ /* 0 */ { startIndex: 1, weights: [0.012373986653983593,] },
2168
+
2169
+ /* 1 */ { startIndex: 1, weights: [0.030392564833164215,] },
2170
+
2171
+ /* 2 */ { startIndex: 2, weights: [0.024747973307967186,] },
2172
+
2173
+ /* 3 */ { startIndex: 2, weights: [0.018018579110503197,] },
2174
+
2175
+ /* 4 */ { startIndex: 3, weights: [0.037121959030628204,] },
2176
+
2177
+ /* 5 */ { startIndex: 3, weights: [0.005644591990858316, 0.006729394197463989,] },
2178
+
2179
+ /* 6 */ { startIndex: 4, weights: [0.03603715822100639,] },
2180
+
2181
+ /* 7 */ { startIndex: 5, weights: [0.019103379920125008,] },
2182
+
2183
+ /* 8 */ { startIndex: 5, weights: [0.023663168773055077,] },
2184
+
2185
+ /* 9 */ { startIndex: 6, weights: [0.031477365642786026,] },
2186
+
2187
+ /* 10 */ { startIndex: 6, weights: [0.011289183981716633, 0.0010848019737750292,] },
2188
+
2189
+ /* 11 */ { startIndex: 7, weights: [0.04168175160884857,] },
2190
+
2191
+ /* 12 */ { startIndex: 8, weights: [0.013458788394927979,] },
2192
+
2193
+ /* 13 */ { startIndex: 8, weights: [0.029307762160897255,] },
2194
+
2195
+ /* 14 */ { startIndex: 9, weights: [0.025832774117588997,] },
2196
+
2197
+ /* 15 */ { startIndex: 9, weights: [0.016933776438236237,] },
2198
+
2199
+ /* 16 */ { startIndex: 10, weights: [0.038206759840250015,] },
2200
+
2201
+ /* 17 */ { startIndex: 10, weights: [0.004559790249913931, 0.007814195938408375,] },
2202
+
2203
+ /* 18 */ { startIndex: 11, weights: [0.03495235741138458,] },
2204
+
2205
+ /* 19 */ { startIndex: 12, weights: [0.020188182592391968,] },
2206
+
2207
+ /* 20 */ { startIndex: 12, weights: [0.022578367963433266,] },
2208
+
2209
+ /* 21 */ { startIndex: 13, weights: [0.032562170177698135,] },
2210
+
2211
+ /* 22 */ { startIndex: 13, weights: [0.010204383172094822, 0.0021696039475500584,] },
2212
+
2213
+ /* 23 */ { startIndex: 14, weights: [0.04059694707393646,] },
2214
+
2215
+ /* 24 */ { startIndex: 15, weights: [0.01454358920454979,] },
2216
+
2217
+ /* 25 */ { startIndex: 15, weights: [0.028222959488630295,] },
2218
+
2219
+ /* 26 */ { startIndex: 16, weights: [0.026917576789855957,] },
2220
+
2221
+ /* 27 */ { startIndex: 16, weights: [0.015848975628614426,] },
2222
+
2223
+ /* 28 */ { startIndex: 17, weights: [0.039291560649871826,] },
2224
+
2225
+ /* 29 */ { startIndex: 17, weights: [0.0034749882761389017, 0.008898998610675335,] },
2226
+
2227
+ /* 30 */ { startIndex: 18, weights: [0.03386755287647247,] },
2228
+
2229
+ /* 31 */ { startIndex: 19, weights: [0.021272985264658928,] },
2230
+
2231
+ /* 32 */ { startIndex: 19, weights: [0.021493567153811455,] },
2232
+
2233
+ /* 33 */ { startIndex: 20, weights: [0.033646970987319946,] },
2234
+
2235
+ /* 34 */ { startIndex: 20, weights: [0.009119580499827862, 0.003254405688494444,] },
2236
+
2237
+ /* 35 */ { startIndex: 21, weights: [0.03951214626431465,] },
2238
+
2239
+ /* 36 */ { startIndex: 22, weights: [0.01562839187681675,] },
2240
+
2241
+ /* 37 */ { startIndex: 22, weights: [0.027138158679008484,] },
2242
+
2243
+ /* 38 */ { startIndex: 23, weights: [0.028002377599477768,] },
2244
+
2245
+ /* 39 */ { startIndex: 23, weights: [0.014764172956347466,] },
2246
+
2247
+ /* 40 */ { startIndex: 24, weights: [0.040376365184783936,] },
2248
+
2249
+ /* 41 */ { startIndex: 24, weights: [0.0023806870449334383, 0.010202637873589993,] },
2250
+
2251
+ /* 42 */ { startIndex: 25, weights: [0.03161146119236946,] },
2252
+
2253
+ /* 43 */ { startIndex: 26, weights: [0.024547001346945763,] },
2254
+
2255
+ /* 44 */ { startIndex: 26, weights: [0.015329193323850632, 0.001665837480686605,] },
2256
+
2257
+ /* 45 */ { startIndex: 27, weights: [0.036729052662849426,] },
2258
+
2259
+ /* 46 */ { startIndex: 28, weights: [0.020097099244594574,] },
2260
+
2261
+ /* 47 */ { startIndex: 28, weights: [0.016931025311350822, 0.0029026553966104984,] },
2262
+
2263
+ /* 48 */ { startIndex: 29, weights: [0.032844990491867065,] },
2264
+
2265
+ /* 49 */ { startIndex: 30, weights: [0.023520048707723618,] },
2266
+
2267
+ /* 50 */ { startIndex: 30, weights: [0.011038944125175476, 0.010725829750299454,] },
2268
+
2269
+ /* 51 */ { startIndex: 31, weights: [0.022718291729688644,] },
2270
+
2271
+ /* 52 */ { startIndex: 32, weights: [0.03227872774004936,] },
2272
+
2273
+ /* 53 */ { startIndex: 32, weights: [0.00011626833293121308, 0.022853482514619827,] },
2274
+
2275
+ /* 54 */ { startIndex: 33, weights: [0.008563440293073654, 0.014979788102209568,] },
2276
+
2277
+ /* 55 */ { startIndex: 34, weights: [0.015513983555138111, 0.008514906279742718,] },
2278
+
2279
+ /* 56 */ { startIndex: 35, weights: [0.02110680378973484, 0.003326520323753357,] },
2280
+
2281
+ /* 57 */ { startIndex: 36, weights: [0.02547064796090126,] },
2282
+
2283
+ /* 58 */ { startIndex: 37, weights: [0.02735907956957817,] },
2284
+
2285
+ /* 59 */ { startIndex: 37, weights: [0.0006585361552424729, 0.02383812516927719,] },
2286
+
2287
+ /* 60 */ { startIndex: 38, weights: [0.0034435924608260393, 0.021224552765488625,] },
2288
+
2289
+ /* 61 */ { startIndex: 39, weights: [0.0053584217093884945, 0.019425557926297188,] },
2290
+
2291
+ /* 62 */ { startIndex: 40, weights: [0.006493247114121914, 0.018355421721935272,] },
2292
+
2293
+ /* 63 */ { startIndex: 41, weights: [0.006931380834430456, 0.017935046926140785,] },
2294
+
2295
+ /* 64 */ { startIndex: 42, weights: [0.0067496825940907, 0.018091518431901932,] },
2296
+
2297
+ /* 65 */ { startIndex: 43, weights: [0.006018991116434336, 0.018757672980427742,] },
2298
+
2299
+ /* 66 */ { startIndex: 44, weights: [0.004804528318345547, 0.019871728494763374,] },
2300
+
2301
+ /* 67 */ { startIndex: 45, weights: [0.0031662785913795233, 0.02137690968811512, 0.001253173453733325,] },
2302
+
2303
+ /* 68 */ { startIndex: 46, weights: [0.0011593446834012866, 0.02080361731350422, 0.004044868052005768,] },
2304
+
2305
+ /* 69 */ { startIndex: 48, weights: [0.017553631216287613, 0.007083200383931398,] },
2306
+
2307
+ /* 70 */ { startIndex: 49, weights: [0.014075386337935925, 0.010326550342142582,] },
2308
+
2309
+ /* 71 */ { startIndex: 50, weights: [0.010409214533865452, 0.013736963272094727,] },
2310
+
2311
+ /* 72 */ { startIndex: 51, weights: [0.006591876968741417, 0.017279881983995438, 0.0014680421445518732,] },
2312
+
2313
+ /* 73 */ { startIndex: 52, weights: [0.0026568188332021236, 0.01809193193912506, 0.005856557283550501,] },
2314
+
2315
+ /* 74 */ { startIndex: 54, weights: [0.013342779129743576, 0.010282675735652447,] },
2316
+
2317
+ /* 75 */ { startIndex: 55, weights: [0.00856800377368927, 0.01472230814397335, 0.001040398608893156,] },
2318
+
2319
+ /* 76 */ { startIndex: 56, weights: [0.003790855873376131, 0.01714678481221199, 0.006116092670708895,] },
2320
+
2321
+ /* 77 */ { startIndex: 58, weights: [0.011759290471673012, 0.011133937165141106,] },
2322
+
2323
+ /* 78 */ { startIndex: 59, weights: [0.006438578478991985, 0.01607806235551834, 0.004239172209054232,] },
2324
+
2325
+ /* 79 */ { startIndex: 60, weights: [0.0011998937698081136, 0.012756715528666973, 0.00965298991650343,] },
2326
+
2327
+ /* 80 */ { startIndex: 62, weights: [0.007069352548569441, 0.014940546825528145, 0.004190248437225819,] },
2328
+
2329
+ /* 81 */ { startIndex: 63, weights: [0.0015148338861763477, 0.012008999474346638, 0.009848233312368393,] },
2330
+
2331
+ /* 82 */ { startIndex: 65, weights: [0.006102240178734064, 0.01533857174217701, 0.005576768424361944,] },
2332
+
2333
+ /* 83 */ { startIndex: 66, weights: [0.00036827256553806365, 0.00989749375730753, 0.011353404261171818, 0.0020512230694293976,] },
2334
+
2335
+ /* 84 */ { startIndex: 68, weights: [0.003892971435561776, 0.012973522767424583, 0.00806631613522768,] },
2336
+
2337
+ /* 85 */ { startIndex: 70, weights: [0.006744932383298874, 0.013858746737241745, 0.005411905236542225,] },
2338
+
2339
+ /* 86 */ { startIndex: 71, weights: [0.0007422015769407153, 0.008987790904939175, 0.011378713883459568, 0.003329580882564187,] },
2340
+
2341
+ /* 87 */ { startIndex: 73, weights: [0.0028231353498995304, 0.010680492967367172, 0.00943340640515089, 0.0017632555682212114,] },
2342
+
2343
+ /* 88 */ { startIndex: 75, weights: [0.0043901861645281315, 0.011877589859068394, 0.007970058359205723, 0.0006610470009036362,] },
2344
+
2345
+ /* 89 */ { startIndex: 77, weights: [0.005494666751474142, 0.012629535980522633, 0.00693987961858511,] },
2346
+
2347
+ /* 90 */ { startIndex: 79, weights: [0.006184019148349762, 0.0129347313195467, 0.00629778765141964,] },
2348
+
2349
+ /* 91 */ { startIndex: 80, weights: [2.3252101527759805e-05, 0.006502066273242235, 0.0123266177251935, 0.006002165377140045,] },
2350
+
2351
+ /* 92 */ { startIndex: 82, weights: [0.00031548753031529486, 0.006489255465567112, 0.012041302397847176, 0.006014628801494837,] },
2352
+
2353
+ /* 93 */ { startIndex: 84, weights: [0.00029979555984027684, 0.006182880140841007, 0.012042728252708912, 0.006299811881035566, 0.0005568959750235081,] },
2354
+
2355
+ /* 94 */ { startIndex: 86, weights: [1.1204706424905453e-05, 0.005617291666567326, 0.011223378591239452, 0.0068251630291342735, 0.0013526449911296368,] },
2356
+
2357
+ /* 95 */ { startIndex: 89, weights: [0.004824100062251091, 0.010166232474148273, 0.007560755126178265, 0.002345903078094125,] },
2358
+
2359
+ /* 96 */ { startIndex: 91, weights: [0.003832357469946146, 0.008922962471842766, 0.00847910437732935, 0.003509786445647478,] },
2360
+
2361
+ /* 97 */ { startIndex: 93, weights: [0.0026687318459153175, 0.007519651670008898, 0.009555005468428135, 0.004819661378860474, 8.431751484749839e-05,] },
2362
+
2363
+ /* 98 */ { startIndex: 95, weights: [0.001357673667371273, 0.005980195011943579, 0.01060271542519331, 0.0062529849819839, 0.0017405991675332189,] },
2364
+
2365
+ /* 99 */ { startIndex: 98, weights: [0.004326442256569862, 0.008731318637728691, 0.007789165247231722, 0.003489238675683737,] },
2366
+
2367
+ /* 100 */ { startIndex: 100, weights: [0.0025783509481698275, 0.006775828544050455, 0.00940941646695137, 0.005311945918947458, 0.0012144759530201554,] },
2368
+
2369
+ /* 101 */ { startIndex: 102, weights: [0.0007541119121015072, 0.004753957036882639, 0.008753802627325058, 0.007192090153694153, 0.003287544008344412,] },
2370
+
2371
+ /* 102 */ { startIndex: 105, weights: [0.0026817969046533108, 0.0064933146350085735, 0.009114579297602177, 0.005393873900175095, 0.0016731682699173689,] },
2372
+
2373
+ /* 103 */ { startIndex: 107, weights: [0.0005739429616369307, 0.0042060003615915775, 0.007838058285415173, 0.007520230021327734, 0.003974708262830973, 0.00042918731924146414,] },
2374
+
2375
+ /* 104 */ { startIndex: 110, weights: [0.0019046447705477476, 0.005365691613405943, 0.008826738223433495, 0.0062760948203504086, 0.0028975096065551043,] },
2376
+
2377
+ /* 105 */ { startIndex: 113, weights: [0.0028988525737076998, 0.006196940783411264, 0.008566990494728088, 0.005347481928765774, 0.002127972897142172,] },
2378
+
2379
+ /* 106 */ { startIndex: 115, weights: [0.0004475022724363953, 0.0035903039388358593, 0.006733105983585119, 0.007770236115902662, 0.004702313803136349, 0.0016343912575393915,] },
2380
+
2381
+ /* 107 */ { startIndex: 118, weights: [0.0010153602343052626, 0.004010187461972237, 0.007005014456808567, 0.007234429940581322, 0.0043109566904604435, 0.0013874832075089216,] },
2382
+
2383
+ /* 108 */ { startIndex: 121, weights: [0.0013334885006770492, 0.004187308251857758, 0.007041127886623144, 0.0069318837486207485, 0.004146058112382889, 0.0013602323597297072,] },
2384
+
2385
+ /* 109 */ { startIndex: 124, weights: [0.0014287971425801516, 0.004148248583078384, 0.006867699790745974, 0.006837052758783102, 0.004182394593954086, 0.0015277357306331396,] },
2386
+
2387
+ /* 110 */ { startIndex: 127, weights: [0.0013261043932288885, 0.003917513880878687, 0.006508923601359129, 0.006926396861672401, 0.0043967291712760925, 0.0018670617137104273,] },
2388
+
2389
+ /* 111 */ { startIndex: 130, weights: [0.0010482777142897248, 0.0035176740493625402, 0.0059870705008506775, 0.007178240455687046, 0.004767679143697023, 0.002357117598876357,] },
2390
+
2391
+ /* 112 */ { startIndex: 133, weights: [0.0006163640646263957, 0.0029694922268390656, 0.005322620272636414, 0.007572650909423828, 0.005275587551295757, 0.0029785241931676865, 0.0006814609514549375,] },
2392
+
2393
+ /* 113 */ { startIndex: 136, weights: [4.9713995394995436e-05, 0.0022920481860637665, 0.004534382373094559, 0.006776716560125351, 0.0059024072252213955, 0.00371349835768342, 0.0015245892573148012,] },
2394
+
2395
+ /* 114 */ { startIndex: 140, weights: [0.0015028533525764942, 0.0036396104842424393, 0.005776367150247097, 0.0066315908916294575, 0.004545743577182293, 0.002459896495565772, 0.00037404923932626843,] },
2396
+
2397
+ /* 115 */ { startIndex: 143, weights: [0.0006179586052894592, 0.00265410915017128, 0.004690259229391813, 0.006726410239934921, 0.005460347048938274, 0.0034727093297988176, 0.0014850713778287172,] },
2398
+
2399
+ /* 116 */ { startIndex: 147, weights: [0.001592335756868124, 0.0035326166544109583, 0.005472897551953793, 0.0064436825923621655, 0.004549629986286163, 0.002655577613040805, 0.0007615251233801246,] },
2400
+
2401
+ /* 117 */ { startIndex: 150, weights: [0.00046749351895414293, 0.0023164190351963043, 0.004165344405919313, 0.0060142697766423225, 0.005678446963429451, 0.0038735736161470413, 0.002068700036033988, 0.0002638266596477479,] },
2402
+
2403
+ /* 118 */ { startIndex: 154, weights: [0.0010534910252317786, 0.002815362298861146, 0.0045772334560751915, 0.006339104846119881, 0.0051281568594276905, 0.0034082632046192884, 0.0016883700154721737,] },
2404
+
2405
+ /* 119 */ { startIndex: 158, weights: [0.0014335009036585689, 0.0031124167144298553, 0.00479133240878582, 0.00640943692997098, 0.004770522005856037, 0.0031316077802330256, 0.0014926930889487267,] },
2406
+
2407
+ /* 120 */ { startIndex: 161, weights: [2.9323589842533693e-05, 0.001629189937375486, 0.003229056019335985, 0.00482892245054245, 0.006146714556962252, 0.004584966227412224, 0.0030232176650315523, 0.0014614691026508808,] },
2408
+
2409
+ /* 121 */ { startIndex: 165, weights: [0.00013601698447018862, 0.001660555717535317, 0.003185094567015767, 0.004709633067250252, 0.006040723994374275, 0.0045525087043643, 0.003064292948693037, 0.001576077425852418, 8.786193211562932e-05,] },
2410
+
2411
+ /* 122 */ { startIndex: 169, weights: [9.328097075922415e-05, 0.001546038780361414, 0.002998796757310629, 0.004451554734259844, 0.0059043122455477715, 0.0046556610614061356, 0.003237516153603792, 0.0018193712458014488, 0.00040122633799910545,] },
2412
+
2413
+ /* 123 */ { startIndex: 174, weights: [0.0013026263331994414, 0.002686982974410057, 0.004071339499205351, 0.005455696024000645, 0.004878324922174215, 0.0035269514191895723, 0.0021755779162049294, 0.0008242045878432691,] },
2414
+
2415
+ /* 124 */ { startIndex: 178, weights: [0.0009459502762183547, 0.002265126211568713, 0.0035843022633343935, 0.0049034785479307175, 0.005205697845667601, 0.0039179520681500435, 0.00263020652346313, 0.001342460629530251, 5.471494296216406e-05,] },
2416
+
2417
+ /* 125 */ { startIndex: 182, weights: [0.0004903789376839995, 0.0017474433407187462, 0.003004507627338171, 0.004261571913957596, 0.005518636200577021, 0.004397072363644838, 0.0031699584797024727, 0.001942844595760107, 0.0007157306536100805,] },
2418
+
2419
+ /* 126 */ { startIndex: 187, weights: [0.0011469805613160133, 0.002344857668504119, 0.0035427347756922245, 0.004740611650049686, 0.0049519846215844154, 0.003782647429034114, 0.002613310469314456, 0.0014439737424254417, 0.0002746368118096143,] },
2420
+
2421
+ /* 127 */ { startIndex: 191, weights: [0.0004756950947921723, 0.0016171716852113605, 0.002758648479357362, 0.0039001251570880413, 0.005041601601988077, 0.004457120783627033, 0.003342840587720275, 0.0022285603918135166, 0.0011142801959067583,] },
2422
+ ]
2423
+
2109
2424
  // Recognition options
2110
2425
  export interface WhisperOptions {
2111
2426
  model?: WhisperModelName
@@ -7,9 +7,10 @@ import { OpenPromise } from '../utilities/OpenPromise.js'
7
7
  import { AudioSourceParam, RawAudio } from '../audio/AudioUtilities.js'
8
8
  import { AlignmentOptions, AlignmentResult } from '../api/Alignment.js'
9
9
  import { RecognitionOptions, RecognitionResult } from '../api/Recognition.js'
10
- import { SpeechTranslationOptions, SpeechTranslationResult } from '../api/Translation.js'
10
+ import { SpeechTranslationOptions, SpeechTranslationResult } from '../api/SpeechTranslation.js'
11
11
  import { Worker as WorkerThread } from 'node:worker_threads'
12
- import { SpeechLanguageDetectionOptions, SpeechLanguageDetectionResult, TextLanguageDetectionOptions, TextLanguageDetectionResult } from '../api/LanguageDetection.js'
12
+ import { SpeechLanguageDetectionOptions, SpeechLanguageDetectionResult } from '../api/SpeechLanguageDetection.js'
13
+ import { TextLanguageDetectionOptions, TextLanguageDetectionResult } from '../api/TextLanguageDetection.js'
13
14
 
14
15
  const log = logToStderr
15
16
 
@@ -4,13 +4,14 @@ import { logToStderr, yieldToEventLoop } from '../utilities/Utilities.js'
4
4
  import { AudioSourceParam } from '../audio/AudioUtilities.js'
5
5
  import { RecognitionOptions, RecognitionResult, recognize } from '../api/Recognition.js'
6
6
  import { AlignmentOptions, AlignmentResult, align } from '../api/Alignment.js'
7
- import { SpeechTranslationOptions, SpeechTranslationResult, translateSpeech } from '../api/Translation.js'
7
+ import { SpeechTranslationOptions, SpeechTranslationResult, translateSpeech } from '../api/SpeechTranslation.js'
8
8
  import { resetActiveLogger } from '../utilities/Logger.js'
9
9
  import { writeToStderr } from '../utilities/Utilities.js'
10
10
  import { Worker, SHARE_ENV } from 'node:worker_threads'
11
- import { SpeechLanguageDetectionOptions, SpeechLanguageDetectionResult, TextLanguageDetectionOptions, TextLanguageDetectionResult, detectSpeechLanguage, detectTextLanguage } from '../api/LanguageDetection.js'
11
+ import { SpeechLanguageDetectionOptions, SpeechLanguageDetectionResult, detectSpeechLanguage } from '../api/SpeechLanguageDetection.js'
12
12
  import chalk from 'chalk'
13
13
  import { resolveToModuleRootDir } from '../utilities/PathUtilities.js'
14
+ import { TextLanguageDetectionOptions, TextLanguageDetectionResult, detectTextLanguage } from '../api/TextLanguageDetection.js'
14
15
 
15
16
  const log = logToStderr
16
17
 
@@ -32,7 +32,7 @@ export class MDXNet {
32
32
  }
33
33
 
34
34
  if (rawAudio.sampleRate != 44100) {
35
- throw new Error(`Input audio must have a 44100 Hz sampling rate`)
35
+ throw new Error(`Input audio must have a sample rate of 44100 Hz`)
36
36
  }
37
37
 
38
38
  await this.initializeSessionIfNeeded()