#! praat # form Mandarin pronunciation recognition word currentSound currentSound.wav word pinyin duo1shao3 boolean logPerformance endform number_of_Coefficients = 12 include SoundRecognition.praat spacing = 0.5 Read from file... 'currentSound$' Rename... Source select Sound Source noprogress To MFCC... 'number_of_Coefficients' 0.015 0.005 100.0 100.0 0.0 Rename... Source select Sound Source call PronunciationRecognition 'pinyin$' "REUSEMFCC" mfcc "" 12 feedbackText$ = pinyin$ # Split distance etc from recognition result distanceDTW$ = replace_regex$(choiceReference$, "^([0-9\.\- e]+).*", "\1", 0) distanceDTW$ = replace_regex$(distanceDTW$, "\s*([0-9\.e]+).*", "\1", 0) spokenWord$ = replace_regex$(choiceReference$, "^[0-9\.\- e]+", " ", 0) spokenWord$ = replace_regex$(spokenWord$, "\s*([a-zA-Z0-9]+)", "\1", 0); spokenWord$ = replace_regex$(spokenWord$, "^\s*'pinyin$'_([a-zA-Z0-9\+\-\[\]]+)_.*$", "\1", 0); fileSpokenWord$ = spokenWord$ spokenWord$ = replace_regex$(spokenWord$, "\+", "[", 0) spokenWord$ = replace_regex$(spokenWord$, "\-", "]", 0) # Remove tone symbols currentPronWord$ = replace_regex$(pinyin$, "\d", "_", 0) spokenPronWord$ = replace_regex$(spokenWord$, "\d", "_", 0) result$ = "'tab$''currentPronWord$''tab$''spokenPronWord$''tab$''pinyin$''tab$''spokenWord$'" if currentPronWord$ = spokenPronWord$ result$ = "Correct:"+result$ else result$ = "Wrong:"+result$ endif currentDate$ = date$() timeStamp$ = replace_regex$(currentDate$, "[^a-zA-Z0-9\-_]", "-", 0) if logPerformance outfilename$ = "'pinyin$'_'fileSpokenWord$'_'timeStamp$'.wav" logfiletext$ = result$+tab$+currentDate$+tab$+outfilename$+newline$ fileappend logFile.txt 'logfiletext$' select Sound Source Write to WAV file... log/'outfilename$' endif # printline 'result$' result$ > lastResult.txt newline$ >> lastResult.txt select Sound Source Remove