Xenova HF staff commited on
Commit
e9a3a57
·
verified ·
1 Parent(s): 3d294cc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md CHANGED
@@ -5,4 +5,32 @@ library_name: transformers.js
5
 
6
  https://huggingface.co/superb/wav2vec2-base-superb-ks with ONNX weights to be compatible with Transformers.js.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  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`).
 
5
 
6
  https://huggingface.co/superb/wav2vec2-base-superb-ks with ONNX weights to be compatible with Transformers.js.
7
 
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/@huggingface/transformers) using:
12
+ ```bash
13
+ npm i @huggingface/transformers
14
+ ```
15
+
16
+ **Example:** Perform audio classification with `Xenova/wav2vec2-base-superb-ks` and return top 3 results.
17
+ ```js
18
+ import { pipeline } from '@huggingface/transformers';
19
+
20
+ // Create an audio classification pipeline
21
+ const classifier = await pipeline('audio-classification', 'Xenova/wav2vec2-base-superb-ks');
22
+
23
+ // Predict class
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speech-commands_down.wav';
25
+ const output = await classifier(await read_audio(url), { top_k: 3});
26
+ console.log(output);
27
+ // [
28
+ // { label: 'down', score: 0.9998697638511658 },
29
+ // { label: 'go', score: 0.00009957332076737657 },
30
+ // { label: '_unknown_', score: 0.000029320701287360862 },
31
+ // ]
32
+ ```
33
+
34
+ ---
35
+
36
  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`).