Xenova HF Staff commited on
Commit
e2a4ce5
·
verified ·
1 Parent(s): 0783298

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -19
README.md CHANGED
@@ -9,34 +9,40 @@ library_name: transformers.js
9
  [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).
10
 
11
 
12
- ## Usage
 
 
 
 
 
 
13
 
14
  **Example:** Transcribe English.
15
 
16
 
17
  ```js
18
- // npm i @xenova/transformers
19
- import { pipeline } from '@xenova/transformers';
20
 
21
- let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
 
22
 
23
- // Create translation pipeline
24
- let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
25
- let output = await transcriber(url);
26
  // { text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country." }
27
  ```
28
 
29
  **Example:** Transcribe English w/ timestamps.
30
 
31
  ```js
32
- // npm i @xenova/transformers
33
- import { pipeline } from '@xenova/transformers';
34
 
35
- let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
 
36
 
37
- // Create translation pipeline
38
- let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
39
- let output = await transcriber(url, { return_timestamps: true });
40
  // {
41
  // text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country."
42
  // chunks: [
@@ -49,14 +55,14 @@ let output = await transcriber(url, { return_timestamps: true });
49
  **Example:** Transcribe English w/ word-level timestamps.
50
 
51
  ```js
52
- // npm i @xenova/transformers
53
- import { pipeline } from '@xenova/transformers';
54
 
55
- let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
 
56
 
57
- // Create translation pipeline
58
- let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
59
- let output = await transcriber(url, { return_timestamps: 'word' });
60
  // {
61
  // "text": " And so my fellow Americans ask not what your country can do for you ask what you can do for your country.",
62
  // "chunks": [
 
9
  [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).
10
 
11
 
12
+
13
+ ## Usage (Transformers.js)
14
+
15
+ 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:
16
+ ```bash
17
+ npm i @huggingface/transformers
18
+ ```
19
 
20
  **Example:** Transcribe English.
21
 
22
 
23
  ```js
24
+ import { pipeline } from '@huggingface/transformers';
 
25
 
26
+ // Create speech recognition pipeline
27
+ const transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
28
 
29
+ // Transcribe audio from URL
30
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
31
+ const output = await transcriber(url);
32
  // { text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country." }
33
  ```
34
 
35
  **Example:** Transcribe English w/ timestamps.
36
 
37
  ```js
38
+ import { pipeline } from '@huggingface/transformers';
 
39
 
40
+ // Create speech recognition pipeline
41
+ const transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
42
 
43
+ // Transcribe audio from URL with timestamps
44
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
45
+ const output = await transcriber(url, { return_timestamps: true });
46
  // {
47
  // text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country."
48
  // chunks: [
 
55
  **Example:** Transcribe English w/ word-level timestamps.
56
 
57
  ```js
58
+ import { pipeline } from '@huggingface/transformers';
 
59
 
60
+ // Create speech recognition pipeline
61
+ const transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
62
 
63
+ // Transcribe audio from URL with word-level timestamps
64
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
65
+ const output = await transcriber(url, { return_timestamps: 'word' });
66
  // {
67
  // "text": " And so my fellow Americans ask not what your country can do for you ask what you can do for your country.",
68
  // "chunks": [