Update README.md
Browse files
README.md
CHANGED
@@ -4,4 +4,36 @@ library_name: transformers.js
|
|
4 |
|
5 |
https://huggingface.co/facebook/hubert-base-ls960 with ONNX weights to be compatible with Transformers.js.
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
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`).
|
|
|
4 |
|
5 |
https://huggingface.co/facebook/hubert-base-ls960 with ONNX weights to be compatible with Transformers.js.
|
6 |
|
7 |
+
https://huggingface.co/laion/larger_clap_music_and_speech with ONNX weights to be compatible with Transformers.js.
|
8 |
+
|
9 |
+
## Usage (Transformers.js)
|
10 |
+
|
11 |
+
If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@xenova/transformers) using:
|
12 |
+
```bash
|
13 |
+
npm i @xenova/transformers
|
14 |
+
```
|
15 |
+
|
16 |
+
**Example:** Load and run a `HubertModel` for feature extraction.
|
17 |
+
```javascript
|
18 |
+
import { AutoProcessor, AutoModel, read_audio } from '@xenova/transformers';
|
19 |
+
|
20 |
+
// Read and preprocess audio
|
21 |
+
const processor = await AutoProcessor.from_pretrained('Xenova/hubert-base-ls960');
|
22 |
+
const audio = await read_audio('https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav', 16000);
|
23 |
+
const inputs = await processor(audio);
|
24 |
+
|
25 |
+
// Load and run model with inputs
|
26 |
+
const model = await AutoModel.from_pretrained('Xenova/hubert-base-ls960');
|
27 |
+
const output = await model(inputs);
|
28 |
+
// {
|
29 |
+
// last_hidden_state: Tensor {
|
30 |
+
// dims: [ 1, 549, 768 ],
|
31 |
+
// type: 'float32',
|
32 |
+
// data: Float32Array(421632) [0.0682469978928566, 0.08104046434164047, -0.4975186586380005, ...],
|
33 |
+
// size: 421632
|
34 |
+
// }
|
35 |
+
// }
|
36 |
+
```
|
37 |
+
---
|
38 |
+
|
39 |
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`).
|