Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformers.js 3.0.2 not compatible with onnxruntime-web 1.20.0 #1016

Open
1 of 5 tasks
jozefchutka opened this issue Nov 7, 2024 · 1 comment
Open
1 of 5 tasks
Labels
bug Something isn't working

Comments

@jozefchutka
Copy link

jozefchutka commented Nov 7, 2024

System Info

transformers.js: 3.0.2
chrome: 130
OS: macos

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

I am trying to run rather simple automatic-speech-recognition model with onnxruntime-web v1.20.0 in a browser, witch fails in runtime with:

bug.mjs:5462 Uncaught (in promise) TypeError: yn[s] is not a function
    at ip (bug.mjs:5462:61)
    at ort-wasm-simd-threaded.jsep.wasm:0x7f697f
    at I.<computed> (bug.mjs:5679:28)
    at ar (bug.mjs:4926:45)
    at Qi (bug.mjs:5715:135)
    at s (bug.mjs:5718:19)
    at Do (bug.mjs:4576:26)
    at bug.mjs:5659:23

Reproduction

bug.src.mjs

import { env, pipeline } from "@huggingface/transformers";

env.allowLocalModels = false;
env.backends.onnx.wasm.numThreads = 1;
env.backends.onnx.wasm.wasmPaths = "https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.20.0/";

const buffer = await (await fetch("source.pcm")).arrayBuffer();
const audio = new Float32Array(buffer);
const pipe = await pipeline("automatic-speech-recognition", "onnx-community/whisper-base",
	{dtype:{encoder_model:"fp32", decoder_model_merged:"q4"}, device:"webgpu"});
const result = await pipe(audio, {chunk_length_s:30, stride_length_s:5, return_timestamps:true, language:"en"});
console.log(result);

index.html

<script src="bug.mjs" type="module"></script>

build:

ffmpeg -to 60 -i source.mp3 -filter_complex [0:1]aformat=channel_layouts=mono,aresample=16000[aout] -map [aout] -c:a pcm_f32le -f data source.pcm
npm install --save-exact --save-dev esbuild
npm install @huggingface/[email protected]
./node_modules/.bin/esbuild bug.src.mjs --bundle --format=esm --target=esnext --outfile=bug.mjs

When wasmPaths is not defined (using default value from transformers.js v3.0.2), there is no runtime error and program completes as expected

@jozefchutka jozefchutka added the bug Something isn't working label Nov 7, 2024
@NikhilVerma
Copy link
Contributor

I have the exact same error. I had to download the WASM from https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/ort-wasm-simd-threaded.jsep.wasm
and replace it with the one provided inside @huggingface/transformers to get it to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants