yongjian commited on
Commit
5312b07
1 Parent(s): 6707524

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - LIUM/tedlium
5
+ tags:
6
+ - speech
7
+ - audio
8
+ - automatic-speech-recognition
9
+ ---
10
+ Finetuned from [facebook/wav2vec2-large-960h-lv60-self](https://huggingface.co/facebook/wav2vec2-large-960h-lv60-self).
11
+
12
+ # Installation
13
+ 1. PyTorch installation: https://pytorch.org/
14
+ 2. Install transformers: https://huggingface.co/docs/transformers/installation
15
+
16
+ e.g., installation by conda
17
+ ```
18
+ >> conda create -n wav2vec2 python=3.8
19
+ >> conda install pytorch cudatoolkit=11.3 -c pytorch
20
+ >> conda install -c conda-forge transformers
21
+ ```
22
+
23
+ # Usage
24
+ ```python
25
+ # Load the model and processor
26
+ from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
27
+ import numpy as np
28
+ import torch
29
+
30
+ model = Wav2Vec2ForCTC.from_pretrained(r'yongjian/wav2vec2-large-a')
31
+ processor = Wav2Vec2Processor.from_pretrained(r'yongjian/wav2vec2-large-a')
32
+
33
+ # Load input
34
+ np_wav = np.random.normal(size=(16000)).clip(-1, 1) # change it to your sample
35
+
36
+ # Inference
37
+ sample_rate = processor.feature_extractor.sampling_rate
38
+ with torch.no_grad():
39
+ model_inputs = processor(np_wav, sampling_rate=sample_rate, return_tensors="pt", padding=True)
40
+ logits = model(model_inputs.input_values, attention_mask=model_inputs.attention_mask).logits # use .cuda() for GPU acceleration
41
+ pred_ids = torch.argmax(logits, dim=-1).cpu()
42
+ pred_text = processor.batch_decode(pred_ids)
43
+ print('Transcription:', pred_text)
44
+ ```