Closed
Description
System Info
- Latest version of V3
- Running in webworker
- Macbook pro 14
- Brave browser
The error being caught is a number, which stays the same on each run: 127037464
.
To remove as many variables as possible I then tried a simpler version of the example. Unfortunately I saw the same error, just with a different number: Uncaught 168274888
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
The MusicGen example generates an error instead of an audio array.
Reproduction
Steps taken to test:
git clone -b v3 https://github.com/xenova/transformers.js.git
cd transformers.js/
npm i
npm run build
Then using the contents of dist
as the js
folder in this minimal example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Musicgen</title>
</head>
<body>
<script type="module">
import { AutoTokenizer, MusicgenForConditionalGeneration } from './js/transformers.js';
// Load tokenizer and model
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/musicgen-small');
const model = await MusicgenForConditionalGeneration.from_pretrained(
'Xenova/musicgen-small', { dtype: 'fp32' }
);
// Prepare text input
const prompt = '80s pop track with bassy drums and synth';
const inputs = tokenizer(prompt);
// Generate audio
const audio_values = await model.generate({
...inputs,
max_new_tokens: 512,
do_sample: true,
guidance_scale: 3,
});
console.log("audio_values: ", audio_values);
/*
// (Optional) Write the output to a WAV file
import { wavefile } from './js/wavefile.js';
const wav = new wavefile.WaveFile();
wav.fromScratch(1, model.config.audio_encoder.sampling_rate, '32f', audio_values.data);
*/
</script>
</body>
</html>