Xenova HF staff commited on
Commit
f4dbe6d
·
verified ·
1 Parent(s): fda0ee8

Update code snippets to use transformers.js v3

Browse files
Files changed (1) hide show
  1. README.md +5 -5
README.md CHANGED
@@ -16,10 +16,10 @@ npm i @xenova/transformers
16
 
17
  **Example:** Text-to-speech pipeline.
18
  ```js
19
- import { pipeline } from '@xenova/transformers';
20
 
21
  // Create a text-to-speech pipeline
22
- const synthesizer = await pipeline('text-to-speech', 'Xenova/speecht5_tts', { quantized: false });
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 '@xenova/transformers';
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', { quantized: false });
57
- const vocoder = await SpeechT5HifiGan.from_pretrained('Xenova/speecht5_hifigan', { quantized: false });
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(