File size: 942 Bytes
7f2211b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re


def main():
    asr_result = """
sample rate: 8000
sample number: 39120
do StreamingVad Init...
5
3520
VadFlagPrepare
3820
VadFlagSpeaking
4360
VadFlagNoSpeech
4360
VadFlagPrepare
4600
VadFlagSpeaking
"""

    pattern = r"(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking[\r\n]+(\d+)[\r\n]+VadFlagNoSpeech[\r\n]+(\d+)[\r\n]+VadFlagPrepare[\r\n]+(\d+)[\r\n]+VadFlagSpeaking"
    # pattern = r"(\d+)[\r\n]+VadFlagNoSpeech"

    match = re.search(pattern, asr_result, flags=re.IGNORECASE | re.DOTALL)
    if match is not None:
        print(match.group(0))
        print("-" * 15)
        print(match.group(1))
        print("-" * 15)
        print(match.group(2))
        print("-" * 15)
        print(match.group(3))
        print("-" * 15)
        print(match.group(4))
        print("-" * 15)
        print(match.group(5))

    return


if __name__ == '__main__':
    main()