Rewriting process start codes to use call process<table><label> .... procedures
[sgc2.git] / ToneProt / ReplayToneLogFile.praat
blob99722684af2b9a9c6a3131849ac820c6dc39238f
1 #! praat
3 # Script to replay the collection of examples in the
4 # logFile.txt as stored in the log/ directory
6 form Please indicate log file, log directory, and the default register
7     sentence logfile logFile.txt
8     sentence data_Source log
9     real default_register 300
10     positive precision_(st) 3
11     boolean randomize 1
12 endform
14 clearinfo
15 exampleChoice$ = "Hum"
16 logPerformance = 0
18 Read Strings from raw text file... 'logfile$'
19 Rename... LogFile
20 numberofLines = Get number of strings
21 if randomize
22         Randomize
23 endif
24 for i from 1 to numberofLines
26     currentRegister =  default_register
27     select Strings LogFile
28     line$ = Get string... 'i'
30     # Skip empty lines and comments
31     if index_regex(line$, "^[ \t]*\#") <= 0 and index_regex(line$, "[a-zA-Z0-9]+") > 0   
32         # Split line
33         lengthLine = length(line$)
34         numFields = 0
35         currentStretch$ = line$
36         currentPoint = 1
37         while currentPoint <= lengthLine
38             currentStretch$ = right$(line$, lengthLine - currentPoint + 1)
39             nextSpace = index_regex(currentStretch$, "\t")
40             if nextSpace <= 0
41                 numFields = numFields + 1
42                 field'numFields'$ = currentStretch$
43                 currentPoint = lengthLine + 1
44             else
45                 numFields = numFields + 1
46                 field'numFields'$ = left$(currentStretch$, nextSpace-1)
47                 currentPoint = currentPoint + nextSpace
48             endif
49         endwhile
51         # Get the relevant information (fields)
52         pinyin$ = field2$
53         currentSound$ = field'numFields'$
54         currentRegister = extractNumber(field7$, "")
56         # Play the current sound
57         Open long sound file... 'data_Source$'/'currentSound$'
58         totalDuration = Get total duration
59         Play part... 0.0 'totalDuration'
60         Remove
62         # Start the recognizer
63         execute SGC_ToneProt.praat "'data_Source$'/'currentSound$'" 'pinyin$' 'currentRegister' 'precision' 'exampleChoice$' 'logPerformance'
65         result$ < lastResult.txt
66         result$ = replace_regex$(result$, "[\n]", " ", 0)
67         printline 'result$'
69         pause Result - 'result$'
70     endif
71 endfor
73 select Strings LogFile
74 Remove