4 # Intializing Praat script
6 # SpeakGoodChinese: InitializeSGC2.praat defines and sets the global variables
7 # and loads general SGC2 code
9 # Copyright (C) 2007-2010 R.J.J.H. van Son and 2010 the Netherlands Cancer Institute
10 # The SpeakGoodChinese team are:
11 # Guangqin Chen, Zhonyan Chen, Stefan de Koning, Eveline van Hagen,
12 # Rob van Son, Dennis Vierkant, David Weenink
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
29 # Do not store these variables as preferences
30 sgc.nonPreferences$ = " config.savePerf config.openPerf config.clearSummary config.audioName "
32 # Information for logging activity
33 currentDate$ = date$()
34 dateYear$ = right$(currentDate$, length(currentDate$) - rindex(currentDate$, " "))
35 logtimeStamp$ = replace_regex$(currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
36 currentLogDirectory$ = ""
37 feedbackTablePrefix$ = "Feedback"
38 feedbackTableName$ = ""
39 evaluationTablePrefix$ = "Evaluation"
40 evaluationTableName$ = ""
41 performanceTableName$ = "Performance"
46 yFeedback = yWordlist + 5
47 yPinyin = yFeedback + 10
48 yContour = yPinyin + 15
49 wipeContourArea$ = "demo Paint rectangle... White 20 80 'yContour' 100"
50 wipePinyinArea$ = "demo Paint rectangle... White 20 80 'yPinyin' 'yContour'"
51 wipeFeedbackArea$ = "demo Paint rectangle... White 0 100 'yFeedback' 'yPinyin'"
52 wipeWordlistArea$ = "demo Paint rectangle... White 20 80 'yWordlist' 'yFeedback'"
54 # Pop-Up window colors
55 sgc2.popUp_bordercolor$ = "{0.5,0.5,1}"
56 sgc2.popUp_backgroundcolor$ = "{0.9,0.9,1}"
58 # Initialize parameters
61 sgc.currentWordlist = -1
63 sgc.currentWordNum = 1
64 sgc.numberOfDisplayedWords = 0
68 sgc.customLanguage$ = ""
77 sgc.failedAttempts = 0
79 config.deleteWordlist = -1
80 config.displayNumbers = 1
81 config.displayPinyin = 1
82 config.displayChar = 0
83 config.displayTrans = 1
84 config.useSoundExample = 1
85 config.synthesis$ = "_DISABLED_"
86 config.input$ = "Microphone"
87 config.showBackground = 1
88 sgc2.noiseThresshold = -30
93 config.clearSummary = 0
94 config.audioName$ = ""
97 mainPage.saveAudio$ = ""
100 sgc_ToneProt.minimumPitch = 40
101 sgc_ToneProt.maximumPitch = 600
103 # Platform dependent settings
104 if macintosh or windows
105 config.displayChar = 1
106 config.displayNumbers = 0
108 if windows and endsWith(build_SHA$, " XP")
109 config.displayChar = 0
110 config.displayNumbers = 0
113 config.displayChar = 0
114 config.displayNumbers = 0
118 samplingFrequency = 44100
120 samplingFrequency = 44100
122 samplingFrequency = 44100
126 # Be careful: Logging and Replaying can have side-effects
127 # sgc2.logging$ = "call saveLogOfActivity"
129 # When this is not "# ", the command 'replaySGC2Log$' will be run!
130 if not variableExists("replaySGC2Log$")
131 replaySGC2Log$ = "# "
134 config.language$ = "EN"
135 config.register = 249
136 preferencesAppFile$ = preferencesAppDir$+"/sgc2rc.txt"
137 preferencesLogDir$ = "'preferencesAppDir$'/log"
138 preferencesTableDir$ = "'preferencesAppDir$'/GUI"
139 sgc2wordlists$ = "'preferencesAppDir$'/wordlists"
140 localWordlistDir$ = sgc2wordlists$
142 # Global word lists must be installed BY THE ADMINISTRATOR
143 # This means, create the directory 'globalwordlists$' and
144 # fill it with wordlist directories containing wordlist.Table
145 # and audio files. They can be copied from a local directory.
146 globalwordlists$ = ""
147 globaltablelists$ = ""
150 globalwordlists$ = "/etc/'sgc2.demoAppName$'/wordlists"
151 globaltablelists$ = "/etc/'sgc2.demoAppName$'/GUI"
152 globalTTSdir$ = "/etc/'sgc2.demoAppName$'/TTS"
154 globalwordlists$ = "/Library/Preferences/'sgc2.demoAppName$'/wordlists"
155 globaltablelists$ = "/Library/Preferences/'sgc2.demoAppName$'/GUI"
156 globalTTSdir$ = "/Library/Preferences/'sgc2.demoAppName$'/TTS"
158 globalwordlists$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/wordlists"
159 globaltablelists$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/GUI"
160 globalTTSdir$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/TTS"
162 sgc2.synthesizer = -1
163 # Define a Praat TTS command that will set sgc2.synthesizer
164 sgc2.normalTTScommand$ = "call create_default_TTS Mandarin f4 10000 0.01 50 100 95 no IPA"
165 sgc2.advancedTTScommand$ = "call create_default_TTS Mandarin f4 10000 0.01 50 70 125 no IPA"
166 sgc.alignedTextGrid = -1
168 ##############################################################
170 config.shuffleLists = 1
171 config.adaptiveLists = 0
173 defaultFont$ = "Helvetica"
176 # Set up directories if they do not exist already
177 call set_up_directories
179 # Get saved preferences
180 call read_preferences ""
183 speakCommandDir$ = "'preferencesAppDir$'/TTS"
184 speakCommandFile$ = ""
186 sgc.recordCommandFile$ = ""
187 sgc.playCommandFile$ = ""
189 sgc.scratchAudioDir$ = "'preferencesAppDir$'\audio\"
191 sgc.scratchAudioDir$ = "/tmp/SpeakGoodChinese/"
193 sgc.useAlternativeRecorder = 0
195 sgc.useAlternativePlayer = 0
198 # Set inital language
199 call set_language 'config.language$'
202 call load_word_list "'localWordlistDir$'" 0
204 # Set up evaluation table
205 initialiseSGC2.toneevaluation_table$ = ""
206 call initialize_toneevaluation_tables
211 ###############################################################
213 # Obligatory procedures
215 ###############################################################
216 # Initialize Demo Window
217 procedure init_window
219 demo Line width... 'defaultLineWidth'
221 call set_font_size 'defaultFontSize'
224 # If there is no recorded sound, try to read stored recording
225 if recordedSound$ = "" and sgc.saveAudio$ <> ""
227 select sgc.currentWordlist
228 if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords
229 call readPinyin 'sgc.currentWord'
230 sgc.pinyin$ = readPinyin.pinyin$
231 .outputName$ = "'sgc.saveAudio$'/'sgc.pinyin$'.wav"
232 if fileReadable(.outputName$)
233 sgc.recordedSound = Read from file: .outputName$
234 recordedSound$ = selected$("Sound")
236 # See feedback on earl;ier recorded words
237 if fileReadable("'sgc.saveAudio$'/TestSpeakGoodChinese2.txt")
238 call write_feedback Feedback
240 select Table Feedback
243 # Set config.audioName
244 .tmp$ = replace_regex$(sgc.saveAudio$, "[^/\\]+[/\\]?$", "", 0)
245 config.audioName$ = replace$(sgc.saveAudio$, .tmp$, "", 0)
251 # Set mainPage.saveAudio$ grade
252 call set_grade_display 'sgc.pinyin$'
256 .windowTitle$ = replace$(wordlistName$, "_", " ", 0)
257 call set_window_title 'buttons$' '.windowTitle$'
258 # Display the word-list
260 # Wipe screen and draw background
261 call wipeArea 'wipeContourArea$'
262 if config.showBackground
263 call draw_background Background
265 # Define buttons in a table
271 call draw_tone_contour
273 call paint_saveAudio_light
276 sgc.failedAttempts = 0
279 # Make sure all Preferences directories are available
280 procedure set_up_directories
281 .dirPath$ = "'preferencesAppDir$'"
282 createDirectory(.dirPath$)
283 .dirPath$ > '.dirPath$'/directory.txt
284 createDirectory("'.dirPath$'/wordlists")
285 .dirPath$ > '.dirPath$'/wordlists/directory.txt
286 createDirectory("'.dirPath$'/pitchmodels")
287 .dirPath$ > '.dirPath$'/pitchmodels/directory.txt
288 createDirectory("'.dirPath$'/log")
289 .dirPath$ > '.dirPath$'/log/directory.txt
290 createDirectory("'.dirPath$'/TTS")
291 .dirPath$ > '.dirPath$'/TTS/directory.txt
295 # Retrieve and store setting between sessions
297 procedure read_preferences .preferencesFile$
298 if not fileReadable(.preferencesFile$)
299 .preferencesFile$ = preferencesAppFile$
301 if fileReadable(.preferencesFile$)
302 Read from file... 'preferencesAppFile$'
303 .preferenceTable$ = selected$("Table")
304 .numPrefKeys = Get number of rows
305 for .row to .numPrefKeys
306 .variableName$ = Get value... '.row' Key
307 if variableExists(.variableName$)
308 .variableValue = Get value... '.row' Value
309 if .variableValue <> undefined
310 '.variableName$' = '.variableValue'
312 elsif variableExists(.variableName$+"$")
313 .variableValue$ = Get value... '.row' Value
314 .variableName$ = .variableName$+"$"
315 '.variableName$' = "'.variableValue$'"
319 select Table '.preferenceTable$'
324 procedure write_preferences .preferencesFile$
325 Create Table with column names... Preferences 0 Key Value
326 if index_regex(.preferencesFile$, "[a-zA-Z0-9]") <= 0
327 .preferencesFile$ = preferencesAppFile$
331 for .tableNum from 1 to 2
337 .varPrefix$ = replace_regex$(.table$, "^(.)", "\l\1", 0)
339 select Table '.table$'
340 .numTableRows = Get number of rows
341 for .tablerow to .numTableRows
342 select Table '.table$'
343 .label$ = Get value... '.tablerow' Label
344 .variableName$ = .varPrefix$+"."+(replace_regex$(.label$, "^(.)", "\l\1", 0))
345 .keyName$ = .variableName$
347 if sgc.nonPreferences$ <> "" and index(sgc.nonPreferences$, " '.variableName$' ")
349 elsif variableExists(.variableName$)
350 .value = '.variableName$'
352 elsif variableExists(.variableName$ + "$")
353 .variableName$ = .variableName$ + "$"
354 .value$ = '.variableName$'
355 elsif index(.variableName$, "_") > 0
356 .variableName$ = left$(.variableName$, rindex(.variableName$, "_") - 1)
357 .keyName$ = .variableName$
358 select Table Preferences
359 .prefRow = Search column... Key '.keyName$'
361 if variableExists(.variableName$)
362 .value = '.variableName$'
364 elsif variableExists(.variableName$ + "$")
365 .variableName$ = .variableName$ + "$"
366 .value$ = '.variableName$'
372 select Table Preferences
375 Set string value... '.row' Key '.keyName$'
376 Set string value... '.row' Value '.value$'
381 # Some extra settings
382 select Table Preferences
385 Set string value... '.row' Key wordlistDir
386 Set string value... '.row' Value 'localWordlistDir$'
388 select Table Preferences
391 Set string value... '.row' Key wordlistName
392 Set string value... '.row' Value 'wordlistName$'
394 select Table Preferences
395 Write to table file... '.preferencesFile$'
400 ###############################################################
402 # TTS (speech synthesis). Place commands in user info
405 # speakCommandDir$ = "'preferencesAppDir$'/TTS"
406 # speakCommandFile$ = ""
408 # Make sure sgc2.synthesizer is set!
409 procedure create_default_TTS .language$ .voice$ .samplefreq .gap .pitch_adj .pitch_range .words_per_minute .use_data$ .espeak_phones$
410 sgc2.synthesizer = Create SpeechSynthesizer... '.language$' '.voice$'
411 Set speech output settings... .samplefreq .gap .pitch_adj .pitch_range .words_per_minute '.use_data$' '.espeak_phones$'
415 if sgc2.synthesizer > 0
416 select sgc2.synthesizer
418 sgc2.synthesizer = -1
420 # Note, the TTScommand must set sgc2.synthesizer!
421 if config.strict$ = "'sgc.highestLevel'"
422 'sgc2.advancedTTScommand$'
424 'sgc2.normalTTScommand$'
428 .ttscommand$ = "speak"
432 .ttscommand$ = "espeak"
436 .ttscommand$ = "C:/Program Files/eSpeak/command_line/espeak.exe"
440 # Global TTS command has precedence
441 if fileReadable("'globalTTSdir$'/TTS_'.osName$'_command.txt")
442 speakCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_command.txt"
443 if config.synthesis$ = "_DISABLED_"
445 config.synthesis$ = "eSpeak"
449 # Local TTS command, if there is no global one
450 # Command does not exist yet, create it if eSpeak is installed
451 # Make sure to quote the path!
452 if speakCommandFile$ = ""
453 # Autodetect synthesizer command
454 # if not fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
455 # .command_path$ = ""
457 # system_nocheck PATH=${PATH}:/opt/local/bin; bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"'
458 # .command_path$ < 'speakCommandDir$'/command_path.txt
460 # system_nocheck PATH=${PATH};bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"'
461 # .command_path$ < 'speakCommandDir$'/command_path.txt
463 # if fileReadable(.ttscommand$)
464 # .command_path$ = .ttscommand$
467 # # Remove any newlines
468 # .command_path$ = replace$(.command_path$, "'newline$'", "", 0)
470 # # Command path found
471 # if sgc2.synthesizer <= 0 and .command_path$ <> "" and fileReadable(.command_path$)
472 # deleteFile("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
473 # fileappend "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"
474 # ...'.quote$''.ttscommand$''.quote$' -v zh+f4 -s 100 'newline$'
475 # speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"
478 # if fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
479 speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"
481 deleteFile("'speakCommandDir$'/command_path.txt")
484 # Close off (other TTS maybe a later option)
485 if sgc2.synthesizer > 0 or (speakCommandFile$ <> "" and fileReadable(speakCommandFile$))
486 config.synthesis$ = "eSpeak"
490 # Alternative audio recorder
491 procedure set_up_recorder
502 # Global TTS command has precedence
503 sgc.useAlternativeRecorder = 0
504 if fileReadable("'globalTTSdir$'/TTS_'.osName$'_record_command.txt")
505 createDirectory(sgc.scratchAudioDir$)
506 sgc.recordCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_record_command.txt"
507 sgc.useAlternativeRecorder = 1
508 elsif fileReadable("'speakCommandDir$'/TTS_'.osName$'_record_command.txt")
509 createDirectory(sgc.scratchAudioDir$)
510 sgc.recordCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_record_command.txt"
511 sgc.useAlternativeRecorder = 1
515 # Alternative audio player
516 procedure set_up_player
527 # Global TTS command has precedence
528 sgc.useAlternativePlayer = 0
529 if fileReadable("'globalTTSdir$'/TTS_'.osName$'_play_command.txt")
530 createDirectory(sgc.scratchAudioDir$)
531 sgc.playCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_play_command.txt"
532 sgc.useAlternativePlayer = 1
533 elsif fileReadable("'speakCommandDir$'/TTS_'.osName$'_play_command.txt")
534 createDirectory(sgc.scratchAudioDir$)
535 sgc.playCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_play_command.txt"
536 sgc.useAlternativePlayer = 1
540 ###############################################################
545 # initialiseSGC2.toneevaluation_table$ = ""
546 procedure initialize_toneevaluation_tables
548 if initialiseSGC2.toneevaluation_table$ != ""
549 select sgc2.performanceTable
552 initialiseSGC2.toneevaluation_table$ = ""
553 # Get the name of the table
554 call get_evaluation_table_labels 'config.language$'
555 performanceTableName$ = eval.performance$
557 if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$)
558 sgc2.performanceTable = Read Table from tab-separated file: sgc.savePerf$
559 Rename: performanceTableName$
560 # Check to make sure all columns are initialized, but only if Pinyin exists!
561 select sgc2.performanceTable
562 .column = Get column index: eval.pinyin$
564 select sgc2.performanceTable
566 sgc2.performanceTable = Create Table with column names... "'performanceTableName$'" 0 'eval.pinyin$' 'eval.correct$' 'eval.wrong$' 'eval.total$' 'eval.high$' 'eval.low$' 'eval.wide$' 'eval.narrow$' 'eval.unknown$' 'eval.commented$' 'eval.level$' 'eval.time$'
568 .columnNameList$ = "'eval.correct$' 'eval.wrong$' 'eval.total$' 'eval.high$' 'eval.low$' 'eval.wide$' 'eval.narrow$' 'eval.unknown$' 'eval.commented$' 'eval.level$' 'eval.time$'"
569 while index_regex(.columnNameList$, "\S")
570 .columnNameList$ = replace_regex$(.columnNameList$, "^\s+", "", 1)
571 .columnHeader$ = extractWord$(.columnNameList$, "")
572 .columnNameList$ = replace_regex$(.columnNameList$, "^\s*'.columnHeader$'\s*", "", 1)
574 select sgc2.performanceTable
575 .column = Get column index: .columnHeader$
577 select sgc2.performanceTable
578 Append column: .columnHeader$
584 sgc2.performanceTable = Create Table with column names... "'performanceTableName$'" 0 'eval.pinyin$' 'eval.correct$' 'eval.wrong$' 'eval.total$' 'eval.high$' 'eval.low$' 'eval.wide$' 'eval.narrow$' 'eval.unknown$' 'eval.commented$' 'eval.level$' 'eval.time$'
586 initialiseSGC2.toneevaluation_table$ = performanceTableName$
587 call get_toneevaluation_row 'eval.total$'
590 procedure get_toneevaluation_row .pinyin$
591 select sgc2.performanceTable
592 .row = Search column... "'eval.pinyin$'" '.pinyin$'
595 .row = Get number of rows
596 Set string value... '.row' "'eval.pinyin$'" '.pinyin$'
597 Set numeric value... '.row' 'eval.correct$' 0
598 Set numeric value... '.row' 'eval.wrong$' 0
599 Set numeric value... '.row' 'eval.total$' 0
600 Set numeric value... '.row' 'eval.high$' 0
601 Set numeric value... '.row' 'eval.low$' 0
602 Set numeric value... '.row' 'eval.wide$' 0
603 Set numeric value... '.row' 'eval.narrow$' 0
604 Set numeric value... '.row' 'eval.unknown$' 0
605 Set numeric value... '.row' 'eval.commented$' 0
606 Set numeric value... '.row' 'eval.level$' 0
607 Set numeric value... '.row' 'eval.time$' 0
608 Sort rows... 'eval.pinyin$'
609 .row = Search column... "'eval.pinyin$'" '.pinyin$'
613 procedure increment_toneevaluation_in_row .row .column$
614 select sgc2.performanceTable
615 .tmp = Get value... '.row' '.column$'
620 Set numeric value... '.row' '.column$' '.tmp'
623 Set string value: .row, eval.level$, config.strict$
627 Set string value: .row, eval.time$, .dateTime$
631 # Update existing performance file with toneevaluation
632 procedure update_toneevaluation_file
633 if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$) and initialiseSGC2.toneevaluation_table$ <> ""
634 select sgc2.performanceTable
635 Write to table file... 'sgc.savePerf$'
639 procedure increment_toneevaluation_value .pinyin$ .column$
640 call get_toneevaluation_row '.pinyin$'
641 .row = get_toneevaluation_row.row
642 call increment_toneevaluation_in_row '.row' '.column$'
644 call get_toneevaluation_row 'eval.total$'
645 .row = get_toneevaluation_row.row
646 call increment_toneevaluation_in_row '.row' '.column$'
649 procedure add_feedback_to_toneevaluation .table$
650 select Table '.table$'
651 .line1$ = Get value... 1 Text
652 .line2$ = Get value... 2 Text
653 .label$ = Get value... 3 Text
655 .label$ = "'eval.unknown$'"
658 .tones$ = replace_regex$(left$(.line1$, rindex(.line1$, ":")), "[^0-9]", "", 0)
659 .recognized$ = replace_regex$(right$(.line1$, length(.line1$)-rindex(.line1$, ":")), "[^0-9]", "", 0)
662 call increment_toneevaluation_value 'sgc.pinyin$' 'eval.total$'
663 if .tones$ = .recognized$
664 call increment_toneevaluation_value 'sgc.pinyin$' 'eval.correct$'
667 call increment_toneevaluation_value 'sgc.pinyin$' 'eval.wrong$'
670 if index_regex(.label$, "(Correct|Wrong)") <= 0
671 if .label$ = "Correct"
672 .label$ = eval.correct$
674 .label$ = eval.wrong$
676 call increment_toneevaluation_value 'sgc.pinyin$' '.label$'
677 call increment_toneevaluation_value 'sgc.pinyin$' 'eval.commented$'
681 # Update performance table when SaveAudio is on
683 call update_toneevaluation_file
687 procedure setGrade .grade$
688 select sgc.currentWordlist
689 if recordedSound$ <> "" and sgc.pinyin$ <> ""
690 call get_toneevaluation_row 'sgc.pinyin$'
691 .row = get_toneevaluation_row.row
692 select sgc2.performanceTable
693 .col = Get column index... Grade
695 Insert column... 2 Grade
698 Set numeric value: .row, "Grade", '.grade$'
699 .numRows = Get number of rows
702 for .r from 2 to .numRows
703 .tmp = Get value: .r, "Grade"
711 .meanGrade = .sumGrade / .sumN
713 Set numeric value: 1, "Grade", .meanGrade
715 # Store current performance table
716 call update_toneevaluation_file
720 # Set mainPage.saveAudio$ to Grade
721 procedure set_grade_display .pinyin$
722 mainPage.saveAudio$ = ""
723 select sgc2.performanceTable
725 .col = Get column index: "Grade"
726 if .pinyin$ <> "" and .col > 0
727 call get_toneevaluation_row '.pinyin$'
728 .row = get_toneevaluation_row.row
730 .grade$ = Get value: .row, "Grade"
731 if index_regex(.grade$, "[0-9]") <= 0
737 mainPage.saveAudio$ = .grade$
741 ###############################################################
743 # Miscelaneous procedures
745 ###############################################################
748 procedure synthesize_sound .pinyin$
750 if speakCommandFile$ <> "" and fileReadable(speakCommandFile$)
751 .command$ < 'speakCommandFile$'
752 .command$ = replace$(.command$, "'newline$'", " ", 0)
754 system_nocheck PATH=${PATH}:/usr/local/bin:/opt/local/bin; bash -rc -- ''.command$' "'.pinyin$'"'
756 system_nocheck bash -rc -- ''.command$' "'.pinyin$'"'
758 system_nocheck call '.command$' "'.pinyin$'"'
760 elsif sgc2.synthesizer > 0
761 select sgc2.synthesizer
762 Play text... '.pinyin$'
766 procedure align_recordedSound .pinyin$
767 if 0 and sgc2.synthesizer > 0 and recordedSound$ <> ""
768 select Sound 'recordedSound$'
769 .recordedTextGrid = To TextGrid... pinyin
770 Set interval text... 1 1 '.pinyin$'
771 select sgc2.synthesizer
772 plus Sound 'recordedSound$'
773 plus .recordedTextGrid
774 sgc.alignedTextGrid = nowarn noprogress To TextGrid (align,trim)... 1 1 1 -35 0.1 0.1 0.08
775 Rename... AlignedTextGrid
776 select .recordedTextGrid