Xenova HF staff commited on
Commit
03199ca
·
1 Parent(s): 5a3362d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md CHANGED
@@ -4,4 +4,32 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/superb/hubert-base-superb-ks 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/superb/hubert-base-superb-ks with ONNX weights to be compatible with Transformers.js.
6
 
7
+ ## Usage (Transformers.js)
8
+
9
+ 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:
10
+ ```bash
11
+ npm i @xenova/transformers
12
+ ```
13
+
14
+ **Example:** Speech command recognition w/ `Xenova/hubert-base-superb-ks`.
15
+
16
+ ```javascript
17
+ import { pipeline } from '@xenova/transformers';
18
+
19
+ // Create audio classification pipeline
20
+ const classifier = await pipeline('audio-classification', 'Xenova/hubert-base-superb-ks');
21
+
22
+ // Classify audio
23
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speech-commands_down.wav';
24
+ const output = await classifier(url, { topk: 5 });
25
+ // [
26
+ // { label: 'down', score: 0.9954305291175842 },
27
+ // { label: 'go', score: 0.004518700763583183 },
28
+ // { label: '_unknown_', score: 0.00005029444946558215 },
29
+ // { label: 'no', score: 4.877569494965428e-7 },
30
+ // { label: 'stop', score: 5.504634081887616e-9 }
31
+ // ]
32
+ ```
33
+ ---
34
+
35
  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`).