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
@@ -0,0 +1,292 @@
1
+ import { DynamicUint8Array } from "./DynamicUint8Array.js"
2
+ import { logToStderr } from "./Utilities.js"
3
+
4
+
5
+ ////////////////////////////////////////////////////////////////////////////////////
6
+ // Encode unsigned integer
7
+ ////////////////////////////////////////////////////////////////////////////////////
8
+ export function encodeUnsignedInt31(value: number, outEncodedData: DynamicUint8Array) {
9
+ value = value >>> 0
10
+
11
+ if (value < (2 ** 7)) {
12
+ outEncodedData.add(
13
+ value
14
+ )
15
+ } else if (value < (2 ** 14)) {
16
+ outEncodedData.addMany(
17
+ (value & 0b00111111) | 0b10000000,
18
+ value >>> 6,
19
+ )
20
+ } else if (value < (2 ** 21)) {
21
+ outEncodedData.addMany(
22
+ (value & 0b00011111) | 0b11000000,
23
+ value >>> 5,
24
+ value >>> 13,
25
+ )
26
+ } else if (value < (2 ** 28)) {
27
+ outEncodedData.addMany(
28
+ (value & 0b00001111) | 0b11100000,
29
+ value >>> 4,
30
+ value >>> 12,
31
+ value >>> 20,
32
+ )
33
+ } else {
34
+ outEncodedData.addMany(
35
+ 0b11110000,
36
+ value,
37
+ value >>> 8,
38
+ value >>> 16,
39
+ value >>> 24,
40
+ )
41
+ }
42
+ }
43
+
44
+ ////////////////////////////////////////////////////////////////////////////////////
45
+ // Decode unsigned integer
46
+ ////////////////////////////////////////////////////////////////////////////////////
47
+ export function decodeUnsignedInt31(encodedData: ArrayLike<number>, readOffset: number): DecodedValueAndReadOffset {
48
+ readOffset = readOffset | 0
49
+
50
+ const byte0 = encodedData[readOffset++]
51
+
52
+ if ((byte0 & 0b10000000) === 0) {
53
+ // 1 byte
54
+ let decodedValue =
55
+ byte0
56
+
57
+ return { decodedValue, readOffset }
58
+ }
59
+
60
+ const byte1 = encodedData[readOffset++]
61
+
62
+ if ((byte0 & 0b01000000) === 0) {
63
+ // 2 bytes
64
+ let decodedValue =
65
+ (byte0 & 0b00111111) |
66
+ (byte1 << 6)
67
+
68
+ return { decodedValue, readOffset }
69
+ }
70
+
71
+ const byte2 = encodedData[readOffset++]
72
+
73
+ if ((byte0 & 0b00100000) === 0) {
74
+ // 3 bytes
75
+ let decodedValue =
76
+ (byte0 & 0b00011111) |
77
+ (byte1 << 5) |
78
+ (byte2 << 13)
79
+
80
+ return { decodedValue, readOffset }
81
+ }
82
+
83
+ const byte3 = encodedData[readOffset++]
84
+
85
+ if ((byte0 & 0b00010000) === 0) {
86
+ // 4 bytes
87
+ let decodedValue =
88
+ (byte0 & 0b00001111) |
89
+ (byte1 << 4) |
90
+ (byte2 << 12) |
91
+ (byte3 << 20)
92
+
93
+ return { decodedValue, readOffset }
94
+ }
95
+
96
+ const byte4 = encodedData[readOffset++]
97
+
98
+ if (byte0 === 0b11110000) {
99
+ // 5 bytes
100
+ let decodedValue =
101
+ (byte1) |
102
+ (byte2 << 8) |
103
+ (byte3 << 16) |
104
+ (byte4 << 24)
105
+
106
+ return { decodedValue, readOffset }
107
+ }
108
+
109
+ throw new Error(`Encountered a value that is encoded with more than 5 bytes (beyond Unsigned Int31 range).`)
110
+ }
111
+
112
+ ////////////////////////////////////////////////////////////////////////////////////
113
+ // Encode signed integer
114
+ ////////////////////////////////////////////////////////////////////////////////////
115
+ export function encodeSignedInt32(value: number, outEncodedData: DynamicUint8Array) {
116
+ const absValue = Math.abs(value | 0)
117
+
118
+ if (absValue < (2 ** 6)) {
119
+ outEncodedData.add(
120
+ value & 0b01111111
121
+ )
122
+ } else if (absValue < (2 ** 13)) {
123
+ outEncodedData.addMany(
124
+ (value & 0b00111111) | 0b10000000,
125
+ value >> 6
126
+ )
127
+ } else if (absValue < (2 ** 20)) {
128
+ outEncodedData.addMany(
129
+ (value & 0b00011111) | 0b11000000,
130
+ value >> 5,
131
+ value >> 13,
132
+ )
133
+ } else if (absValue < (2 ** 27)) {
134
+ outEncodedData.addMany(
135
+ (value & 0b00001111) | 0b11100000,
136
+ value >> 4,
137
+ value >> 12,
138
+ value >> 20,
139
+ )
140
+ } else {
141
+ outEncodedData.addMany(
142
+ 0b11110000,
143
+ value,
144
+ value >> 8,
145
+ value >> 16,
146
+ value >> 24,
147
+ )
148
+ }
149
+ }
150
+
151
+ ////////////////////////////////////////////////////////////////////////////////////
152
+ // Decode signed integer
153
+ ////////////////////////////////////////////////////////////////////////////////////
154
+ export function decodeSignedInt32(encodedData: ArrayLike<number>, readOffset: number): DecodedValueAndReadOffset {
155
+ const byte0 = encodedData[readOffset++]
156
+
157
+ if ((byte0 & 0b10000000) === 0) {
158
+ // 1 byte
159
+ let decodedValue =
160
+ byte0
161
+
162
+ if ((byte0 & 0b01000000) !== 0) {
163
+ decodedValue |= (-1 << 7)
164
+ }
165
+
166
+ return { decodedValue, readOffset }
167
+ }
168
+
169
+ const byte1 = encodedData[readOffset++]
170
+
171
+ if ((byte0 & 0b01000000) === 0) {
172
+ // 2 bytes
173
+ let decodedValue =
174
+ (byte0 & 0b00111111) |
175
+ (byte1 << 6)
176
+
177
+ if ((byte1 & 0b10000000) !== 0) {
178
+ decodedValue |= (-1 << 14)
179
+ }
180
+
181
+ return { decodedValue, readOffset }
182
+ }
183
+
184
+ const byte2 = encodedData[readOffset++]
185
+
186
+ if ((byte0 & 0b00100000) === 0) {
187
+ // 3 bytes
188
+ let decodedValue =
189
+ (byte0 & 0b00011111) |
190
+ (byte1 << 5) |
191
+ (byte2 << 13)
192
+
193
+ if ((byte2 & 0b10000000) !== 0) {
194
+ decodedValue |= (-1 << 21)
195
+ }
196
+
197
+ return { decodedValue, readOffset }
198
+ }
199
+
200
+ const byte3 = encodedData[readOffset++]
201
+
202
+ if ((byte0 & 0b00010000) === 0) {
203
+ // 4 bytes
204
+ let decodedValue =
205
+ (byte0 & 0b00001111) |
206
+ (byte1 << 4) |
207
+ (byte2 << 12) |
208
+ (byte3 << 20)
209
+
210
+ if ((byte3 & 0b10000000) !== 0) {
211
+ decodedValue |= (-1 << 28)
212
+ }
213
+
214
+ return { decodedValue, readOffset }
215
+ }
216
+
217
+ const byte4 = encodedData[readOffset++]
218
+
219
+ if (byte0 === 0b11110000) {
220
+ // 5 bytes
221
+ let decodedValue =
222
+ (byte1) |
223
+ (byte2 << 8) |
224
+ (byte3 << 16) |
225
+ (byte4 << 24)
226
+
227
+ return { decodedValue, readOffset }
228
+ }
229
+
230
+ throw new Error(`Encountered a value that is encoded with more than 5 bytes (beyond int32 range).`)
231
+ }
232
+
233
+ ////////////////////////////////////////////////////////////////////////////////////
234
+ // Types
235
+ ////////////////////////////////////////////////////////////////////////////////////
236
+ export interface DecodedValueAndReadOffset {
237
+ decodedValue: number
238
+ readOffset: number
239
+ }
240
+
241
+ ////////////////////////////////////////////////////////////////////////////////////
242
+ // Tests
243
+ ////////////////////////////////////////////////////////////////////////////////////
244
+ export function testLPVarintSigned() {
245
+ const encodedBytes = new DynamicUint8Array()
246
+
247
+ function runTest(testValue: number) {
248
+ encodedBytes.clear()
249
+
250
+ encodeSignedInt32(testValue, encodedBytes)
251
+ const { decodedValue } = decodeSignedInt32(encodedBytes.data, 0)
252
+
253
+ if (decodedValue !== testValue) {
254
+ throw new Error(`Expected ${testValue} but got ${decodedValue}`)
255
+ }
256
+ }
257
+
258
+ for (let i = -(2 ** 26); i < 2 ** 26; i++) {
259
+ if (i % 1000000 === 0) {
260
+ logToStderr(i)
261
+ }
262
+
263
+ runTest(i)
264
+ }
265
+
266
+ const x = 1
267
+ }
268
+
269
+ export function testLPVarintUnsigned() {
270
+ const encodedBytes = new DynamicUint8Array()
271
+
272
+ function runTest(testValue: number) {
273
+ encodedBytes.clear()
274
+
275
+ encodeUnsignedInt31(testValue, encodedBytes)
276
+ const { decodedValue } = decodeUnsignedInt31(encodedBytes.data, 0)
277
+
278
+ if (decodedValue !== testValue) {
279
+ throw new Error(`Expected ${testValue} but got ${decodedValue}`)
280
+ }
281
+ }
282
+
283
+ for (let i = 0; i < 2 ** 31; i++) {
284
+ if (i % 1000000 === 0) {
285
+ logToStderr(i)
286
+ }
287
+
288
+ runTest(i)
289
+ }
290
+
291
+ const x = 1
292
+ }
@@ -22,7 +22,7 @@ export function formatLanguageCodeWithName(languageCode: string, styleId: 1 | 2
22
22
  }
