Muhammadreza
commited on
Commit
•
e8af36e
1
Parent(s):
8c3b7b9
Update README.md
Browse files
README.md
CHANGED
@@ -3,60 +3,6 @@ library_name: transformers.js
|
|
3 |
license: cc-by-nc-4.0
|
4 |
---
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
> [!IMPORTANT]
|
11 |
-
> NOTE: MusicGen support is experimental and requires you to install Transformers.js [v3](https://github.com/xenova/transformers.js/tree/v3) from source.
|
12 |
-
|
13 |
-
If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [GitHub](https://github.com/xenova/transformers.js/tree/v3) using:
|
14 |
-
```bash
|
15 |
-
npm install xenova/transformers.js#v3
|
16 |
-
```
|
17 |
-
|
18 |
-
**Example:** Generate music with `Xenova/musicgen-small`.
|
19 |
-
```js
|
20 |
-
import { AutoTokenizer, MusicgenForConditionalGeneration } from '@xenova/transformers';
|
21 |
-
|
22 |
-
// Load tokenizer and model
|
23 |
-
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/musicgen-small');
|
24 |
-
const model = await MusicgenForConditionalGeneration.from_pretrained('Xenova/musicgen-small', {
|
25 |
-
dtype: {
|
26 |
-
text_encoder: 'q8',
|
27 |
-
decoder_model_merged: 'q8',
|
28 |
-
encodec_decode: 'fp32',
|
29 |
-
},
|
30 |
-
});
|
31 |
-
|
32 |
-
// Prepare text input
|
33 |
-
const prompt = 'a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130';
|
34 |
-
const inputs = tokenizer(prompt);
|
35 |
-
|
36 |
-
// Generate audio
|
37 |
-
const audio_values = await model.generate({
|
38 |
-
...inputs,
|
39 |
-
max_new_tokens: 500,
|
40 |
-
do_sample: true,
|
41 |
-
guidance_scale: 3,
|
42 |
-
});
|
43 |
-
|
44 |
-
// (Optional) Write the output to a WAV file
|
45 |
-
import wavefile from 'wavefile';
|
46 |
-
import fs from 'fs';
|
47 |
-
|
48 |
-
const wav = new wavefile.WaveFile();
|
49 |
-
wav.fromScratch(1, model.config.audio_encoder.sampling_rate, '32f', audio_values.data);
|
50 |
-
fs.writeFileSync('musicgen.wav', wav.toBuffer());
|
51 |
-
```
|
52 |
-
|
53 |
-
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/cJ9HFIDstOqJN0eGyJwlS.wav"></audio>
|
54 |
-
|
55 |
-
We also released an online demo, which you can try yourself: https://huggingface.co/spaces/Xenova/musicgen-web
|
56 |
-
|
57 |
-
|
58 |
-
<video controls src="https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/zc43B_VuUVJm4kOJPOHNh.mp4"></video>
|
59 |
-
|
60 |
-
---
|
61 |
-
|
62 |
-
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
|
|
|
3 |
license: cc-by-nc-4.0
|
4 |
---
|
5 |
|
6 |
+
# Avasaz ONNX (In Browser model)
|
7 |
|
8 |
+
Based on [Xenova](https://huggingface.co/xeonva/musicgen-small)'s ONNX quantization.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|