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-1.3B_covost2_en-to-15")
14
15# Load ZeroSwot Encoder
16commit_hash = "762878c55bf91406318983c724db22590a828e96"
17zeroswot_encoder = AutoModel.from_pretrained(
18 "johntsi/ZeroSwot-Large_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-1.3B_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-2B | ✗ | 2.0 | 20.7 | 34.2 | 33.8 | 28.3 | 24.1 | 22.9 | 32.5 | 41.5 | 23.5 | 16.2 | 27.6 | 34.5 | 19.8 | 18.6 | 38.5 | 27.8 |
| SeamlessM4T-L-v1 | ✗ | 2.3 | 24.5 | 41.6 | 33.6 | 35.9 | 28.5 | 19.3 | 39.0 | 39.4 | 23.8 | 15.7 | 35.0 | 42.5 | 22.7 | 23.9 | 33.1 | 30.6 |
| SeamlessM4T-L-v2 | ✗ | 2.3 | 25.4 | 43.6 | 35.5 | 37.0 | 29.3 | 19.2 | 40.2 | 39.7 | 24.8 | 16.4 | 36.2 | 43.7 | 23.4 | 24.7 | 35.9 | 31.7 |
| ZeroSwot-Large_asr-cv | ✓ | 0.35/1.65 | 19.8 | 36.1 | 22.6 | 31.8 | 23.6 | 16.8 | 34.2 | 33.6 | 17.5 | 11.8 | 28.9 | 36.8 | 19.1 | 17.5 | 32.2 | 25.5 |
| ZeroSwot-Large_asr-cv_mt-covost2 | ✓ | 0.35/1.65 | 25.7 | 40.0 | 29.0 | 32.8 | 27.2 | 26.6 | 37.1 | 47.1 | 25.7 | 18.9 | 33.2 | 39.3 | 25.3 | 19.8 | 40.5 | 31.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",
}