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.
- package/data/schemas/options.json +310 -25
- package/dist/alignment/DTWMfccSequenceAlignment.d.ts +1 -1
- package/dist/alignment/DTWMfccSequenceAlignment.js +5 -5
- package/dist/alignment/DTWSequenceAlignmentWindowed.js +1 -3
- package/dist/alignment/DTWSequenceAlignmentWindowed.js.map +1 -1
- package/dist/alignment/{TextAlignment.d.ts → SemanticTextAlignment.d.ts} +4 -2
- package/dist/alignment/SemanticTextAlignment.js +336 -0
- package/dist/alignment/SemanticTextAlignment.js.map +1 -0
- package/dist/alignment/SpeechAlignment.d.ts +4 -3
- package/dist/alignment/SpeechAlignment.js +130 -39
- package/dist/alignment/SpeechAlignment.js.map +1 -1
- package/dist/api/API.d.ts +7 -3
- package/dist/api/API.js +7 -2
- package/dist/api/API.js.map +1 -1
- package/dist/api/APIOptions.d.ts +4 -1
- package/dist/api/Alignment.d.ts +1 -1
- package/dist/api/Alignment.js +13 -5
- package/dist/api/Alignment.js.map +1 -1
- package/dist/api/LanguageDetectionCommon.d.ts +6 -0
- package/dist/api/LanguageDetectionCommon.js +2 -0
- package/dist/api/LanguageDetectionCommon.js.map +1 -0
- package/dist/api/Recognition.js.map +1 -1
- package/dist/api/{LanguageDetection.d.ts → SpeechLanguageDetection.d.ts} +1 -25
- package/dist/api/{LanguageDetection.js → SpeechLanguageDetection.js} +1 -68
- package/dist/api/SpeechLanguageDetection.js.map +1 -0
- package/dist/api/{Translation.js → SpeechTranslation.js} +3 -3
- package/dist/api/SpeechTranslation.js.map +1 -0
- package/dist/api/Synthesis.d.ts +0 -1
- package/dist/api/Synthesis.js +4 -4
- package/dist/api/TextLanguageDetection.d.ts +21 -0
- package/dist/api/TextLanguageDetection.js +67 -0
- package/dist/api/TextLanguageDetection.js.map +1 -0
- package/dist/api/TextTranslation.d.ts +25 -0
- package/dist/api/TextTranslation.js +101 -0
- package/dist/api/TextTranslation.js.map +1 -0
- package/dist/api/TimelineTranslationAlignment.d.ts +23 -0
- package/dist/api/TimelineTranslationAlignment.js +92 -0
- package/dist/api/TimelineTranslationAlignment.js.map +1 -0
- package/dist/api/TranscriptAndTranslationAlignment.d.ts +35 -0
- package/dist/api/TranscriptAndTranslationAlignment.js +78 -0
- package/dist/api/TranscriptAndTranslationAlignment.js.map +1 -0
- package/dist/api/TranslationAlignment.d.ts +4 -3
- package/dist/api/TranslationAlignment.js +9 -8
- package/dist/api/TranslationAlignment.js.map +1 -1
- package/dist/api/VoiceActivityDetection.js +16 -1
- package/dist/api/VoiceActivityDetection.js.map +1 -1
- package/dist/audio/AudioBufferConversion.d.ts +0 -1
- package/dist/audio/AudioPlayer.d.ts +0 -1
- package/dist/audio/AudioPlayer.js +62 -41
- package/dist/audio/AudioPlayer.js.map +1 -1
- package/dist/audio/AudioUtilities.d.ts +0 -1
- package/dist/cli/CLI.d.ts +28 -7
- package/dist/cli/CLI.js +265 -37
- package/dist/cli/CLI.js.map +1 -1
- package/dist/codecs/FFMpegTranscoder.d.ts +0 -1
- package/dist/codecs/FFMpegTranscoder.js +7 -0
- package/dist/codecs/FFMpegTranscoder.js.map +1 -1
- package/dist/codecs/TIMITCodec.d.ts +0 -1
- package/dist/codecs/WaveCodec.d.ts +0 -1
- package/dist/dsp/FFT.d.ts +1 -1
- package/dist/dsp/FFT.js +6 -0
- package/dist/dsp/FFT.js.map +1 -1
- package/dist/dsp/KWeightingFilter.js +1 -1
- package/dist/dsp/KWeightingFilter.js.map +1 -1
- package/dist/dsp/MelSpectogram.d.ts +3 -2
- package/dist/dsp/MelSpectogram.js +14 -8
- package/dist/dsp/MelSpectogram.js.map +1 -1
- package/dist/math/VectorMath.d.ts +9 -9
- package/dist/math/VectorMath.js +10 -10
- package/dist/math/VectorMath.js.map +1 -1
- package/dist/nlp/ChineseSegmentation.js +4 -4
- package/dist/nlp/ChineseSegmentation.js.map +1 -1
- package/dist/nlp/Segmentation.d.ts +2 -2
- package/dist/nlp/Segmentation.js +20 -13
- package/dist/nlp/Segmentation.js.map +1 -1
- package/dist/recognition/OpenAICloudSTT.d.ts +2 -1
- package/dist/recognition/OpenAICloudSTT.js +30 -19
- package/dist/recognition/OpenAICloudSTT.js.map +1 -1
- package/dist/recognition/SileroSTT.d.ts +0 -1
- package/dist/recognition/WhisperCppSTT.d.ts +3 -3
- package/dist/recognition/WhisperCppSTT.js +21 -9
- package/dist/recognition/WhisperCppSTT.js.map +1 -1
- package/dist/recognition/WhisperSTT.d.ts +9 -6
- package/dist/recognition/WhisperSTT.js +227 -46
- package/dist/recognition/WhisperSTT.js.map +1 -1
- package/dist/server/Client.d.ts +3 -4
- package/dist/server/Client.js.map +1 -1
- package/dist/server/Worker.d.ts +3 -3
- package/dist/server/Worker.js +3 -2
- package/dist/server/Worker.js.map +1 -1
- package/dist/source-separation/MDXNetSourceSeparation.d.ts +0 -1
- package/dist/source-separation/MDXNetSourceSeparation.js +1 -1
- package/dist/source-separation/MDXNetSourceSeparation.js.map +1 -1
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts +12 -0
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js +68 -0
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js.map +1 -0
- package/dist/speech-language-detection/SileroLanguageDetection.d.ts +1 -2
- package/dist/speech-language-detection/SileroLanguageDetection.js +1 -1
- package/dist/speech-language-detection/SileroLanguageDetection.js.map +1 -1
- package/dist/subtitles/Subtitles.js +2 -2
- package/dist/subtitles/Subtitles.js.map +1 -1
- package/dist/synthesis/GoogleCloudTTS.d.ts +0 -1
- package/dist/synthesis/GoogleTranslateTTS.d.ts +0 -1
- package/dist/synthesis/GoogleTranslateTTS.js +6 -21
- package/dist/synthesis/GoogleTranslateTTS.js.map +1 -1
- package/dist/synthesis/StreamlabsPollyTTS.d.ts +0 -1
- package/dist/synthesis/VitsTTS.d.ts +0 -1
- package/dist/synthesis/VitsTTS.js +30 -0
- package/dist/synthesis/VitsTTS.js.map +1 -1
- package/dist/tests/Test.js +0 -31
- package/dist/tests/Test.js.map +1 -1
- package/dist/text-language-detection/FastTextLanguageDetection.d.ts +1 -1
- package/dist/text-language-detection/FastTextLanguageDetection.js.map +1 -1
- package/dist/text-language-detection/TinyLDLanguageDetection.d.ts +1 -1
- package/dist/text-language-detection/TinyLDLanguageDetection.js.map +1 -1
- package/dist/text-translation/DeepLTextTranslation.d.ts +2 -0
- package/dist/text-translation/DeepLTextTranslation.js +67 -0
- package/dist/text-translation/DeepLTextTranslation.js.map +1 -0
- package/dist/text-translation/GoogleTranslateTextTranslation.d.ts +10 -0
- package/dist/text-translation/GoogleTranslateTextTranslation.js +554 -0
- package/dist/text-translation/GoogleTranslateTextTranslation.js.map +1 -0
- package/dist/text-translation/NLLBTextTranslation.d.ts +2 -1
- package/dist/text-translation/NLLBTextTranslation.js +249 -19
- package/dist/text-translation/NLLBTextTranslation.js.map +1 -1
- package/dist/utilities/BinaryArrayConversion.d.ts +0 -1
- package/dist/utilities/BrowserRequestHeaders.d.ts +6 -0
- package/dist/utilities/BrowserRequestHeaders.js +52 -0
- package/dist/utilities/BrowserRequestHeaders.js.map +1 -0
- package/dist/utilities/BufferFileReadStream.d.ts +20 -0
- package/dist/utilities/BufferFileReadStream.js +81 -0
- package/dist/utilities/BufferFileReadStream.js.map +1 -0
- package/dist/utilities/DynamicUint8Array.d.ts +9 -0
- package/dist/utilities/DynamicUint8Array.js +31 -0
- package/dist/utilities/DynamicUint8Array.js.map +1 -0
- package/dist/utilities/FileSystem.d.ts +0 -2
- package/dist/utilities/Hashing.d.ts +3 -10
- package/dist/utilities/Hashing.js +10 -127
- package/dist/utilities/Hashing.js.map +1 -1
- package/dist/utilities/LEB128.d.ts +15 -5
- package/dist/utilities/LEB128.js +199 -119
- package/dist/utilities/LEB128.js.map +1 -1
- package/dist/utilities/LPVarInt.d.ts +11 -0
- package/dist/utilities/LPVarInt.js +187 -0
- package/dist/utilities/LPVarInt.js.map +1 -0
- package/dist/utilities/Locale.d.ts +1 -1
- package/dist/utilities/Locale.js +1 -1
- package/dist/utilities/OnnxUtilities.d.ts +1 -2
- package/dist/utilities/PVarInt.d.ts +4 -0
- package/dist/utilities/PVarInt.js +166 -0
- package/dist/utilities/PVarInt.js.map +1 -0
- package/dist/utilities/PackageManager.js +48 -25
- package/dist/utilities/PackageManager.js.map +1 -1
- package/dist/utilities/RandomGenerator.d.ts +3 -17
- package/dist/utilities/RandomGenerator.js +12 -81
- package/dist/utilities/RandomGenerator.js.map +1 -1
- package/dist/utilities/Timeline.d.ts +2 -0
- package/dist/utilities/Timeline.js +129 -20
- package/dist/utilities/Timeline.js.map +1 -1
- package/dist/utilities/Utilities.d.ts +1 -3
- package/dist/utilities/Utilities.js +30 -3
- package/dist/utilities/Utilities.js.map +1 -1
- package/dist/utilities/VarInt.d.ts +4 -0
- package/dist/utilities/VarInt.js +166 -0
- package/dist/utilities/VarInt.js.map +1 -0
- package/dist/utilities/VirtualFileReadStream.d.ts +20 -0
- package/dist/utilities/VirtualFileReadStream.js +79 -0
- package/dist/utilities/VirtualFileReadStream.js.map +1 -0
- package/dist/utilities/WebReader.js +7 -23
- package/dist/utilities/WebReader.js.map +1 -1
- package/dist/voice-activity-detection/SileroVAD.d.ts +0 -1
- package/docs/API.md +105 -3
- package/docs/CLI.md +51 -1
- package/docs/Engines.md +32 -3
- package/docs/Options.md +53 -12
- package/docs/Tasklist.md +1 -13
- package/package.json +20 -24
- package/src/alignment/DTWMfccSequenceAlignment.ts +5 -5
- package/src/alignment/DTWSequenceAlignmentWindowed.ts +1 -3
- package/src/alignment/SemanticTextAlignment.ts +467 -0
- package/src/alignment/SpeechAlignment.ts +214 -56
- package/src/api/API.ts +18 -2
- package/src/api/APIOptions.ts +14 -1
- package/src/api/Alignment.ts +31 -9
- package/src/api/LanguageDetectionCommon.ts +7 -0
- package/src/api/Recognition.ts +2 -0
- package/src/api/{LanguageDetection.ts → SpeechLanguageDetection.ts} +1 -119
- package/src/api/{Translation.ts → SpeechTranslation.ts} +2 -2
- package/src/api/Synthesis.ts +4 -4
- package/src/api/TextLanguageDetection.ts +116 -0
- package/src/api/TextTranslation.ts +177 -0
- package/src/api/TimelineTranslationAlignment.ts +162 -0
- package/src/api/TranscriptAndTranslationAlignment.ts +164 -0
- package/src/api/TranslationAlignment.ts +12 -10
- package/src/api/VoiceActivityDetection.ts +24 -3
- package/src/audio/AudioPlayer.ts +2 -0
- package/src/cli/CLI.ts +376 -40
- package/src/codecs/FFMpegTranscoder.ts +6 -0
- package/src/dsp/FFT.ts +8 -2
- package/src/dsp/KWeightingFilter.ts +1 -1
- package/src/dsp/MelSpectogram.ts +17 -8
- package/src/math/VectorMath.ts +15 -15
- package/src/nlp/ChineseSegmentation.ts +6 -4
- package/src/nlp/Segmentation.ts +18 -13
- package/src/recognition/OpenAICloudSTT.ts +47 -29
- package/src/recognition/WhisperCppSTT.ts +26 -11
- package/src/recognition/WhisperSTT.ts +364 -49
- package/src/server/Client.ts +3 -2
- package/src/server/Worker.ts +3 -2
- package/src/source-separation/MDXNetSourceSeparation.ts +1 -1
- package/src/speech-embeddings/WavToVec2BertFeatureEmbeddings.ts +107 -0
- package/src/speech-language-detection/SileroLanguageDetection.ts +2 -1
- package/src/subtitles/Subtitles.ts +2 -2
- package/src/synthesis/GoogleTranslateTTS.ts +7 -21
- package/src/synthesis/VitsTTS.ts +31 -3
- package/src/tests/Test.ts +1 -38
- package/src/text-language-detection/FastTextLanguageDetection.ts +1 -1
- package/src/text-language-detection/TinyLDLanguageDetection.ts +1 -1
- package/src/text-translation/DeepLTextTranslation.ts +88 -0
- package/src/text-translation/GoogleTranslateTextTranslation.ts +667 -0
- package/src/text-translation/NLLBTextTranslation.ts +261 -21
- package/src/typings/Fillers.d.ts +25 -2
- package/src/utilities/BrowserRequestHeaders.ts +59 -0
- package/src/utilities/DynamicUint8Array.ts +39 -0
- package/src/utilities/Hashing.ts +14 -167
- package/src/utilities/LEB128.ts +273 -148
- package/src/utilities/LPVarInt.ts +292 -0
- package/src/utilities/Locale.ts +1 -1
- package/src/utilities/OnnxUtilities.ts +1 -1
- package/src/utilities/PackageManager.ts +51 -30
- package/src/utilities/RandomGenerator.ts +12 -113
- package/src/utilities/Timeline.ts +162 -23
- package/src/utilities/Utilities.ts +40 -3
- package/src/utilities/VirtualFileReadStream.ts +109 -0
- package/src/utilities/WebReader.ts +9 -23
- package/dist/alignment/TextAlignment.js +0 -156
- package/dist/alignment/TextAlignment.js.map +0 -1
- package/dist/api/LanguageDetection.js.map +0 -1
- package/dist/api/Translation.js.map +0 -1
- package/src/alignment/TextAlignment.ts +0 -234
- /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
|
+
}
|
package/src/utilities/Locale.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function formatLanguageCodeWithName(languageCode: string, styleId: 1 | 2
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function
|
|
25
|
+
export async function normalizeIdentifierToLanguageCode(langIdentifier: string) {
|
|
26
26
|
const result = await parseLangIdentifier(langIdentifier)
|
|
27
27
|
|
|
28
28
|
return result.Name
|
|
@@ -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': '
|
|
139
|
+
'whisper-large-v3-turbo-fp16': '20241002',
|
|
118
140
|
|
|
119
|
-
|
|
120
|
-
'
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
'whisper.cpp-binaries-
|
|
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-
|
|
182
|
-
|
|
183
|
-
'whisper.cpp-binaries-windows-x64-cublas-12.4.0-latest
|
|
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
|
-
|
|
187
|
-
'xenova-
|
|
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-
|
|
191
|
-
'xenova-multilingual-e5-large-
|
|
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(
|
|
34
|
-
const features = this.getNormallyDistributedValues(
|
|
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
|
|
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
|
|
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
|
|
126
|
+
let state = this.state | 0
|
|
198
127
|
|
|
199
|
-
|
|
128
|
+
state ^= state << 13
|
|
129
|
+
state ^= state >>> 17
|
|
130
|
+
state ^= state << 5
|
|
200
131
|
|
|
201
|
-
this.state =
|
|
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
|
-
|
|
134
|
+
return state
|
|
236
135
|
}
|
|
237
136
|
}
|