carlito507
commited on
Commit
•
a1305b7
1
Parent(s):
19dd0ed
Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,43 @@
|
|
2 |
license: afl-3.0
|
3 |
language:
|
4 |
- fr
|
5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: afl-3.0
|
3 |
language:
|
4 |
- fr
|
5 |
+
---
|
6 |
+
Finetuned from [facebook/wav2vec2-large-960h-lv60-self](https://huggingface.co/facebook/wav2vec2-large-960h-lv60-self).
|
7 |
+
|
8 |
+
# Installation
|
9 |
+
1. PyTorch installation: https://pytorch.org/
|
10 |
+
2. Install transformers: https://huggingface.co/docs/transformers/installation
|
11 |
+
|
12 |
+
e.g., installation by conda
|
13 |
+
```
|
14 |
+
>> conda create -n wav2vec2 python=3.8
|
15 |
+
>> conda install pytorch cudatoolkit=11.3 -c pytorch
|
16 |
+
>> conda install -c conda-forge transformers
|
17 |
+
```
|
18 |
+
|
19 |
+
# Usage
|
20 |
+
```python
|
21 |
+
# Load the model and processor
|
22 |
+
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
|
23 |
+
import numpy as np
|
24 |
+
import torch
|
25 |
+
|
26 |
+
model = Wav2Vec2ForCTC.from_pretrained(r'yongjian/wav2vec2-large-a') # Note: PyTorch Model
|
27 |
+
processor = Wav2Vec2Processor.from_pretrained(r'yongjian/wav2vec2-large-a')
|
28 |
+
|
29 |
+
# Load input
|
30 |
+
np_wav = np.random.normal(size=(16000)).clip(-1, 1) # change it to your sample
|
31 |
+
|
32 |
+
# Inference
|
33 |
+
sample_rate = processor.feature_extractor.sampling_rate
|
34 |
+
with torch.no_grad():
|
35 |
+
model_inputs = processor(np_wav, sampling_rate=sample_rate, return_tensors="pt", padding=True)
|
36 |
+
logits = model(model_inputs.input_values, attention_mask=model_inputs.attention_mask).logits # use .cuda() for GPU acceleration
|
37 |
+
pred_ids = torch.argmax(logits, dim=-1).cpu()
|
38 |
+
pred_text = processor.batch_decode(pred_ids)
|
39 |
+
print('Transcription:', pred_text)
|
40 |
+
```
|
41 |
+
|
42 |
+
# Code
|
43 |
+
GitHub Repo:
|
44 |
+
https://github.com/CassiniHuy/wav2vec2_finetune
|