23
23
  }
24
24
 
25
- export async function normalizeIdentifierToLangaugeCode(langIdentifier: string) {
25
+ export async function normalizeIdentifierToLanguageCode(langIdentifier: string) {
26
26
  const result = await parseLangIdentifier(langIdentifier)
27
27
 
28
28
  return result.Name
@@ -65,4 +65,4 @@ export interface OnnxSessionOptions {
65
65
  logSeverityLevel?: 0 | 1 | 2 | 3 | 4
66
66
  }
67
67
 
68
- export type OnnxExecutionProvider = 'cpu' | 'dml'
68
+ export type OnnxExecutionProvider = 'cpu' | 'dml' | 'cuda'
@@ -82,8 +82,10 @@ export function resolveVersionTagForUnversionedPackageName(unversionedPackageNam
82
82
  const defaultVersionTag = '20230718'
83
83
 
84
84
  const packageVersionTagResolutionLookup: { [packageName: string]: string } = {
85
+ // SOX binary
85
86
  'sox-14.4.2-linux-minimal': '20230802',
86
87
 
88
+ // VITS voices
87
89
  'vits-de_DE-thorsten_emotional-medium': '20230808',
88
90
  'vits-en_GB-semaine-medium': '20230808',
89
91
  'vits-fr_FR-upmc-medium': '20230808',
@@ -91,21 +93,41 @@ const packageVersionTagResolutionLookup: { [packageName: string]: string } = {
91
93
  'vits-ro_RO-mihai-medium': '20230808',
92
94
  'vits-sr_RS-serbski_institut-medium': '20230808',
93
95
  'vits-tr_TR-dfki-medium': '20230808',
94
-
95
96
  'vits-cs_CZ-jirka-medium': '20230824',
96
97
  'vits-de_DE-thorsten-high': '20230824',
97
98
  'vits-hu_HU-anna-medium': '20230824',
98
99
  'vits-pt_PT-tugao-medium': '20230824',
99
100
  'vits-sk_SK-lili-medium': '20230824',
100
101
  'vits-tr_TR-fahrettin-medium': '20230824',
101
-
102
102
  'vits-ar_JO-kareem-medium': '20231022',
103
103
  'vits-cs_CZ-jirka-low': '20231022',
104
104
  'vits-en_US-hfc_male-medium': '20231022',
105
105
  'vits-en_US-libritts_r-medium': '20231022',
106
106
  'vits-hu_HU-imre-medium': '20231022',
107
107
  'vits-pl_PL-mc_speech-medium': '20231022',
108
-
108
+ 'vits-ar_JO-kareem-low': '20231126',
109
+ 'vits-en_US-hfc_female-medium': '20231126',
110
+ 'vits-de_DE-mls-medium': '20240316',
111
+ 'vits-en_GB-cori-high': '20240316',
112
+ 'vits-en_US-kristin-medium': '20240316',
113
+ 'vits-en_US-ljspeech-high': '20240316',
114
+ 'vits-en_US-ljspeech-medium': '20240316',
115
+ 'vits-es_MX-claude-high': '20240316',
116
+ 'vits-fa_IR-amir-medium': '20240316',
117
+ 'vits-fa_IR-gyro-medium': '20240316',
118
+ 'vits-fr_FR-mls-medium': '20240316',
119
+ 'vits-fr_FR-tom-medium': '20240316',
120
+ 'vits-nl_NL-mls-medium': '20240316',
121
+ 'vits-sl_SI-artur-medium': '20240316',
122
+ 'vits-tr_TR-fettah-medium': '20240316',
123
+ 'vits-it_IT-paola-medium': '20241001',
124
+ 'vits-en_US-norman-medium': '20241001',
125
+ 'vits-en_US-john-medium': '20241001',
126
+ 'vits-en_US-bryce-medium': '20241001',
127
+ 'vits-en_GB-cori-medium': '20241001',
128
+ 'vits-cy_GB-gwryw_gogleddol-medium': '20241001',
129
+
130
+ // Whisper (integrated engine) models
109
131
  'whisper-tiny': '20231126',
110
132
  'whisper-tiny.en': '20231126',
111
133
  'whisper-base': '20231126',
@@ -114,11 +136,12 @@ const packageVersionTagResolutionLookup: { [packageName: string]: string } = {
114
136
  'whisper-small.en': '20231126',
115
137
  'whisper-medium': '20231126',
116
138
  'whisper-medium.en': '20231126',
117
- 'whisper-large-v3': '20231126',
139
+ 'whisper-large-v3-turbo-fp16': '20241002',
118
140
 
119
- 'vits-ar_JO-kareem-low': '20231126',
120
- 'vits-en_US-hfc_female-medium': '20231126',
141
+ // Whisper tiktoken data
142
+ 'whisper-tiktoken-data': '20240408',
121
143
 
144
+ // FFMpeg binaries
122
145
  'ffmpeg-6.0-win32-x64': '20240316',
123
146
  'ffmpeg-6.0-win32-ia32': '20240316',
124
147
  'ffmpeg-6.0-darwin-x64': '20240316',
@@ -129,25 +152,13 @@ const packageVersionTagResolutionLookup: { [packageName: string]: string } = {
129
152
  'ffmpeg-6.0-linux-arm': '20240316',
130
153
  'ffmpeg-6.0-freebsd-x64': '20240316',
131
154
 
132
- 'vits-de_DE-mls-medium': '20240316',
133
- 'vits-en_GB-cori-high': '20240316',
134
- 'vits-en_US-kristin-medium': '20240316',
135
- 'vits-en_US-ljspeech-high': '20240316',
136
- 'vits-en_US-ljspeech-medium': '20240316',
137
- 'vits-es_MX-claude-high': '20240316',
138
- 'vits-fa_IR-amir-medium': '20240316',
139
- 'vits-fa_IR-gyro-medium': '20240316',
140
- 'vits-fr_FR-mls-medium': '20240316',
141
- 'vits-fr_FR-tom-medium': '20240316',
142
- 'vits-nl_NL-mls-medium': '20240316',
143
- 'vits-sl_SI-artur-medium': '20240316',
144
- 'vits-tr_TR-fettah-medium': '20240316',
145
-
155
+ // MDXNET models
146
156
  'mdxnet-UVR_MDXNET_1_9703': '20240330',
147
157
  'mdxnet-UVR_MDXNET_2_9682': '20240330',
148
158
  'mdxnet-UVR_MDXNET_3_9662': '20240330',
149
159
  'mdxnet-UVR_MDXNET_KARA': '20240330',
150
160
 
161
+ // whisper.cpp models
151
162
  'whisper.cpp-tiny': '20240405',
152
163
  'whisper.cpp-tiny-q5_1': '20240405',
153
164
  'whisper.cpp-tiny.en': '20240405',
@@ -174,19 +185,29 @@ const packageVersionTagResolutionLookup: { [packageName: string]: string } = {
174
185
  'whisper.cpp-large-v2-q5_0': '20240405',
175
186
  'whisper.cpp-large-v3': '20240405',
176
187
  'whisper.cpp-large-v3-q5_0': '20240405',
188
+ 'whisper.cpp-large-v3-turbo': '20241003',
189
+ 'whisper.cpp-large-v3-turbo-q5_0': '20241003',
177
190
 
178
- 'whisper.cpp-binaries-linux-x64-cpu-latest-patched': '20240405',
179
- 'whisper.cpp-binaries-windows-x64-cpu-latest-patched': '20240409',
191
+ // whisper.cpp binaries
192
+ 'whisper.cpp-binaries-linux-x64-cpu-1.6.2': '20241001',
193
+ 'whisper.cpp-binaries-windows-x64-cpu-1.6.2': '20241001',
194
+ 'whisper.cpp-binaries-windows-x64-cublas-12.4.0-1.6.2': '20241002',
180
195
 
181
- 'whisper-tiktoken-data': '20240408',
182
-
183
- 'whisper.cpp-binaries-windows-x64-cublas-12.4.0-latest-patched': '20240409',
184
- 'whisper.cpp-binaries-windows-x64-cublas-11.8.0-latest-patched': '20240409',
196
+ 'whisper.cpp-binaries-linux-x64-cpu-latest': '20241003',
197
+ 'whisper.cpp-binaries-windows-x64-cpu-latest': '20241003',
198
+ 'whisper.cpp-binaries-windows-x64-cublas-12.4.0-latest': '20241003',
185
199
 
186
- 'xenova-multilingual-e5-small-quantized': '20240504',
187
- 'xenova-nllb-200-distilled-600M-quantized': '20240505',
200
+ // E5 models
201
+ 'xenova-multilingual-e5-small-q8': '20240504',
188
202
  'xenova-multilingual-e5-small-fp16': '20240514',
189
203
  'xenova-multilingual-e5-base-fp16': '20240514',
190
- 'xenova-multilingual-e5-base-quantized': '20240514',
191
- 'xenova-multilingual-e5-large-quantized': '20240514',
204
+ 'xenova-multilingual-e5-base-q8': '20240514',
205
+ 'xenova-multilingual-e5-large-q8': '20240514',
206
+
207
+ // NLLB models
208
+ 'xenova-nllb-200-distilled-600M-q8': '20240505',
209
+
210
+ // W2V-BERT models
211
+ 'w2v-bert-2.0-int8': '20240517',
212
+ 'w2v-bert-2.0-uint8': '20240517',
192
213
  }
@@ -1,5 +1,4 @@
1
1
  import { sumVector } from '../math/VectorMath.js'
2
- import { logToStderr } from './Utilities.js'
3
2
 
4
3
  export abstract class RandomGenerator {
5
4
  getIntInRange(min: number, max: number) {
@@ -30,8 +29,8 @@ export abstract class RandomGenerator {
30
29
  return result
31
30
  }
32
31
 
33
- getNormallyDistributedVector(featureCount: number, meanVector: number[], standardDeviationVector: number[]) {
34
- const features = this.getNormallyDistributedValues(featureCount)
32
+ getNormallyDistributedVector(elementCount: number, meanVector: number[], standardDeviationVector: number[]) {
33
+ const features = this.getNormallyDistributedValues(elementCount)
35
34
 
36
35
  for (let i = 0; i < features.length; i++) {
37
36
  features[i] = meanVector[i] + (features[i] * standardDeviationVector[i])
@@ -104,134 +103,34 @@ export abstract class RandomGenerator {
104
103
  abstract nextInt32(): number
105
104
  }
106
105
 
107
- export class MurmurRNG extends RandomGenerator {
108
- state: number
109
-
110
- constructor(seed: number) {
111
- super()
112
-
113
- this.state = seed
114
- }
115
-
116
- nextFloat() {
117
- return this.nextUint32() / 4294967296
118
- }
119
-
106
+ export abstract class Int32RandomGenerator extends RandomGenerator {
120
107
  nextUint32() {
121
108
  return this.nextInt32() >>> 0
122
109
  }
123
110
 
124
- nextInt32() {
125
- const multiplier = 3332679571
126
-
127
- let s = this.state
128
-
129
- s = Math.imul(s, multiplier)
130
- s ^= s >>> 16
131
-
132
- s = Math.imul(s, multiplier)
133
- s ^= s >>> 10
134
-
135
- s = Math.imul(s, multiplier)
136
- s ^= s >>> 17
137
-
138
- this.state = s
139
-
140
- return s
141
- }
142
-
143
- static hashInt32(val: number, seed = 234928357) {
144
- const rng = new MurmurRNG(seed ^ val)
145
- return rng.nextUint32()
146
- }
147
- }
148
-
149
- export class XorShift32RNG extends RandomGenerator {
150
- state: number
151
-
152
- constructor(seed: number) {
153
- super()
154
-
155
- this.state = seed
156
- }
157
-
158
111
  nextFloat() {
159
- return this.nextUint32() / 4294967296
160
- }
161
-
162
- nextUint32() {
163
- return this.nextInt32() >>> 0
164
- }
165
-
166
- nextInt32() {
167
- let s = this.state
168
-
169
- s ^= s << 13
170
- s ^= s >>> 17
171
- s ^= s << 5
172
-
173
- this.state = s
174
-
175
- return s
112
+ return this.nextUint32() * (1 / 4294967296)
176
113
  }
177
114
  }
178
115
 
179
- export class LehmerRNG extends RandomGenerator {
116
+ export class XorShift32PRNG extends Int32RandomGenerator {
180
117
  state: number
181
118
 
182
119
  constructor(seed: number) {
183
120
  super()
184
121
 
185
- this.state = seed
186
- }
187
-
188
- nextFloat() {
189
- return this.nextUint32() / 4294967296
190
- }
191
-
192
- nextUint32() {
193
- return this.nextInt32() >>> 0
122
+ this.state = (3077908504 + seed) | 0
194
123
  }
195
124
 
196
125
  nextInt32() {
197
- let s = this.state
126
+ let state = this.state | 0
198
127
 
199
- s = s * 48271 % 0x7fffffff
128
+ state ^= state << 13
129
+ state ^= state >>> 17
130
+ state ^= state << 5
200
131
 
201
- this.state = s
202
-
203
- return s
204
- }
205
- }
206
-
207
- const log = logToStderr
208
-
209
- export function testRngCycleLength() {
210
- const seed = 1
211
-
212
- const rng = new XorShift32RNG(seed)
213
-
214
- const bucketCount = 1000000
215
- const seen: number[][] = []
216
-
217
- for (let i = 0; i < bucketCount; i++) {
218
- seen[i] = []
219
- }
220
-
221
- for (let i = 0; i < 4294967296; i++) {
222
- if (i % 1000000 == 0) {
223
- log(`${i} iterations`)
224
- }
225
-
226
- const r = rng.nextUint32()
227
-
228
- const bucket = seen[r % bucketCount]
229
-
230
- if (bucket.includes(r)) {
231
- log(`Cycles at iteration ${i}`)
232
- return
233
- }
132
+ this.state = state
234
133
 
235
- bucket.push(r)
134
+ return state
236
135
  }
237
136
  }