Xenova HF staff commited on
Commit
8b1897b
1 Parent(s): e26400f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -0
README.md CHANGED
@@ -4,4 +4,43 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/facebook/mms-tts-ron 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/facebook/mms-tts-ron 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:** Generate Romanian speech with `Xenova/mms-tts-ron`.
15
+ ```js
16
+ import { pipeline } from '@xenova/transformers';
17
+
18
+ // Create a text-to-speech pipeline
19
+ const synthesizer = await pipeline('text-to-speech', 'Xenova/mms-tts-ron', {
20
+ quantized: false, // Remove this line to use the quantized version (default)
21
+ });
22
+
23
+ // Generate speech
24
+ const output = await synthesizer('Salut');
25
+ console.log(output);
26
+ // {
27
+ // audio: Float32Array(17408) [ ... ],
28
+ // sampling_rate: 16000
29
+ // }
30
+ ```
31
+
32
+ Optionally, save the audio to a wav file (Node.js):
33
+ ```js
34
+ import wavefile from 'wavefile';
35
+ import fs from 'fs';
36
+
37
+ const wav = new wavefile.WaveFile();
38
+ wav.fromScratch(1, output.sampling_rate, '32f', output.audio);
39
+ fs.writeFileSync('out.wav', wav.toBuffer());
40
+ ```
41
+
42
+ <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/VwXe86UBbX7uehbeZeJrH.wav"></audio>
43
+
44
+ ---
45
+
46
  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`).