Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
4 |
+
# W2v-BERT 2.0 speech encoder
|
5 |
+
|
6 |
+
We are open-sourcing our Conformer-based [W2v-BERT 2.0 speech encoder](#w2v-bert-20-speech-encoder) as described in Section 3.2.1 of the [paper](https://arxiv.org/pdf/2312.05187.pdf), which is at the core of our Seamless models.
|
7 |
+
|
8 |
+
| Model Name | #params | checkpoint |
|
9 |
+
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
10 |
+
| W2v-BERT 2.0 | 600M | [checkpoint](https://dl.fbaipublicfiles.com/seamless/models/conformer_shaw.pt)
|
11 |
+
|
12 |
+
Scaling data size for self-supervised pre-training has been empirically proven to be a relatively cheap, yet effective way to improve speech representation quality (Zhang et al., 2023a). Following such direction, we continued to add more unlabeled speech data, increasing the amount of our pre-training data from 1M hours (Seamless Communication et al., 2023) to approximately 4.5M hours.
|
13 |
+
Besides leveraging more pre-training data, we removed the random-projection quantizer (RPQ) (Chiu et al., 2022) and its associated loss previously incorporated in SeamlessM4T v1 (Seamless Communication et al., 2023).4 Akin to v1, the v2 w2v-BERT 2.0 comprises 24 Conformer layers (Gulati et al., 2020) with approximately 600M parameters and the same pre-training hyperparameters.
|
14 |
+
|
15 |
+
|
16 |
+
Here's how you should do a forward pass through the speech encoder:
|
17 |
+
|
18 |
+
```python
|
19 |
+
import torch
|
20 |
+
|
21 |
+
from fairseq2.data.audio import AudioDecoder, WaveformToFbankConverter
|
22 |
+
from fairseq2.memory import MemoryBlock
|
23 |
+
from fairseq2.nn.padding import get_seqs_and_padding_mask
|
24 |
+
from pathlib import Path
|
25 |
+
from seamless_communication.models.conformer_shaw import load_conformer_shaw_model
|
26 |
+
|
27 |
+
|
28 |
+
audio_wav_path, device, dtype = ...
|
29 |
+
audio_decoder = AudioDecoder(dtype=torch.float32, device=device)
|
30 |
+
fbank_converter = WaveformToFbankConverter(
|
31 |
+
num_mel_bins=80,
|
32 |
+
waveform_scale=2**15,
|
33 |
+
channel_last=True,
|
34 |
+
standardize=True,
|
35 |
+
device=device,
|
36 |
+
dtype=dtype,
|
37 |
+
)
|
38 |
+
collater = Collater(pad_value=1)
|
39 |
+
|
40 |
+
model = load_conformer_shaw_model("conformer_shaw", device=device, dtype=dtype)
|
41 |
+
model.eval()
|
42 |
+
|
43 |
+
with Path(audio_wav_path).open("rb") as fb:
|
44 |
+
block = MemoryBlock(fb.read())
|
45 |
+
|
46 |
+
decoded_audio = audio_decoder(block)
|
47 |
+
src = collater(fbank_converter(decoded_audio))["fbank"]
|
48 |
+
seqs, padding_mask = get_seqs_and_padding_mask(src)
|
49 |
+
|
50 |
+
with torch.inference_mode():
|
51 |
+
seqs, padding_mask = model.encoder_frontend(seqs, padding_mask)
|
52 |
+
seqs, padding_mask = model.encoder(seqs, padding_mask)
|
53 |
+
```
|