File size: 6,762 Bytes
6eabed3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5eda1fa
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
### training
```
#!/usr/bin/env bash

set -x

K2_ROOT=/path/to/k2
ICEFALL=/path/to/icefall

export PYTHONPATH=$K2_ROOT/k2/python:$PYTHONPATH
export PYTHONPATH=$K2_ROOT/build/lib:$PYTHONPATH
export PYTHONPATH=$ICEFALL:$PYTHONPATH

export CUDA_VISIBLE_DEVICES="0,1,2,3"

./pruned_transducer_stateless4/train.py \
  --exp-dir pruned_transducer_stateless4/exp \
  --full-libri 1 \
  --dynamic-chunk-training 1 \
  --short-chunk-size 32 \
  --num-left-chunks 4 \
  --causal-convolution 1 \
  --max-duration 300 \
  --world-size 4 \
  --start-epoch 1 \
  --num-epochs 30
```

### decoding
#### simulate streaming
```
#!/usr/bin/env bash                                                                                                                                           
                                                                                                                                                              
set -x                                                                                                                                                        
                                                                                                                                                              
K2_ROOT=/path/to/k2
ICEFALL=/path/to/icefall                                                                                                             
                                                                                                                                                              
export PYTHONPATH=$K2_ROOT/k2/python:$PYTHONPATH                                                                                                              
export PYTHONPATH=$K2_ROOT/build/lib:$PYTHONPATH                                                                                                              
export PYTHONPATH=$ICEFALL:$PYTHONPATH                                                                                                                        
                                                                                                                                                              
export CUDA_VISIBLE_DEVICES="0"                                                                                                                               
                                                                                                                                                              
for size in 1 2 4 8 16 32; do                                                                                                                                
  for left in 32 64 -1; do                                                                                                                                    
    ./pruned_transducer_stateless4/decode.py \                                                                                                                
            --simulate-streaming 1 \                                                                                                                          
            --decode-chunk-size ${size} \
            --left-context ${left} \
            --causal-convolution 1 \
            --use-averaged-model 1 \
            --epoch 29 \
            --avg 6 \
            --exp-dir ./pruned_transducer_stateless4/exp \
            --max-sym-per-frame 1 \
            --max-duration 1000 \
            --decoding-method greedy_search
  done
done
```

#### streaming
```
#!/usr/bin/env bash                                                                                                                                           
                                                                                                                                                              
set -x                                                                                                                                                        
                                                                                                                                                              
K2_ROOT=/path/to/k2
ICEFALL=/path/to/icefall                                                                                                              
                                                                                                                                                              
export PYTHONPATH=$K2_ROOT/k2/python:$PYTHONPATH                                                                                                              
export PYTHONPATH=$K2_ROOT/build/lib:$PYTHONPATH                                                                                                              
export PYTHONPATH=$ICEFALL:$PYTHONPATH                                                                                                                        
                                                                                                                                                              
export CUDA_VISIBLE_DEVICES="0"                                                                                                                               
            
#left_context=32                                                                                                                                               
#chunk_size=8
                                                                                                                                                                                                                                                                                                  
left_context=64                                                                                                                                               
chunk_size=16

for right in 0 2 4 8; do
  ./pruned_transducer_stateless4/streaming_decode.py \
    --left-context ${left_context} \
    --decode-chunk-size ${chunk_size} \
    --right-context ${right} \
    --exp-dir ./pruned_transducer_stateless4/exp \
    --use-averaged-model 1 \
    --epoch 29 \
    --avg 6 \
    --num-decode-streams 1000
done
```

### export
for pretrained.pt
```
python pruned_transducer_stateless4/export.py \
    --exp-dir ./pruned_transducer_stateless4/exp \
    --epoch 29 \
    --avg 6 \
    --streaming-model 1 \
    --causal-convolution 1
```
for cpu_jit.pt
```
python pruned_transducer_stateless4/export.py \
    --exp-dir ./pruned_transducer_stateless4/exp \
    --epoch 29 \
    --avg 6 \
    --streaming-model 1 \
    --causal-convolution 1 \
    --jit 1
```
---
license: apache-2.0
---