Small typo corrected in SGC_ToneProt/README.txt
[sgc.git] / SGC_ToneProt / TestToneRecognition.praat
blob6ee11830dcef7ab2944b8f79d501fb4787eeb373
1 #!praat
3 # TestToneRecognition reads all audio-files in a
4 # source directory and tries to recognize them.
6 # The filenames should be:
7 # <pinyin corr>_<transcription>_<height Hz>_...wav
9 form Where are the files
10     sentence dir ../../test
11     sentence files *.wav
12 endform
14 exampleChoice$ = "none"
15 logPerformance = 0
16 precision = 3
18 clearinfo
20 Create Strings as file list... fileList 'dir$'/'files$'
22 number_of_files = Get number of strings
24 for i from 1 to number_of_files
25     select Strings fileList
26     currentFile$ = Get string... 'i'
27     
28     pinyin$ = replace_regex$(currentFile$, "^([^_]+)_.*$", "\1", 0)
29     result$ = replace_regex$(currentFile$, "^[^_]+_([^_]+)_.*$", "\1", 0)
30     height$ = replace_regex$(currentFile$, "^[^_]+_[^_]+_([^_]+)_.*$", "\1", 0)
31     if index_regex(height$, "^F") > 0
32         height$ = "300"
33     elsif index_regex(height$, "^M") > 0
34         height$ = "200"
35     endif
36     f1 = 'height$'
38     # Take the correct boundaries between genders
39     if f1 > 378
40         currentRegister = 450
41     elsif f1 > 252
42         currentRegister = 300
43     elsif f1 > 168
44         currentRegister = 200
45     else
46         currentRegister = 150
47     endif
49     execute SGC_ToneProt.praat "'dir$'/'currentFile$'" 'pinyin$' 'currentRegister' 'precision' 'exampleChoice$' 'logPerformance'
51     result$ < lastResult.txt
52     result$ = replace_regex$(result$, "[\n]", " ", 0)
53     printline 'result$''tab$''currentFile$'
55     # pause 'result$'
56 endfor