From 048bf75266d979ec553eb6e08c7bbfb99724dfc3 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Wed, 7 Jan 2015 08:52:30 +0100 Subject: [PATCH] Adapted Performance grading --- InitialiseSGC2.praat | 83 ++++++++++------------------------------------------ MainPage.praat | 20 ++++++------- sgc2.praat | 9 +----- 3 files changed, 27 insertions(+), 85 deletions(-) diff --git a/InitialiseSGC2.praat b/InitialiseSGC2.praat index 95f94a1..628c616 100644 --- a/InitialiseSGC2.praat +++ b/InitialiseSGC2.praat @@ -56,6 +56,7 @@ te.numberOfWords = 0 te.recordedSound = 0 te.saveAudio = 0 pinyin$ = "" +sgc.pinyin$ = "" character$ = "" buttons$ = "" config$ = "" @@ -106,7 +107,6 @@ recordingTime = 2 logging = 0 config.language$ = "EN" config.register = 249 -config.logPerformance = 0 preferencesAppFile$ = preferencesAppDir$+"/sgc2rc.txt" preferencesLogDir$ = "'preferencesAppDir$'/log" preferencesTableDir$ = "'preferencesAppDir$'/Data" @@ -456,13 +456,13 @@ procedure initialize_toneevaluation_tables call get_toneevaluation_row Total endproc -procedure get_toneevaluation_row .tones$ +procedure get_toneevaluation_row .pinyin$ select Table 'initialiseSGC2.toneevaluation_table$' - .row = Search column... Pinyin '.tones$' + .row = Search column... Pinyin '.pinyin$' if .row < 1 Append row .row = Get number of rows - Set string value... '.row' Pinyin '.tones$' + Set string value... '.row' Pinyin '.pinyin$' Set numeric value... '.row' Correct 0 Set numeric value... '.row' Wrong 0 Set numeric value... '.row' Total 0 @@ -474,7 +474,7 @@ procedure get_toneevaluation_row .tones$ Set numeric value... '.row' Commented 0 Set numeric value... '.row' Time 0 Sort rows... Pinyin - .row = Search column... Pinyin '.tones$' + .row = Search column... Pinyin '.pinyin$' endif endproc @@ -489,8 +489,8 @@ procedure increment_toneevaluation_in_row .row .column$ Set string value: .row, "Time", .dateTime$ endproc -procedure increment_toneevaluation_value .tones$ .column$ - call get_toneevaluation_row '.tones$' +procedure increment_toneevaluation_value .pinyin$ .column$ + call get_toneevaluation_row '.pinyin$' .row = get_toneevaluation_row.row call increment_toneevaluation_in_row '.row' '.column$' @@ -508,62 +508,31 @@ procedure add_feedback_to_toneevaluation .table$ .label$ = "Unknown" endif - .tones$ = replace_regex$(left$(.line1$, rindex(.line1$, ":")), "[^a-z0-9]", "", 0) + .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_toneevaluation_value '.tones$' Total + call increment_toneevaluation_value 'sgc.pinyin$' Total if .tones$ = .recognized$ - call increment_toneevaluation_value '.tones$' Correct + call increment_toneevaluation_value 'sgc.pinyin$' Correct else - call increment_toneevaluation_value '.tones$' Wrong + call increment_toneevaluation_value 'sgc.pinyin$' Wrong endif if index_regex(.label$, "(Correct|Wrong)") <= 0 - call increment_toneevaluation_value '.tones$' '.label$' - call increment_toneevaluation_value '.tones$' Commented + call increment_toneevaluation_value 'sgc.pinyin$' '.label$' + call increment_toneevaluation_value 'sgc.pinyin$' Commented endif endproc -procedure CreateSummaryToneEvaluation - .font$ = defaultFont$ - # Summarize tone evaluation - Create Table with column names... SummaryToneEvaluation 0 Total Correct Problematic - # Create texts - call get_toneevaluation_row Total - .row = get_toneevaluation_row.row - select Table 'initialiseSGC2.toneevaluation_table$' - .total = Get value... '.row' Total - .correct = Get value... '.row' Correct - if .total > 0 - .correctPerc = 100 * .correct / .total - else - .correctPerc = 0 - endif - .problematic = Get value... '.row' Commented - if .total > 0 - .problematicPerc = 100 * .problematic / .total - else - .problematicPerc = 0 - endif - - select Table SummaryToneEvaluation - Append row - Set numeric value... 1 Total '.total' - Set numeric value... 1 Correct '.correctPerc' - Set numeric value... 1 Problematic '.problematicPerc' -endproc - procedure setGrade .grade$ select Table 'wordlist$' - if recordedSound$ <> "" and te.currentWord > 0 and te.currentWord <= te.numberOfWords - .pinyin$ = Get value: te.currentWord, "Pinyin" - - call get_toneevaluation_row '.pinyin$' + if recordedSound$ <> "" and sgc.pinyin$ <> "" + call get_toneevaluation_row 'sgc.pinyin$' .row = get_toneevaluation_row.row select Table 'initialiseSGC2.toneevaluation_table$' .col = Get column index... Grade if .col <= 0 - Append column... Grade + Insert column... 2 Grade endif Set numeric value: .row, "Grade", '.grade$' @@ -591,26 +560,6 @@ endproc # Miscelaneous procedures # ############################################################### -# -# Create a file 'preferencesAppDir$'/log/logPerformance -# This file contains the path to the target directory where logging -# is to be stored. -# Note that this procedure is nowhere used in SGC2. It has to -# be explicitely called in a separate script. -# -procedure activate_sgc2_logging .targetDirectory$ - createDirectory("'preferencesAppDir$'") - preferencesAppDir$ > 'preferencesAppDir$'/directory.txt - createDirectory("'preferencesLogDir$'") - preferencesLogDir$ > 'preferencesLogDir$'/directory.txt - - if startsWith(.targetDirectory$, "~") - .targetDirectory$ = replace$(.targetDirectory$, "~", homeDirectory$, 1) - endif - - .targetDirectory$ > 'preferencesLogDir$'/logPerformance.txt - newline$ >> 'preferencesLogDir$'/logPerformance.txt -endproc # TTS synthesis procedure synthesize_sound .pinyin$ diff --git a/MainPage.praat b/MainPage.praat index 83c70e8..f2d39af 100644 --- a/MainPage.praat +++ b/MainPage.praat @@ -292,9 +292,9 @@ procedure generate_example if te.currentWord > 0 and te.currentWord <= te.numberOfWords select Table 'wordlist$' .sound$ = Get value... 'te.currentWord' Sound - .pinyin$ = Get value... 'te.currentWord' Pinyin + sgc.pinyin$ = Get value... 'te.currentWord' Pinyin if .sound$ = "-" or .sound$ = "" - .sound$ = .pinyin$+".wav" + .sound$ = sgc.pinyin$+".wav" endif .soundFilePath$ = localWordlistDir$+"/"+wordlistName$+"/"+.sound$ .wordlistDirectory$ = "" @@ -306,7 +306,7 @@ procedure generate_example .wordlistDirectory$ = "'globalwordlists$'/'wordlistName$'" endif if .wordlistDirectory$ <> "" - .audioExampleList = Create Strings as file list... AudioList '.wordlistDirectory$'/'.pinyin$'.* + .audioExampleList = Create Strings as file list... AudioList '.wordlistDirectory$'/'sgc.pinyin$'.* .number_of_examples = Get number of strings if .number_of_examples > 0 Randomize @@ -323,9 +323,9 @@ procedure generate_example Remove endif elsif config.synthesis$ <> "" and config.synthesis$ <> "_DISABLED_" - call synthesize_sound '.pinyin$' + call synthesize_sound 'sgc.pinyin$' else - call humToneContour '.pinyin$' 'config.register' + call humToneContour 'sgc.pinyin$' 'config.register' call reset_viewport endif endif @@ -337,8 +337,8 @@ procedure draw_tone_contour select Table 'wordlist$' if te.currentWord > 0 and te.currentWord <= te.numberOfWords .sound$ = Get value... 'te.currentWord' Sound - .pinyin$ = Get value... 'te.currentWord' Pinyin - call drawToneContour '.pinyin$' 'config.register' + sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + call drawToneContour 'sgc.pinyin$' 'config.register' call reset_viewport if te.recordedPitch > 0 @@ -352,9 +352,9 @@ procedure recognizeTone select Table 'wordlist$' if te.currentWord > 0 and te.currentWord <= te.numberOfWords .sound$ = Get value... 'te.currentWord' Sound - .pinyin$ = Get value... 'te.currentWord' Pinyin - call align_recordedSound '.pinyin$' - call sgc_ToneProt 'recordedSound$' '.pinyin$' 'config.register' 'config.strict' 'config.language$' + sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + call align_recordedSound 'sgc.pinyin$' + call sgc_ToneProt 'recordedSound$' 'sgc.pinyin$' 'config.register' 'config.strict' 'config.language$' # sgc_ToneProt manipulates the sound given. Reconnect select Sound 'recordedSound$' te.recordedSound = selected("Sound") diff --git a/sgc2.praat b/sgc2.praat index de7b2ba..a54674e 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -954,14 +954,7 @@ endproc # Do what is asked procedure process_config .label$ .clickX .clickY .pressed$ - if .label$ = "!Logging" - config.logPerformance = not config.logPerformance - .displayButton = config.logPerformance - call Draw_button 'config$' +'.label$' '.displayButton' - if config.logPerformance - call start_logging - endif - elsif .label$ <> "" and not startsWith(.label$,"!") + if .label$ <> "" and not startsWith(.label$,"!") .label$ = replace$(.label$, "_", " ", 0) call process'config$''.label$' '.clickX' '.clickY' '.pressed$' endif -- 2.11.4.GIT