TencentGameMate commited on
Commit
94042d5
1 Parent(s): bb2f849

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md CHANGED
@@ -1,3 +1,47 @@
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
+
18
+ from transformers import (
19
+ Wav2Vec2FeatureExtractor,
20
+ HubertModel,
21
+ )
22
+
23
+
24
+ model_path=""
25
+ wav_path=""
26
+
27
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(model_path)
28
+ model = HubertModel.from_pretrained(model_path)
29
+
30
+ # for pretrain: Wav2Vec2ForPreTraining
31
+ # model = Wav2Vec2ForPreTraining.from_pretrained(model_path)
32
+
33
+ model = model.to(device)
34
+ model = model.half()
35
+ model.eval()
36
+
37
+ wav, sr = sf.read(wav_path)
38
+ input_values = feature_extractor(wav, return_tensors="pt").input_values
39
+ input_values = input_values.half()
40
+ input_values = input_values.to(device)
41
+
42
+ with torch.no_grad():
43
+ outputs = model(input_values)
44
+ last_hidden_state = outputs.last_hidden_state
45
+
46
+
47
+ ```