Views
No views yet


| Models | ASR data | NLLB version |
|---|---|---|
| ZeroSwot-Medium_asr-mustc | MuST-C v1.0 | distilled-600M original |
| ZeroSwot-Medium_asr-mustc_mt-mustc | MuST-C v1.0 | distilled-600M finetuned w/ MuST-C |
| ZeroSwot-Large_asr-mustc | MuST-C v1.0 | distilled-1.3B original |
| ZeroSwot-Large_asr-mustc_mt-mustc | MuST-C v1.0 | distilled-1.3B finetuned w/ MuST-C |
| ZeroSwot-Medium_asr-cv | CommonVoice | distilled-600M original |
| ZeroSwot-Medium_asr-cv_mt-covost2 | CommonVoice | distilled-600M finetuned w/ CoVoST2 |
| ZeroSwot-Large_asr-cv | CommonVoice | distilled-1.3B original |
| ZeroSwot-Large_asr-cv_mt-covost2 | CommonVoice | distilled-1.3B finetuned w/ CoVoST2 |
pip install transformers torchaudio sentencepiece1from transformers import Wav2Vec2Processor, NllbTokenizer, AutoModel, AutoModelForSeq2SeqLM
2import torchaudio
3
4def load_and_resample_audio(audio_path, target_sr=16000):
5 audio, orig_freq = torchaudio.load(audio_path)
6 if orig_freq != target_sr:
7 audio = torchaudio.functional.resample(audio, orig_freq=orig_freq, new_freq=target_sr)
8 audio = audio.squeeze(0).numpy()
9 return audio
10
11# Load processors and tokenizers
12processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-large-960h-lv60-self")
13tokenizer = NllbTokenizer.from_pretrained("johntsi/nllb-200-distilled-600M_covost2_en-to-15")
14
15# Load ZeroSwot Encoder
16commit_hash = "4cebecf19220ee375078046392290fcc12d1e321"
17zeroswot_encoder = AutoModel.from_pretrained(
18 "johntsi/ZeroSwot-Medium_asr-cv_mt-covost2_en-to-15", trust_remote_code=True, revision=commit_hash,
19)
20zeroswot_encoder.eval()
21zeroswot_encoder.to("cuda")
22
23# Load NLLB Model
24nllb_model = AutoModelForSeq2SeqLM.from_pretrained("johntsi/nllb-200-distilled-600M_covost2_en-to-15")
25nllb_model.eval()
26nllb_model.to("cuda")
27
28# Load audio file
29audio = load_and_resample_audio(path_to_audio_file) # you can use "resources/sample.wav" for testing
30input_values = processor(audio, sampling_rate=16000, return_tensors="pt").to("cuda")
31
32# translation to German
33compressed_embeds, attention_mask = zeroswot_encoder(**input_values)
34predicted_ids = nllb_model.generate(
35 inputs_embeds=compressed_embeds,
36 attention_mask=attention_mask,
37 forced_bos_token_id=tokenizer.lang_code_to_id["deu_Latn"],
38 num_beams=5,
39)
40translation = tokenizer.decode(predicted_ids[0], skip_special_tokens=True)
41print(translation)| Models | ZS | Size (B) | Ar | Ca | Cy | De | Et | Fa | Id | Ja | Lv | Mn | Sl | Sv | Ta | Tr | Zh | Average |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| XLS-R-1B | ✗ | 1.0 | 19.2 | 32.1 | 31.8 | 26.2 | 22.4 | 21.3 | 30.3 | 39.9 | 22.0 | 14.9 | 25.4 | 32.3 | 18.1 | 17.1 | 36.7 | 26.0 |
| SeamlessM4T-Medium | ✗ | 1.2 | 20.8 | 37.3 | 29.9 | 31.4 | 23.3 | 17.2 | 34.8 | 37.5 | 19.5 | 12.9 | 29.0 | 37.3 | 18.9 | 19.8 | 30.0 | 26.6 |
| ZeroSwot-M_asr-cv | ✓ | 0.35/0.95 | 17.6 | 32.5 | 18.0 | 29.9 | 20.4 | 16.3 | 32.4 | 32.0 | 13.3 | 10.0 | 25.2 | 34.4 | 17.8 | 15.6 | 30.5 | 23.1 |
| ZeroSwot-M_asr-cv_mt-covost2 | ✓ | 0.35/0.95 | 24.4 | 38.7 | 28.8 | 31.2 | 26.2 | 26.0 | 36.0 | 46.0 | 24.8 | 19.0 | 31.6 | 37.8 | 24.4 | 18.6 | 39.0 | 30.2 |
@inproceedings{tsiamas-etal-2024-pushing,
title = {{Pushing the Limits of Zero-shot End-to-End Speech Translation}},
author = "Tsiamas, Ioannis and
G{\'a}llego, Gerard and
Fonollosa, Jos{\'e} and
Costa-juss{\`a}, Marta",
editor = "Ku, Lun-Wei and
Martins, Andre and
Srikumar, Vivek",
booktitle = "Findings of the Association for Computational Linguistics ACL 2024",
month = aug,
year = "2024",
address = "Bangkok, Thailand and virtual meeting",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.findings-acl.847",
pages = "14245--14267",
}