TencentGameMate commited on
Commit
229b61b
·
1 Parent(s): 63cbc61

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md CHANGED
@@ -1,3 +1,48 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+
5
+ This model does not have a tokenizer as it was pretrained on audio alone.
6
+ In order to use this model speech recognition, a tokenizer should be created and the model should be fine-tuned on labeled text data.
7
+
8
+ python package:
9
+ transformers==4.16.2
10
+
11
+ ```python
12
+
13
+
14
+ import torch
15
+ import torch.nn.functional as F
16
+ import soundfile as sf
17
+ from fairseq import checkpoint_utils
18
+
19
+ from transformers import (
20
+ Wav2Vec2FeatureExtractor,
21
+ HubertModel,
22
+ )
23
+ from transformers.models.wav2vec2.modeling_wav2vec2 import _compute_mask_indices
24
+
25
+ model_path=""
26
+ wav_path=""
27
+
28
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(model_path)
29
+ model = HubertModel.from_pretrained(model_path)
30
+
31
+ # for pretrain: Wav2Vec2ForPreTraining
32
+ # model = Wav2Vec2ForPreTraining.from_pretrained(model_path)
33
+
34
+ model = model.to(device)
35
+ model = model.half()
36
+ model.eval()
37
+
38
+ wav, sr = sf.read(wav_path)
39
+ input_values = feature_extractor(wav, return_tensors="pt").input_values
40
+ input_values = input_values.half()
41
+ input_values = input_values.to(device)
42
+
43
+ with torch.no_grad():
44
+ outputs = model(input_values)
45
+ last_hidden_state = outputs.last_hidden_state
46
+
47
+
48
+ ```