File size: 1,200 Bytes
22ec72d
 
 
d9eaede
2bcd5b9
d9eaede
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
license: apache-2.0
---
# NLLB-600M Finetuned for Robustness
We finetuned NLLB-200-distilled-600M using adapters for robustness to ASR and synthetic non-native speakers noise. This model can only be used for translating from en to de, it, es, nl and el.

## How to use

Start by installing transformers with NLLB-200 model with added adapters
```bash
git clone https://gitlab.com/horizon-europe-voxreality/multilingual-translation/speech-translation-demo.git
cd speech-translation-demo
# You might need to switch to dev branch
pip install -e transformers
```
And now we can use the model:
```python

model_name = 'voxreality/nllb-asr-synthetic-robust'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = M2M100ForConditionalGenerationWithAdapters.from_pretrained(model_name)

src_lang = 'eng_Latn'
tgt_lang = 'deu_Latn'

input_text = "This is a good day"

tokenizer.src_lang = src_lang
inputs = tokenizer(input_text, return_tensors='pt').to(model.device)
model_output = model.generate(**inputs,
                              forced_bos_token_id=tokenizer.lang_code_to_id[tgt_lang])
output_text = tokenizer.batch_decode(model_output, skip_special_tokens=True)[0]

print(output_text)

```