Update README.md
Browse files
README.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
| 2 |
library_name: "transformers.js"
|
| 3 |
---
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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`).
|
|
|
|
| 2 |
library_name: "transformers.js"
|
| 3 |
---
|
| 4 |
|
| 5 |
+
|
| 6 |
+
# Whisper
|
| 7 |
+
|
| 8 |
+
[openai/whisper-tiny.en](https://huggingface.co/openai/whisper-tiny.en) with ONNX weights to be compatible with [Transformers.js](https://huggingface.co/docs/transformers.js).
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
**Example:** Transcribe English.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
```js
|
| 17 |
+
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
|
| 18 |
+
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
|
| 19 |
+
let output = await transcriber(url);
|
| 20 |
+
// { text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country." }
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
**Example:** Transcribe English w/ timestamps.
|
| 24 |
+
|
| 25 |
+
```js
|
| 26 |
+
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
|
| 27 |
+
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
|
| 28 |
+
let output = await transcriber(url, { return_timestamps: true });
|
| 29 |
+
// {
|
| 30 |
+
// text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country."
|
| 31 |
+
// chunks: [
|
| 32 |
+
// { timestamp: [0, 8], text: " And so my fellow Americans ask not what your country can do for you" }
|
| 33 |
+
// { timestamp: [8, 11], text: " ask what you can do for your country." }
|
| 34 |
+
// ]
|
| 35 |
+
// }
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
**Example:** Transcribe English w/ word-level timestamps.
|
| 39 |
+
|
| 40 |
+
```js
|
| 41 |
+
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
|
| 42 |
+
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
|
| 43 |
+
let output = await transcriber(url, { return_timestamps: 'word' });
|
| 44 |
+
// {
|
| 45 |
+
// "text": " And so my fellow Americans ask not what your country can do for you ask what you can do for your country.",
|
| 46 |
+
// "chunks": [
|
| 47 |
+
// { "text": " And", "timestamp": [0, 0.78] },
|
| 48 |
+
// { "text": " so", "timestamp": [0.78, 1.06] },
|
| 49 |
+
// { "text": " my", "timestamp": [1.06, 1.46] },
|
| 50 |
+
// ...
|
| 51 |
+
// { "text": " for", "timestamp": [9.72, 9.92] },
|
| 52 |
+
// { "text": " your", "timestamp": [9.92, 10.22] },
|
| 53 |
+
// { "text": " country.", "timestamp": [10.22, 13.5] }
|
| 54 |
+
// ]
|
| 55 |
+
// }
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
|
| 60 |
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`).
|