Commit
•
255ed69
1
Parent(s):
ca96ef6
Improve Transformers.js usage instructions (#4)
Browse files- Improve Transformers.js usage instructions (6ba4f165085b52248fb528e7d5c2be86a91a40b1)
Co-authored-by: Joshua <[email protected]>
README.md
CHANGED
@@ -323,17 +323,25 @@ make -j && ./main -m models/ggml-distil-small.en.bin -f samples/jfk.wav
|
|
323 |
|
324 |
### Transformers.js
|
325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
```js
|
327 |
import { pipeline } from '@xenova/transformers';
|
328 |
|
329 |
-
|
330 |
|
331 |
-
|
332 |
-
|
333 |
// { text: " And so my fellow Americans, ask not what your country can do for you. Ask what you can do for your country." }
|
334 |
```
|
335 |
|
336 |
-
Check out the online [Distil-Whisper Web demo](https://huggingface.co/distil-whisper
|
337 |
|
338 |
See the [docs](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline) for more information.
|
339 |
|
|
|
323 |
|
324 |
### Transformers.js
|
325 |
|
326 |
+
Distil-Whisper can even run completely in your web browser with [Transformers.js](http://github.com/xenova/transformers.js):
|
327 |
+
|
328 |
+
1. Install Transformers.js from [NPM](https://www.npmjs.com/package/@xenova/transformers):
|
329 |
+
```bash
|
330 |
+
npm i @xenova/transformers
|
331 |
+
```
|
332 |
+
|
333 |
+
2. Import the library and perform inference with the pipeline API.
|
334 |
```js
|
335 |
import { pipeline } from '@xenova/transformers';
|
336 |
|
337 |
+
const transcriber = await pipeline('automatic-speech-recognition', 'distil-whisper/distil-small.en');
|
338 |
|
339 |
+
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
|
340 |
+
const output = await transcriber(url);
|
341 |
// { text: " And so my fellow Americans, ask not what your country can do for you. Ask what you can do for your country." }
|
342 |
```
|
343 |
|
344 |
+
Check out the online [Distil-Whisper Web demo](https://huggingface.co/spaces/Xenova/distil-whisper-web) to try it out yourself. As you'll see, it runs locally in your browser: no server required!
|
345 |
|
346 |
See the [docs](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline) for more information.
|
347 |
|