From bbf0c6aa8cb387e6bbfdf4a34717cab1587927fa Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Tue, 9 Nov 2010 11:38:23 +0100 Subject: [PATCH] Added performance evaluation table --- InitialiseSGC2.praat | 231 +++++++++++++++++++++++++++++++------------- MainPage.praat | 1 + ToneProt/SGC_ToneProt.praat | 157 +++++++++++++++--------------- 3 files changed, 244 insertions(+), 145 deletions(-) diff --git a/InitialiseSGC2.praat b/InitialiseSGC2.praat index 57d3ef3..3465740 100644 --- a/InitialiseSGC2.praat +++ b/InitialiseSGC2.praat @@ -101,73 +101,7 @@ elsif windows globalTTSdir$ = "C:/Documents and Settings/All Users/Application Data/praat/sgc2/TTS" endif -############################################################### -# -# TTS (speech synthesis). Place commands in user info -# -speakCommandDir$ = "'preferencesDirectory$'/sgc2/TTS" -speakCommandFile$ = "" -procedure set_up_TTS - if macintosh - .ttscommand$ = "speak" - .osName$ = "OSX" - .quote$ = "" - elsif unix - .ttscommand$ = "espeak" - .osName$ = "UNIX" - .quote$ = "" - elsif windows - .ttscommand$ = "C:/Program Files/eSpeak/command_line/espeak.exe" - .osName$ = "WIN" - .quote$ = """" - endif - # Global TTS command has precedence - if fileReadable("'globalTTSdir$'/TTS_'.osName$'_command.txt") - speakCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_command.txt" - if config.synthesis$ = "_DISABLED_" - # Default is ON - config.synthesis$ = "eSpeak" - endif - endif - - # Local TTS command, if there is no global one - # Command does not exist yet, create it if eSpeak is installed - # Make sure to quote the path! - if speakCommandFile$ = "" - if not fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") - if macintosh - system_nocheck PATH=${PATH}:/opt/local/bin; bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"' - .command_path$ < 'speakCommandDir$'/command_path.txt - elsif unix - system_nocheck PATH=${PATH};bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"' - .command_path$ < 'speakCommandDir$'/command_path.txt - elsif windows - if fileReadable(.ttscommand$) - .command_path$ = .ttscommand$ - endif - endif - # Remove any newlines - .command_path$ = replace$(.command_path$, "'newline$'", "", 0) - - # Command path found - if .command_path$ <> "" and fileReadable(.command_path$) - deleteFile("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") - fileappend "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" - ...'.quote$''.ttscommand$''.quote$' -v zh+f4 -s 100 'newline$' - speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" - endif - endif - if fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") - speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" - endif - deleteFile("'speakCommandDir$'/command_path.txt") - endif - - # Close off (other TTS maybe a later option) - if speakCommandFile$ <> "" and fileReadable(speakCommandFile$) - config.synthesis$ = "eSpeak" - endif -endproc +############################################################## config.shuffleLists = 1 defaultFontSize = 12 @@ -176,14 +110,25 @@ defaultLineWidth = 1 # Set up directories if they do not exist already call set_up_directories + # Get saved preferences call read_preferences "" + +# Set up TTS system +speakCommandDir$ = "'preferencesDirectory$'/sgc2/TTS" +speakCommandFile$ = "" call set_up_TTS + # Set inital language call set_language 'config.language$' + # Get the word-list call load_word_list "'localWordlistDir$'" 0 +# Set up evaluation table +evaluation_table$ = "" +call initialize_evaluation_tables + # Draw inital window call init_window @@ -329,6 +274,158 @@ endproc ############################################################### # +# TTS (speech synthesis). Place commands in user info +# +# Prerequisites +# speakCommandDir$ = "'preferencesDirectory$'/sgc2/TTS" +# speakCommandFile$ = "" +procedure set_up_TTS + if macintosh + .ttscommand$ = "speak" + .osName$ = "OSX" + .quote$ = "" + elsif unix + .ttscommand$ = "espeak" + .osName$ = "UNIX" + .quote$ = "" + elsif windows + .ttscommand$ = "C:/Program Files/eSpeak/command_line/espeak.exe" + .osName$ = "WIN" + .quote$ = """" + endif + # Global TTS command has precedence + if fileReadable("'globalTTSdir$'/TTS_'.osName$'_command.txt") + speakCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_command.txt" + if config.synthesis$ = "_DISABLED_" + # Default is ON + config.synthesis$ = "eSpeak" + endif + endif + + # Local TTS command, if there is no global one + # Command does not exist yet, create it if eSpeak is installed + # Make sure to quote the path! + if speakCommandFile$ = "" + if not fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") + if macintosh + system_nocheck PATH=${PATH}:/opt/local/bin; bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"' + .command_path$ < 'speakCommandDir$'/command_path.txt + elsif unix + system_nocheck PATH=${PATH};bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"' + .command_path$ < 'speakCommandDir$'/command_path.txt + elsif windows + if fileReadable(.ttscommand$) + .command_path$ = .ttscommand$ + endif + endif + # Remove any newlines + .command_path$ = replace$(.command_path$, "'newline$'", "", 0) + + # Command path found + if .command_path$ <> "" and fileReadable(.command_path$) + deleteFile("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") + fileappend "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" + ...'.quote$''.ttscommand$''.quote$' -v zh+f4 -s 100 'newline$' + speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" + endif + endif + if fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt") + speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt" + endif + deleteFile("'speakCommandDir$'/command_path.txt") + endif + + # Close off (other TTS maybe a later option) + if speakCommandFile$ <> "" and fileReadable(speakCommandFile$) + config.synthesis$ = "eSpeak" + endif +endproc + +############################################################### +# +# Evaluation tables +# +# Prerequisites +# evaluation_table$ = "" +procedure initialize_evaluation_tables + # Remove old table + if evaluation_table$ != "" + select Table 'evaluation_table$' + Remove + endif + evaluation_table$ = "" + + # Create new table + Create Table with column names... Performance 0 Tones Correct Wrong Total High Low Wide Narrow Unknown Commented + evaluation_table$ = "Performance" + call get_evaluation_row Total +endproc + +procedure get_evaluation_row .tones$ + select Table 'evaluation_table$' + .row = Search column... Tones '.tones$' + if .row < 1 + Append row + .row = Get number of rows + Set string value... '.row' Tones '.tones$' + Set numeric value... '.row' Correct 0 + Set numeric value... '.row' Wrong 0 + Set numeric value... '.row' Total 0 + Set numeric value... '.row' High 0 + Set numeric value... '.row' Low 0 + Set numeric value... '.row' Wide 0 + Set numeric value... '.row' Narrow 0 + Set numeric value... '.row' Unknown 0 + Set numeric value... '.row' Commented 0 + Sort rows... Tones + .row = Search column... Tones '.tones$' + endif +endproc + +procedure increment_evaluation_in_row .row .column$ + select Table 'evaluation_table$' + .tmp = Get value... '.row' '.column$' + .tmp += 1 + Set numeric value... '.row' '.column$' '.tmp' +endproc + +procedure increment_evaluation_value .tones$ .column$ + call get_evaluation_row '.tones$' + .row = get_evaluation_row.row + call increment_evaluation_in_row '.row' '.column$' + + call get_evaluation_row Total + .row = get_evaluation_row.row + call increment_evaluation_in_row '.row' '.column$' +endproc + +procedure add_feedback_to_evaluation .table$ + select Table '.table$' + .line1$ = Get value... 1 Text + .line2$ = Get value... 2 Text + .label$ = Get value... 3 Text + if .label$ = "6" + .label$ = "Unknown" + endif + + .tones$ = replace_regex$(left$(.line1$, rindex(.line1$, ":")), "[^0-9]", "", 0) + .recognized$ = replace_regex$(right$(.line1$, length(.line1$)-rindex(.line1$, ":")), "[^0-9]", "", 0) + + # Set evaluation + call increment_evaluation_value '.tones$' Total + if .tones$ = .recognized$ + call increment_evaluation_value '.tones$' Correct + else + call increment_evaluation_value '.tones$' Wrong + endif + if index_regex(.label$, "(Correct|Wrong)") <= 0 + call increment_evaluation_value '.tones$' '.label$' + call increment_evaluation_value '.tones$' Commented + endif +endproc + +############################################################### +# # Miscelaneous procedures # ############################################################### diff --git a/MainPage.praat b/MainPage.praat index 19c51e7..5312bca 100644 --- a/MainPage.praat +++ b/MainPage.praat @@ -243,6 +243,7 @@ procedure processMainPageRecord .clickX .clickY .pressed$ # Write text (again) call display_word_list_name call display_text Black + call add_feedback_to_evaluation Feedback call write_feedback Feedback select Table Feedback Remove diff --git a/ToneProt/SGC_ToneProt.praat b/ToneProt/SGC_ToneProt.praat index c17d05f..127fb9e 100644 --- a/ToneProt/SGC_ToneProt.praat +++ b/ToneProt/SGC_ToneProt.praat @@ -135,15 +135,16 @@ procedure sgc_ToneProt sgc_ToneProt.currentSound$ sgc_ToneProt.pinyin$ sgc_ToneP timeMinimum = Get time of minimum... 0 0 Hertz Parabolic if maximumRecFzero = undefined # Determine what should be told to the student - recognitionText$ = "'sgc_ToneProt.currentTestWord$': ???" + .recognitionText$ = "'sgc_ToneProt.currentTestWord$': ???" for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback + .label$ = "Unknown" - if toneOne$ = "NoSound" - feedbackText$ = toneText$ + if .toneOne$ = "NoSound" + .feedbackText$ = .toneText$ endif endfor @@ -302,9 +303,9 @@ procedure sgc_ToneProt sgc_ToneProt.currentSound$ sgc_ToneProt.pinyin$ sgc_ToneP endif # Initialize result texts - recognitionText$ = "'sgc_ToneProt.currentTestWord$': " - choiceText$ = replace_regex$(sgc_ToneProt.choiceReference$, "6", "\?", 0) - feedbackText$ = "----" + .recognitionText$ = "'sgc_ToneProt.currentTestWord$': " + .choiceText$ = replace_regex$(sgc_ToneProt.choiceReference$, "6", "\?", 0) + .feedbackText$ = "----" # Separate tone from pronunciation errors currentToneWord$ = replace_regex$(sgc_ToneProt.currentTestWord$, "[a-z]+", "\*", 0) @@ -312,125 +313,125 @@ procedure sgc_ToneProt sgc_ToneProt.currentSound$ sgc_ToneProt.pinyin$ sgc_ToneP # Determine what should be told to the student if sgc_ToneProt.registerUsed$ = "Low" - recognitionText$ = recognitionText$ + "???" + .recognitionText$ = .recognitionText$ + "???" for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback - if toneOne$ = "Low" - feedbackText$ = toneText$ - .label$ = toneOne$ + if .toneOne$ = "Low" + .feedbackText$ = .toneText$ + .label$ = .toneOne$ endif endfor elsif rangeUsed$ = "Narrow" - recognitionText$ = recognitionText$ + "???" + .recognitionText$ = .recognitionText$ + "???" for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback - if toneOne$ = "Narrow" - feedbackText$ = toneText$ - .label$ = toneOne$ + if .toneOne$ = "Narrow" + .feedbackText$ = .toneText$ + .label$ = .toneOne$ endif endfor elsif sgc_ToneProt.registerUsed$ = "High" - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback - if toneOne$ = "High" - feedbackText$ = toneText$ - .label$ = toneOne$ + if .toneOne$ = "High" + .feedbackText$ = .toneText$ + .label$ = .toneOne$ endif endfor elsif rangeUsed$ = "Wide" - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback - if toneOne$ = "Wide" - feedbackText$ = toneText$ - .label$ = toneOne$ + if .toneOne$ = "Wide" + .feedbackText$ = .toneText$ + .label$ = .toneOne$ endif endfor # Bad tones, first handle first syllable elsif rindex_regex(sgc_ToneProt.choiceReference$, "^[a-zA-Z]+6") > 0 - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ # First syllable for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback # - feedbackText$ = "" - if toneOne$ = "6" - recognitionText$ = recognitionText$ + " ('toneText$')" - .label$ = toneOne$ - elsif rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'toneOne$'") > 0 and toneTwo$ = "-" - feedbackText$ = feedbackText$ + toneText$ + " " + .feedbackText$ = "" + if .toneOne$ = "6" + .recognitionText$ = .recognitionText$ + " ('.toneText$')" + .label$ = .toneOne$ + elsif rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'.toneOne$'") > 0 and .toneTwo$ = "-" + .feedbackText$ = .feedbackText$ + .toneText$ + " " endif endfor # Bad tones, then handle second syllable elsif rindex_regex(sgc_ToneProt.choiceReference$, "[a-zA-Z]+6$") > 0 - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ # Last syllable for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback # - feedbackText$ = "" - if toneOne$ = "6" - recognitionText$ = recognitionText$ + " ('toneText$')" - .label$ = toneOne$ - elsif rindex_regex(sgc_ToneProt.currentTestWord$, "[a-zA-Z]+'toneOne$'$") > 0 and toneTwo$ = "-" - feedbackText$ = feedbackText$ + toneText$ + " " + .feedbackText$ = "" + if .toneOne$ = "6" + .recognitionText$ = .recognitionText$ + " ('.toneText$')" + .label$ = .toneOne$ + elsif rindex_regex(sgc_ToneProt.currentTestWord$, "[a-zA-Z]+'.toneOne$'$") > 0 and .toneTwo$ = "-" + .feedbackText$ = .feedbackText$ + .toneText$ + " " endif endfor # Just plain wrong tones elsif currentToneWord$ <> choiceToneReference$ - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback - - if rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'toneOne$'$") > 0 and toneTwo$ = "-" - feedbackText$ = toneText$ - elsif rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'toneOne$'[a-zA-Z]+'toneTwo$'$") > 0 - feedbackText$ = toneText$ - elsif toneOne$ = "Wrong" - recognitionText$ = recognitionText$ + " ('toneText$')" - .label$ = toneOne$ + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback + + if rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'.toneOne$'$") > 0 and .toneTwo$ = "-" + .feedbackText$ = .toneText$ + elsif rindex_regex(sgc_ToneProt.currentTestWord$, "^[a-zA-Z]+'.toneOne$'[a-zA-Z]+'.toneTwo$'$") > 0 + .feedbackText$ = .toneText$ + elsif .toneOne$ = "Wrong" + .recognitionText$ = .recognitionText$ + " ('.toneText$')" + .label$ = .toneOne$ endif endfor # Correct else - recognitionText$ = recognitionText$ + choiceText$ + .recognitionText$ = .recognitionText$ + .choiceText$ for i from 1 to numberOfFeedbackRows select Table ToneFeedback - toneOne$ = Get value... 'i' T1 - toneTwo$ = Get value... 'i' T2 - toneText$ = Get value... 'i' Feedback + .toneOne$ = Get value... 'i' T1 + .toneTwo$ = Get value... 'i' T2 + .toneText$ = Get value... 'i' Feedback - if toneOne$ = "Correct" - feedbackText$ = toneText$ - .label$ = toneOne$ + if .toneOne$ = "Correct" + .feedbackText$ = .toneText$ + .label$ = .toneOne$ endif endfor endif @@ -439,8 +440,8 @@ procedure sgc_ToneProt sgc_ToneProt.currentSound$ sgc_ToneProt.pinyin$ sgc_ToneP # Write out result Create Table with column names... Feedback 3 Text - Set string value... 1 Text 'recognitionText$' - Set string value... 2 Text 'feedbackText$' + Set string value... 1 Text '.recognitionText$' + Set string value... 2 Text '.feedbackText$' Set string value... 3 Text '.label$' # Clean up -- 2.11.4.GIT