csukuangfj commited on
Commit
018f80b
1 Parent(s): 19831bd

First commit

Browse files
README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Introduction
2
+
3
+ This repo contains torchscript models for Wav2Vec 2.0.
export-to-torchscript.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ # We used torch 1.8.1 to run this file, so
4
+ # you have to use torch >= 1.8.1 to load pt files saved by this file
5
+
6
+ import torch
7
+
8
+ import torchaudio
9
+ from pathlib import Path
10
+
11
+ models = [
12
+ "WAV2VEC2_ASR_BASE_10M",
13
+ "WAV2VEC2_ASR_BASE_100H",
14
+ "WAV2VEC2_ASR_BASE_960H",
15
+ "WAV2VEC2_ASR_LARGE_10M",
16
+ "WAV2VEC2_ASR_LARGE_100H",
17
+ "WAV2VEC2_ASR_LARGE_960H",
18
+ ]
19
+
20
+
21
+ @torch.no_grad()
22
+ def main():
23
+ for p in models:
24
+ f = p.lower() + ".pt"
25
+ if Path(f).is_file():
26
+ continue
27
+
28
+ print(f"Processing {p} {f}")
29
+ bundle = getattr(torchaudio.pipelines, p)
30
+ acoustic_model = bundle.get_model()
31
+ acoustic_model.eval()
32
+ m = torch.jit.script(acoustic_model)
33
+ torch.jit.save(m, f)
34
+
35
+ if Path("tokens.txt").is_file():
36
+ continue
37
+ print("generating tokens.txt")
38
+
39
+ symbols = bundle.get_labels()
40
+ symbol_ids = list(range(len(symbols)))
41
+ symbol_table = dict(zip(symbol_ids, symbols))
42
+ with open("tokens.txt", "w") as f:
43
+ for idx, sym in zip(symbol_ids, symbols):
44
+ f.write(f"{sym} {idx}\n")
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
test_wavs/1089-134686-0001.wav ADDED
Binary file (212 kB). View file
 
test_wavs/1221-135766-0001.wav ADDED
Binary file (535 kB). View file
 
test_wavs/1221-135766-0002.wav ADDED
Binary file (154 kB). View file
 
test_wavs/trans.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ 1089-134686-0001 AFTER EARLY NIGHTFALL THE YELLOW LAMPS WOULD LIGHT UP HERE AND THERE THE SQUALID QUARTER OF THE BROTHELS
2
+ 1221-135766-0001 GOD AS A DIRECT CONSEQUENCE OF THE SIN WHICH MAN THUS PUNISHED HAD GIVEN HER A LOVELY CHILD WHOSE PLACE WAS ON THAT SAME DISHONOURED BOSOM TO CONNECT HER PARENT FOR EVER WITH THE RACE AND DESCENT OF MORTALS AND TO BE FINALLY A BLESSED SOUL IN HEAVEN
3
+ 1221-135766-0002 YET THESE THOUGHTS AFFECTED HESTER PRYNNE LESS WITH HOPE THAN APPREHENSION
tokens.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - 0
2
+ | 1
3
+ E 2
4
+ T 3
5
+ A 4
6
+ O 5
7
+ N 6
8
+ I 7
9
+ H 8
10
+ S 9
11
+ R 10
12
+ D 11
13
+ L 12
14
+ U 13
15
+ M 14
16
+ W 15
17
+ C 16
18
+ F 17
19
+ G 18
20
+ Y 19
21
+ P 20
22
+ B 21
23
+ V 22
24
+ K 23
25
+ ' 24
26
+ X 25
27
+ J 26
28
+ Q 27
29
+ Z 28
wav2vec2_asr_base_10m.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a8fcf63387c5cb11126a4935844aadaec6984ac0a5c428e9802fb67ee33f5ee
3
+ size 377675280