Update code snippets to use transformers.js v3
Browse files
README.md
CHANGED
@@ -16,10 +16,10 @@ npm i @xenova/transformers
|
|
16 |
|
17 |
**Example:** Text-to-speech pipeline.
|
18 |
```js
|
19 |
-
import { pipeline } from '@
|
20 |
|
21 |
// Create a text-to-speech pipeline
|
22 |
-
const synthesizer = await pipeline('text-to-speech', 'Xenova/speecht5_tts', {
|
23 |
|
24 |
// Generate speech
|
25 |
const speaker_embeddings = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin';
|
@@ -45,7 +45,7 @@ fs.writeFileSync('result.wav', wav.toBuffer());
|
|
45 |
|
46 |
**Example:** Load processor, tokenizer, and models separately.
|
47 |
```js
|
48 |
-
import { AutoTokenizer, AutoProcessor, SpeechT5ForTextToSpeech, SpeechT5HifiGan, Tensor } from '@
|
49 |
|
50 |
// Load the tokenizer and processor
|
51 |
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/speecht5_tts');
|
@@ -53,8 +53,8 @@ const processor = await AutoProcessor.from_pretrained('Xenova/speecht5_tts');
|
|
53 |
|
54 |
// Load the models
|
55 |
// NOTE: We use the unquantized versions as they are more accurate
|
56 |
-
const model = await SpeechT5ForTextToSpeech.from_pretrained('Xenova/speecht5_tts', {
|
57 |
-
const vocoder = await SpeechT5HifiGan.from_pretrained('Xenova/speecht5_hifigan', {
|
58 |
|
59 |
// Load speaker embeddings from URL
|
60 |
const speaker_embeddings_data = new Float32Array(
|
|
|
16 |
|
17 |
**Example:** Text-to-speech pipeline.
|
18 |
```js
|
19 |
+
import { pipeline } from '@huggingface/transformers';
|
20 |
|
21 |
// Create a text-to-speech pipeline
|
22 |
+
const synthesizer = await pipeline('text-to-speech', 'Xenova/speecht5_tts', { dtype: "fp32" });
|
23 |
|
24 |
// Generate speech
|
25 |
const speaker_embeddings = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin';
|
|
|
45 |
|
46 |
**Example:** Load processor, tokenizer, and models separately.
|
47 |
```js
|
48 |
+
import { AutoTokenizer, AutoProcessor, SpeechT5ForTextToSpeech, SpeechT5HifiGan, Tensor } from '@huggingface/transformers';
|
49 |
|
50 |
// Load the tokenizer and processor
|
51 |
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/speecht5_tts');
|
|
|
53 |
|
54 |
// Load the models
|
55 |
// NOTE: We use the unquantized versions as they are more accurate
|
56 |
+
const model = await SpeechT5ForTextToSpeech.from_pretrained('Xenova/speecht5_tts', { dtype: 'fp32' });
|
57 |
+
const vocoder = await SpeechT5HifiGan.from_pretrained('Xenova/speecht5_hifigan', { dtype: 'fp32' });
|
58 |
|
59 |
// Load speaker embeddings from URL
|
60 |
const speaker_embeddings_data = new Float32Array(
|