Skip to content

Commit 5b5e5ed

Browse files
authored
[version] Update to 3.4.0
* Update types * hotfix: Allow user to pass whisper language as special token * Update onnxruntime-web version * [version] Update to 3.4.0
1 parent a5322c4 commit 5b5e5ed

File tree

11 files changed

+32
-23
lines changed

11 files changed

+32
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ npm i @huggingface/transformers
4747
Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN or static hosting. For example, using [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can import the library with:
4848
```html
4949
<script type="module">
50-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.3.3';
50+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.4.0';
5151
</script>
5252
```
5353

@@ -155,7 +155,7 @@ Check out the Transformers.js [template](https://huggingface.co/new-space?templa
155155

156156

157157

158-
By default, Transformers.js uses [hosted pretrained models](https://huggingface.co/models?library=transformers.js) and [precompiled WASM binaries](https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.3.3/dist/), which should work out-of-the-box. You can customize this as follows:
158+
By default, Transformers.js uses [hosted pretrained models](https://huggingface.co/models?library=transformers.js) and [precompiled WASM binaries](https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.4.0/dist/), which should work out-of-the-box. You can customize this as follows:
159159

160160
### Settings
161161

docs/snippets/2_installation.snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ npm i @huggingface/transformers
77
Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN or static hosting. For example, using [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can import the library with:
88
```html
99
<script type="module">
10-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.3.3';
10+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.4.0';
1111
</script>
1212
```

docs/snippets/4_custom-usage.snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
By default, Transformers.js uses [hosted pretrained models](https://huggingface.co/models?library=transformers.js) and [precompiled WASM binaries](https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.3.3/dist/), which should work out-of-the-box. You can customize this as follows:
3+
By default, Transformers.js uses [hosted pretrained models](https://huggingface.co/models?library=transformers.js) and [precompiled WASM binaries](https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.4.0/dist/), which should work out-of-the-box. You can customize this as follows:
44

55
### Settings
66

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/transformers",
3-
"version": "3.3.3",
3+
"version": "3.4.0",
44
"description": "State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!",
55
"main": "./src/transformers.js",
66
"types": "./types/transformers.d.ts",
@@ -57,7 +57,7 @@
5757
"dependencies": {
5858
"@huggingface/jinja": "^0.3.3",
5959
"onnxruntime-node": "1.20.1",
60-
"onnxruntime-web": "1.22.0-dev.20250306-aafa8d170a",
60+
"onnxruntime-web": "1.22.0-dev.20250306-ccf8fdd9ea",
6161
"sharp": "^0.33.5"
6262
},
6363
"devDependencies": {
@@ -69,7 +69,7 @@
6969
"jest-environment-node": "^30.0.0-alpha.6",
7070
"jsdoc-to-markdown": "^9.1.1",
7171
"prettier": "3.4.2",
72-
"typescript": "^5.7.2",
72+
"typescript": "^5.8.2",
7373
"wavefile": "11.0.0",
7474
"webpack": "^5.97.1",
7575
"webpack-cli": "^5.1.4",

src/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import fs from 'fs';
2626
import path from 'path';
2727
import url from 'url';
2828

29-
const VERSION = '3.3.3';
29+
const VERSION = '3.4.0';
3030

3131
// Check if various APIs are available (depends on environment)
3232
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";

src/models/idefics3/image_processing_idefics3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class Idefics3ImageProcessor extends ImageProcessor {
147147
const start_offset = i * pixel_attention_mask_stride + num_patches * h * w;
148148
const end_offset = (i + 1) * pixel_attention_mask_stride;
149149

150-
// @ts-expect-error
150+
// @ts-ignore
151151
pixel_attention_mask_data.fill(false, start_offset, end_offset);
152152
}
153153
}

src/models/whisper/common_whisper.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export function whisper_language_to_code(language) {
135135
if (language_code === undefined) {
136136
// User provided something that is not a language name
137137

138+
// Perhaps the user passed the special token itself
139+
const language_special_token = language.match(/^<\|([a-z]{2})\|>$/);
140+
if (language_special_token) {
141+
language = language_special_token[1];
142+
}
143+
138144
if (WHISPER_LANGUAGE_MAPPING.has(language)) {
139145
// User provided the language code directly (e.g., "en")
140146
language_code = language;
@@ -144,7 +150,7 @@ export function whisper_language_to_code(language) {
144150
const is_language_code = language.length === 2;
145151
const langs = is_language_code ? WHISPER_LANGUAGE_MAPPING.keys() : WHISPER_LANGUAGE_MAPPING.values();
146152

147-
throw new Error(`Language "${language}" is not supported. Must be one of: ${JSON.stringify(langs)}`);
153+
throw new Error(`Language "${language}" is not supported. Must be one of: ${JSON.stringify(Array.from(langs))}`);
148154
}
149155
}
150156
return language_code;

src/utils/audio.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ function hertz_to_mel(freq, mel_scale = "htk") {
150150
throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');
151151
}
152152

153+
// @ts-expect-error ts(2322)
153154
return typeof freq === 'number' ? fn(freq) : freq.map(x => fn(x));
154155
}
155156

@@ -173,6 +174,7 @@ function mel_to_hertz(mels, mel_scale = "htk") {
173174
throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');
174175
}
175176

177+
// @ts-expect-error ts(2322)
176178
return typeof mels === 'number' ? fn(mels) : mels.map(x => fn(x));
177179
}
178180

src/utils/maths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
/**
12-
* @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray
12+
* @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float16Array | Float32Array | Float64Array} TypedArray
1313
* @typedef {BigInt64Array | BigUint64Array} BigTypedArray
1414
* @typedef {TypedArray | BigTypedArray} AnyTypedArray
1515
*/

0 commit comments

Comments
 (0)