ivangtorre commited on
Commit
dd9561c
1 Parent(s): 5787097

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -3
README.md CHANGED
@@ -1,3 +1,28 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ ---
4
+
5
+ ## Usage
6
+
7
+ The model can be used directly (without a language model) as follows:
8
+
9
+ ```python
10
+ from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
11
+ import torch
12
+ import torchaudio
13
+
14
+ # load model and processor
15
+ processor = Wav2Vec2Processor.from_pretrained("ivangtorre/wav2vec2-xls-r-300m-quechua")
16
+ model = Wav2Vec2ForCTC.from_pretrained("ivangtorre/wav2vec2-xls-r-300m-quechua")
17
+
18
+ # load dummy dataset and read soundfiles
19
+ file = torchaudio.load("quechua000573.wav")
20
+
21
+ # retrieve logits
22
+ logits = model(file[0]).logits
23
+
24
+ # take argmax and decode
25
+ predicted_ids = torch.argmax(logits, dim=-1)
26
+ transcription = processor.batch_decode(predicted_ids)
27
+ print("HF prediction: ", transcription)
28
+ ```