Xenova HF staff commited on
Commit
59e0328
1 Parent(s): 269f137

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -0
README.md CHANGED
@@ -3,5 +3,43 @@ library_name: transformers.js
3
  ---
4
 
5
  https://huggingface.co/facebook/mms-tts-ara 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`).
 
3
  ---
4
 
5
  https://huggingface.co/facebook/mms-tts-ara with ONNX weights to be compatible with Transformers.js.
6
+ ## Usage (Transformers.js)
7
+
8
+ 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:
9
+ ```bash
10
+ npm i @xenova/transformers
11
+ ```
12
+
13
+ **Example:** Generate Arabic speech with `Xenova/mms-tts-ara`.
14
+ ```js
15
+ import { pipeline } from '@xenova/transformers';
16
+
17
+ // Create a text-to-speech pipeline
18
+ const synthesizer = await pipeline('text-to-speech', 'Xenova/mms-tts-ara', {
19
+ quantized: false, // Remove this line to use the quantized version (default)
20
+ });
21
+
22
+ // Generate speech
23
+ const output = await synthesizer('مرحبا');
24
+ console.log(output);
25
+ // {
26
+ // audio: Float32Array(17152) [ ... ],
27
+ // sampling_rate: 16000
28
+ // }
29
+ ```
30
+
31
+ Optionally, save the audio to a wav file (Node.js):
32
+ ```js
33
+ import wavefile from 'wavefile';
34
+ import fs from 'fs';
35
+
36
+ const wav = new wavefile.WaveFile();
37
+ wav.fromScratch(1, output.sampling_rate, '32f', output.audio);
38
+ fs.writeFileSync('out.wav', wav.toBuffer());
39
+ ```
40
+
41
+ <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/UKJ3GxqeAsrAirQHQS7b-.wav"></audio>
42
+
43
+ ---
44
 
45
  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`).