nguyenvulebinh commited on
Commit
438b1f8
1 Parent(s): a48472e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -0
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: ja
3
+ datasets:
4
+ - csj
5
+ tags:
6
+ - audio
7
+ - automatic-speech-recognition
8
+ license: cc-by-nc-4.0
9
+ ---
10
+
11
+ ### Usage
12
+
13
+ ```python
14
+ #!pip install transformers==4.17.0
15
+ #!pip install https://github.com/kpu/kenlm/archive/master.zip
16
+ #!pip install pyctcdecode==0.4.0
17
+ from transformers.file_utils import cached_path, hf_bucket_url
18
+ from importlib.machinery import SourceFileLoader
19
+ from transformers import Wav2Vec2ProcessorWithLM
20
+ from IPython.lib.display import Audio
21
+ import torchaudio
22
+ import torch
23
+
24
+ # Load model & processor
25
+ model_name = "nguyenvulebinh/wav2vec2-base-ja"
26
+ model = SourceFileLoader("model", cached_path(hf_bucket_url(model_name,filename="model_handling.py"))).load_module().Wav2Vec2ForCTC.from_pretrained(model_name)
27
+ processor = Wav2Vec2ProcessorWithLM.from_pretrained(model_name)
28
+
29
+ # Load an example audio (16k)
30
+ audio, sample_rate = torchaudio.load(cached_path(hf_bucket_url(model_name, filename="sample.wav")))
31
+ input_data = processor.feature_extractor(audio[0], sampling_rate=16000, return_tensors='pt')
32
+
33
+ # Infer
34
+ output = model(**input_data)
35
+
36
+ # Output transcript without LM
37
+ print(processor.tokenizer.decode(output.logits.argmax(dim=-1)[0].detach().cpu().numpy()))
38
+
39
+ # Output transcript with LM
40
+ print(processor.decode(output.logits.cpu().detach().numpy()[0], beam_width=100).text)
41
+ ```
42
+
43
+ ### Model Parameters License
44
+
45
+ The ASR model parameters are made available for non-commercial use only, under the terms of the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. You can find details at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
46
+
47
+
48
+ ### Contact
49
+
50
+ nguyenvulebinh@gmail.com
51
+
52
+ [![Follow](https://img.shields.io/twitter/follow/nguyenvulebinh?style=social)](https://twitter.com/intent/follow?screen_name=nguyenvulebinh)