Changed German special characters
[sgc2.git] / Config.praat
blobc8e075d96f2ac6c438f9f552d0c6add27295b781
2 # SpeakGoodChinese 2.0
3
4 # Praat script handling configuration page
6 #     SpeakGoodChinese: Config.praat loads the code needed for the 
7 #     settings and the Settings page of SpeakGoodChinese.
8 #     
9 #     Copyright (C) 2007-2010  R.J.J.H. van Son
10 #     The SpeakGoodChinese team are:
11 #     Guangqin Chen, Zhonyan Chen, Stefan de Koning, Eveline van Hagen, 
12 #     Rob van Son, Dennis Vierkant, David Weenink
13
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.
18
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.
23
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
27
29 ###############################################################
31 # Button Drawing Routines
33 ###############################################################
35 procedure DrawCredits .color$ .x .y .size
36         .size *= 0.71
37         .lineheight = 2*.size
38         call adjustFontSizeOnHeight 24 '.lineheight'
39         .currentFontSize = adjustFontSizeOnHeight.newFontSize
40     demo Paint circle... {0.2,0.2,0.8} '.x' '.y' '.size'
41         demo Colour... White
42         demo Text special... '.x' centre '.y' half Times '.currentFontSize' 0 i
43         demoShow()
44         demo Colour... Black
45         call set_font_size 'defaultFontSize'    
46 endproc
48 procedure DrawDeleteList .color$ .x .y .size
49     .y += 2*.size
50     .leftX = .x - 10
51     .rightX = .x + 10
52     .botY = .y+1
53     .topY = .botY + 5
54     demo Paint rectangle... White '.leftX' '.rightX' '.botY' '.topY'
55         call set_font_size 12
56     demo Red
57     .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
59         # Adapt wide of text
60         .maxWidth = (.rightX - .leftX)
61     .currentFontSize = defaultFontSize
62         call adjustFontSizeOnWidth '.currentFontSize' '.maxWidth' '.displayWordList$'
63         .currentFontSize = adjustFontSizeOnWidth.newFontSize
64         call set_font_size '.currentFontSize'
66         demo Text... '.x' Centre '.botY' Bottom '.displayWordList$'
67     demo Black
68         demoShow()
69         call set_font_size 'defaultFontSize'
70 endproc
72 procedure DrawLogging .color$ .x .y .size
73     .size /= 2
74         .y += .size
75     if .color$ = "Blue"
76         .color$ = "{0.5,0.5,1}"
77      else
78         .color$ = "Blue"
79      endif
80     demo Paint circle... '.color$' '.x' '.y' '.size'
81 endproc
83 ###############################################################
85 # Obligatory button Drawing Routines
86
87 # These MUST be defined
89 ###############################################################
91 procedure DrawReturn .color$ .x .y .size
92     call DrawConfig '.color$' '.x' '.y' '.size'
93 endproc
95 # Set the correct button states after redrawing hte window
96 procedure setConfigButtons
97     call Draw_button 'config$' Lang_'language$' 2
98     call Draw_button 'config$' Register_'register' 2
99         if displayNumbers
100         call Draw_button 'config$' DisplayNumbers 2
101         endif
102         if displayPinyin
103         call Draw_button 'config$' DisplayPinyin 2
104         endif
105         if displayChar
106         call Draw_button 'config$' DisplayChar 2
107         endif
108         if shuffleLists
109         call Draw_button 'config$' Shuffle 2
110         endif
111         if useSoundExample
112         call Draw_button 'config$' SndExample 2
113         endif
114         if precision < 3
115         call Draw_button 'config$' Precision 2
116         endif
117     call Draw_button 'config$' Input'soundInput$' 2
118     # Handle logging buttons with forced button draw
119     if fileReadable("'preferencesLogDir$'/logPerformance.txt")
120         call Draw_button 'config$' +!Logging 'logPerformance'
121     endif
122 endproc
124 ###############################################################
126 # Button Processing Routines
128 ###############################################################
130 procedure processConfigShuffle .clickX .clickY .pressed$
131         .table$ = "Config"
132         .label$ = "Shuffle"
133         shuffleLists = not shuffleLists
134         .displayButton = 2*shuffleLists
135     call Draw_button '.table$' '.label$' '.displayButton'
136 endproc
138 procedure processConfigSndExample .clickX .clickY .pressed$
139         .table$ = "Config"
140         .label$ = "SndExample"
141         useSoundExample = not useSoundExample
142         .displayButton = 2*useSoundExample
143     call Draw_button '.table$' '.label$' '.displayButton'
144 endproc
145         
146 procedure processConfigPrecision .clickX .clickY .pressed$
147         .table$ = "Config"
148         .label$ = "Precision"
149         if precision >= 3
150                 precision = 1.5
151                 .displayButton = 2
152         else
153                 precision = 3
154                 .displayButton = 0
155         endif
156     call Draw_button '.table$' '.label$' '.displayButton'
157 endproc
159 procedure processConfigDisplayPinyin .clickX .clickY .pressed$
160         .table$ = "Config"
161         .label$ = "DisplayPinyin"
162         displayPinyin = not displayPinyin
163         .displayButton = 2*displayPinyin
164     call Draw_button '.table$' '.label$' '.displayButton'
165 endproc
166                 
167 procedure processConfigDisplayChar .clickX .clickY .pressed$
168         .table$ = "Config"
169         .label$ = "DisplayChar"
170         displayChar = not displayChar
171         .displayButton = 2*displayChar
172     call Draw_button 'table$' '.label$' '.displayButton'
173 endproc
175 procedure processConfigDisplayNumbers .clickX .clickY .pressed$
176         .table$ = "Config"
177         .label$ = "DisplayNumbers"
178         displayNumbers = not displayNumbers
179         .displayButton = 2*displayNumbers
180     call Draw_button 'table$' '.label$' '.displayButton'
181 endproc
183 procedure processConfigLang .language$ .clickX .clickY .pressed$
184         .table$ = "Config"
185         .label$ = "Lang_'.language$'"
186         call processLanguageCodes '.table$' '.label$'
187 endproc
188         
189 procedure processConfigLang_EN .clickX .clickY .pressed$
190         .table$ = "Config"
191         .label$ = "Lang_EN"
192         call processLanguageCodes '.table$' '.label$'
193 endproc
194         
195 procedure processConfigLang_NL .clickX .clickY .pressed$
196         .table$ = "Config"
197         .label$ = "Lang_NL"
198         call processLanguageCodes '.table$' '.label$'
199 endproc
201 procedure processConfigInputMicrophone .clickX .clickY .pressed$
202         .table$ = "Config"
203         .label$ = "InputMicrophone"
204     call Draw_button '.table$' Input'soundInput$' 0
205     call Draw_button '.table$' '.label$' 2
206     .numChars = length(.label$) - length("Input")
207         soundInput$ = right$(.label$, .numChars)
208 endproc
209         
210 procedure processConfigInputLine .clickX .clickY .pressed$
211         .table$ = "Config"
212         .label$ = "InputLine"
213     call Draw_button '.table$' Input'soundInput$' 0
214     call Draw_button '.table$' '.label$' 2
215     .numChars = length(.label$) - length("Input")
216         soundInput$ = right$(.label$, .numChars)
217 endproc
219 procedure processConfigRegister .register .clickX .clickY .pressed$
220         .table$ = "Config"
221         .label$ = "Register_'.register'"
222         call setRegisterFromLabel '.table$' '.label$'
223 endproc
224         
225 procedure processConfigRegister_350 .clickX .clickY .pressed$
226         .table$ = "Config"
227         .label$ = "Register_350"
228         call setRegisterFromLabel '.table$' '.label$'
229 endproc
230         
231 procedure processConfigRegister_300 .clickX .clickY .pressed$
232         .table$ = "Config"
233         .label$ = "Register_300"
234         call setRegisterFromLabel '.table$' '.label$'
235 endproc
236         
237 procedure processConfigRegister_250 .clickX .clickY .pressed$
238         .table$ = "Config"
239         .label$ = "Register_250"
240         call setRegisterFromLabel '.table$' '.label$'
241 endproc
243 procedure processConfigRegister_249 .clickX .clickY .pressed$
244         .table$ = "Config"
245         .label$ = "Register_249"
246         call setRegisterFromLabel '.table$' '.label$'
247 endproc
249 procedure processConfigRegister_180 .clickX .clickY .pressed$
250         .table$ = "Config"
251         .label$ = "Register_180"
252         call setRegisterFromLabel '.table$' '.label$'
253 endproc
255 procedure processConfigRegister_150 .clickX .clickY .pressed$
256         .table$ = "Config"
257         .label$ = "Register_150"
258         call setRegisterFromLabel '.table$' '.label$'
259 endproc
261 procedure setRegisterFromLabel .table$ .label$
262     call Draw_button '.table$' Register_'register' 0
263     call Draw_button '.table$' '.label$' 2
264     # Someone might have to use more than 3 chars for the register code
265     .numChars = length(.label$) - length("Register_")
266         .registerText$ = right$(.label$, .numChars)
267         register = '.registerText$'
268 endproc
270 procedure processConfigDeleteWordlist .clickX .clickY .pressed$
271         .table$ = "Config"
272         .label$ = "DeleteWordlist"
273     call findLabel '.table$' !'.label$'
274         if findLabel.row > 0
275         select Table '.table$'
276         .alertText$ = Get value... 'findLabel.row' Text
277         .confirmKey$ = Get value... 'findLabel.row' Key
278     else
279         exit Cannot find delete directive: '.table$' !'.label$'
280     endif
281     call Draw_button '.table$' '.label$' 2
282     alertText$ = .alertText$
283     call Draw_button '.table$' '.label$' 3
284         alertText$ = ""
285     # Wait for confirmation
286     demoWaitForInput()
287     if demoInput(.confirmKey$)
288         .deleteWordListDir$ = wordlistName$
289         call load_word_list "'localWordlistDir$'" 1
290         call removeWordlist '.deleteWordListDir$'
291     endif
292     call Draw_button '.table$' '.label$' 0
293 endproc
294         
295 procedure processConfigInstallWordlist .clickX .clickY .pressed$
296         .table$ = "Config"
297         .label$ = "InstallWordlist"
298     call Draw_button '.table$' '.label$' 1
299     call sgc2wordlist 'homeDirectory$'
300     call sgc2wordlist 'homeDirectory$'/Downloads
301     call sgc2wordlist 'homeDirectory$'/Desktop
302     call sgc2wordlist 'preferencesDirectory$'/sgc2
303     call Draw_button '.table$' '.label$' 0
304 endproc
305         
306 ###############################################################
308 # Obligatory button Processing Routines
310 # These MUST be defined
312 ###############################################################
314 procedure processConfigReturn .clickX .clickY .pressed$
315         .table$ = "Config"
316         .label$ = "Return"
317         call Draw_button '.table$' '.label$' 1
318         call write_preferences ""
319 endproc
321 procedure processConfigRefresh .clickX .clickY .pressed$
322         .table$ = "Config"
323         .label$ = "Refresh"
324         call Draw_config_page
325 endproc
327 procedure processConfigCredits .clickX .clickY .pressed$
328         .table$ = "Config"
329         .label$ = "Credits"
330         call Draw_button '.table$' '.label$' 1
331         call write_credits
332         demoWaitForInput()
333     call Draw_button '.table$' '.label$' 0
334     demo Erase all
335     call Draw_config_page
336 endproc
338 procedure processConfigHelp .clickX .clickY .pressed$
339         .table$ = "Config"
340         .label$ = "Help"
341         call help_loop  '.table$' Draw_config_page
342 endproc
344 ###############################################################
346 # Miscelaneous supporting code
348 ###############################################################
349 # Word lists: It is a VERY good idea to make sure that word-lists
350 # have unique names.
351 procedure load_word_list .localdir$ .relnumber
352     # Remove old word list
353     if wordlist$ <> ""
354         select Table 'wordlist$'
355         Remove
356        call wipeArea 'wipeWordlistArea$'
357            wordlist$ = ""
358     endif
359     
360         # Create Table that will recieve the wordlists and directories
361         Create Table with column names... AllWordLists 0 Name Directory
362         .currentWordlistRow = 0
363         
364         # Start with the word lists in the distribution, unless the local directory exists!
365         if not fileReadable(.localdir$)
366                 call CreateCreateWordlists
367                 select Table CreateWordlists
368         .numLists = Get number of rows
369                 for .i to .numLists
370                         select Table CreateWordlists
371            .currentName$ = Get value... '.i' Name
372                    .currentDirectory$ = "*call Create'.currentName$'"
373                         select Table AllWordLists
374                         Append row
375                         .currentWordlistRow = Get number of rows
376                         Set string value... '.currentWordlistRow' Name '.currentName$'
377                     .currentDirectory$ = "*call Create'.currentName$'"
378                         Set string value... '.currentWordlistRow' Directory '.currentDirectory$'
379                 endfor
380                 select Table CreateWordlists
381                 Remove
382         endif
383         
384         # First the clobal word lists
385         if fileReadable(globalwordlists$)
386         Create Strings as directory list... WordList 'globalwordlists$'
387         .numLists = Get number of strings
388         for .i to .numLists
389             select Strings WordList
390             .currentName$ = Get string... '.i'
391                         select Table AllWordLists
392                         Append row
393                         .currentWordlistRow = Get number of rows
394                         Set string value... '.currentWordlistRow' Name '.currentName$'
395                     .currentDirectory$ = globalwordlists$+"/"+.currentName$
396                         Set string value... '.currentWordlistRow' Directory '.currentDirectory$'
397         endfor
398         select Strings WordList
399         Remove
400         endif
401         
402         # Now the preferences word lists
403         if fileReadable(sgc2wordlists$)
404         Create Strings as directory list... WordList 'sgc2wordlists$'
405         .numLists = Get number of strings
406         for .i to .numLists
407             select Strings WordList
408             .currentName$ = Get string... '.i'
409                         select Table AllWordLists
410                         Append row
411                         .currentWordlistRow = Get number of rows
412                         Set string value... '.currentWordlistRow' Name '.currentName$'
413                     .currentDirectory$ = sgc2wordlists$+"/"+.currentName$
414                         Set string value... '.currentWordlistRow' Directory '.currentDirectory$'
415         endfor
416         select Strings WordList
417         Remove
418         endif
419         
420         # Finally, the local word lists
421         if fileReadable(.localdir$)
422         Create Strings as directory list... WordList '.localdir$'
423         .numLists = Get number of strings
424         for .i to .numLists
425             select Strings WordList
426             .currentName$ = Get string... '.i'
427                         select Table AllWordLists
428                         Append row
429                         .currentWordlistRow = Get number of rows
430                         Set string value... '.currentWordlistRow' Name '.currentName$'
431                     .currentDirectory$ = .localdir$+"/"+.currentName$
432                         Set string value... '.currentWordlistRow' Directory '.currentDirectory$'
433         endfor
434         select Strings WordList
435         Remove
436     endif
438         # Get the position of the current word list
439         select Table AllWordLists
440         .currentNumber = 1
441     .numLists = Get number of rows
442         if wordlistName$ <> ""
443                 select Table AllWordLists
444                 .currentNumber = Search column... Name 'wordlistName$'
445         endif
446     wordlistNum = .currentNumber + .relnumber
447     if wordlistNum > .numLists
448         wordlistNum = 1
449         elsif wordlistNum < 1
450                 wordlistNum = .numLists
451     endif
452     select Table AllWordLists
453     wordlistName$ = Get value... 'wordlistNum' Name
454         .dirWordlistName$ = Get value... 'wordlistNum' Directory
455     .dirString$ = replace_regex$(.dirWordlistName$, "[ ]", "&", 0)
456         
457         # Read in full tables
458         if fileReadable("'.dirString$'/wordlist.Table")
459         Read from file... '.dirString$'/wordlist.Table
460         Rename... 'wordlistName$'
461         # Praat wil change the name if it feels like it
462         wordlist$ = selected$("Table")
463         # Handle (legacy) simple word lists
464         elsif fileReadable("'.dirString$'/wordlist.txt")
465                 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound
466         wordlist$ = selected$("Table")
467                 Read Strings from raw text file... '.dirString$'/wordlist.txt
468                 Rename... RawWordList
469                 .numWordStrings = Get number of strings
470                 for .i to .numWordStrings
471                         select Strings RawWordList
472                         .currentLine$ = Get string... '.i'
473                         .currentPinyin$ = extractWord$(.currentLine$, "")
474                         if length(.currentLine$) > length(.currentPinyin$)+1
475                                 .currentFile$ = right$(.currentLine$, length(.currentPinyin$)+1)
476                         elsif fileReadable("'.dirString$'/'.currentPinyin$'.spx")
477                                 .currentFile$ = .currentPinyin$+".spx"
478                         elsif fileReadable("'.dirString$'/'.currentPinyin$'.flac")
479                                 .currentFile$ = .currentPinyin$+".flac"
480                         elsif fileReadable("'.dirString$'/'.currentPinyin$'.wav")
481                                 .currentFile$ = .currentPinyin$+".wav"
482                         elsif fileReadable("'.dirString$'/'.currentPinyin$'.mp3")
483                                 .currentFile$ = .currentPinyin$+".mp3"
484                         else
485                                 .currentFile$ = "-"
486                         endif
487                         select Table 'wordlist$'
488                         Append row
489                         Set string value... '.i' Pinyin '.currentPinyin$'
490                         Set string value... '.i' Character -
491                         Set string value... '.i' Sound '.currentFile$'
492                 endfor
493                 select Strings RawWordList
494                 Remove
495                 
496                 select Table 'wordlist$'
497         elsif fileReadable(.dirString$)
498                 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound
499         wordlist$ = selected$("Table")
500                 Create Strings as file list... RawWordList '.dirString$'/*
501                 .numWordStrings = Get number of strings
502                 .i = 0
503                 for .j to .numWordStrings
504                         select Strings RawWordList
505                         .currentLine$ = Get string... '.j'
506                         .currentFile$ = extractWord$(.currentLine$, "")
507                         if index_regex(.currentFile$, "\.(spx|flac|wav|mp3)")
508                                 .currentPinyin$ = left$(.currentFile$, index(.currentFile$, ".")-1)
509                                 select Table 'wordlist$'
510                                 Append row
511                                 .i += 1
512                                 Set string value... '.i' Pinyin '.currentPinyin$'
513                                 Set string value... '.i' Character -
514                                 Set string value... '.i' Sound '.currentFile$'
515                         endif
516                 endfor
517                 select Strings RawWordList
518                 Remove
519                 
520                 select Table 'wordlist$'
521         elsif startsWith(.dirString$, "*call ")
522                 .callProcedure$ = right$(.dirString$, length(.dirString$)-1)
523                 '.callProcedure$'
524                 wordlist$ = selected$("Table")
525         endif
526         
527     numberOfWords = Get number of rows
528     if shuffleLists
529         Randomize rows
530     endif
531         
532         # Clean up
533     select Table AllWordLists
534     Remove
535     
536     # There were no Word Lists
537     label NOWORDLISTS
538     if .numLists <= 0
539         wordlistName$ = "No Word Lists available"
540         wordlistNum = 1
541                 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound
542         wordlist$ = selected$("Table")
543         .i = 0
544                 Append row
545                 .i += 1
546                 Set string value... '.i' Pinyin ni3hao3
547                 Set string value... '.i' Character -
548                 Set string value... '.i' Sound -
549                 Append row
550                 .i += 1
551                 Set string value... '.i' Pinyin xie4xie0
552                 Set string value... '.i' Character -
553                 Set string value... '.i' Sound -
554                 Append row
555                 .i += 1
556                 Set string value... '.i' Pinyin zai4jian4
557                 Set string value... '.i' Character -
558                 Set string value... '.i' Sound -
559         numberOfWords = Get number of rows
560     endif
562         call set_window_title 'buttons$' 'wordlistName$'
563 endproc
565 procedure display_word_list_name
566     .xtext = 50
567     .ytext = 12
568    call reset_viewport
569     .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
570     call wipeArea 'wipeWordlistArea$'
571         call adjustFontSizeOnHeight 'defaultFontSize' 5
572         .currentFontSize = adjustFontSizeOnHeight.newFontSize
574     demo Blue
575         demo Text special... '.xtext' Centre '.ytext' Bottom Helvetica '.currentFontSize' 0 '.displayWordList$'
576     demo Black
577         demoShow()
578         call set_font_size 'defaultFontSize'
579 endproc
581 procedure write_word_list
582         # Draw the contour
583         call draw_tone_contour
585         # Write current Pinyin text
586         call display_text Black
587         
588         # Write the current word list name
589         call display_word_list_name
590 endproc
592 procedure start_logging
593         if fileReadable("'preferencesLogDir$'/logPerformance.txt")
594                 .logDirectory$ < 'preferencesLogDir$'/logPerformance.txt
595                 .logDirectory$ = extractWord$(.logDirectory$, "")
596                 if .logDirectory$ = "" or not fileReadable(.logDirectory$)
597                         .logDirectory$ = "'preferencesDirectory$'/sgc2/log"
598                 endif
599                 createDirectory("'.logDirectory$'/sgc2log")
600                 currentLogDirectory$ = "'.logDirectory$'/sgc2log/log'logtimeStamp$'"
601                 createDirectory(currentLogDirectory$)
602                 if not fileReadable("'currentLogDirectory$'/wordlist.Table")
603                         .headerLine$ = "Pinyin'tab$'Character'tab$'Sound'newline$'"
604                         .headerLine$ > 'currentLogDirectory$'/wordlist.Table
605                 endif
606                         # Flip switch
607                         logPerformance = 1
608         endif
609 endproc
611 procedure log_performance .recordedSound$ .register .precision .pinyin$ .choice$
612         # Log files
613         .currentDate$ = date$()
614         .timeStamp$ = replace_regex$(.currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
615         .choiceText$ = replace_regex$(.choice$, "[^a-zA-Z0-9\-_]", "-", 0)
617         if logPerformance and fileReadable("'preferencesLogDir$'/logPerformance.txt")
618            .outfilename$ = .pinyin$+"_"+.choice$+"_'.register'_"+.timeStamp$+".wav"
619            .logtext$ = .pinyin$+tab$+.choice$+tab$+"'.register'Hz"+tab$+.currentDate$+tab$+.outfilename$+newline$
620            # Plain log text
621            fileappend 'currentLogDirectory$'/logFile.txt '.logtext$'
622            # A wordlist.Table
623            fileappend 'currentLogDirectory$'/wordlist.Table '.pinyin$''tab$''.choice$''tab$''.outfilename$''newline$'
624                 # The recorded sound
625            select Sound 'recordedSound$'
626            Write to WAV file... 'currentLogDirectory$'/'.outfilename$'
627         endif
628 endproc
630 procedure paint_logging_light
631     select Table Config
632     .row = Search column... Label !Logging
633         if .row < 1
634                 exit Button Table Config does not have a row with label !Logging
635         endif
636         # Get button values
637     .leftX = Get value... '.row' LeftX
638     .rightX = Get value... '.row' RightX
639     .lowY = Get value... '.row' LowY
640     .highY = Get value... '.row' HighY
641     .buttonColor$ = Get value... '.row' Color
642     .centerX = (.leftX + .rightX)/2
643     .centerY = (.lowY + .highY)/2
644     .radius = (.highY - .lowY )/(4*2)
645     .wipeRadius = 1.1*.radius
646     if logPerformance and fileReadable("'preferencesLogDir$'/logPerformance.txt")
647         demo Paint circle... White '.centerX' '.centerY' '.wipeRadius'
648         demo Paint circle... '.buttonColor$' '.centerX' '.centerY' '.radius'
649         demoShow()
650     else
651         demo Paint circle... White '.centerX' '.centerY' '.wipeRadius'
652         demoShow()
653     endif
654 endproc
656 # Uninstall word lists
657 procedure removeWordlist .deletedWordlistName$
658     .targetDir$ = ""
659     if fileReadable("'preferencesDirectory$'/sgc2/wordlists/'.deletedWordlistName$'")
660         .targetDir$ = "'preferencesDirectory$'/sgc2/wordlists/'.deletedWordlistName$'"
661     elsif fileReadable("'localWordlistDir$'/'.deletedWordlistName$'")
662         .targetDir$ = "'localWordlistDir$'/'.deletedWordlistName$'"
663     endif
664     Create Strings as file list... DeleteList '.targetDir$'/*
665     .numdeleteFiles = Get number of strings
666     for .i to .numdeleteFiles
667         .file$ = Get string... '.i'
668         deleteFile("'.targetDir$'/'.file$'")
669     endfor
670     deleteFile("'.targetDir$'")
671 endproc
673 # Install word lists
674 procedure sgc2wordlist .sourceDir$
675         if startsWith(.sourceDir$, "preferencesDirectory$")
676                 .sourceDir$ = replace$(.sourceDir$, "preferencesDirectory$", preferencesDirectory$)
677         endif
679         .targetDirectory$ = "'preferencesDirectory$'/sgc2/wordlists"
680         if  fileReadable(.sourceDir$)
681                 Create Strings as file list... PackageList '.sourceDir$'/*.sgc
682                 .numFiles = Get number of strings
683                 for .i to .numFiles
684                         select Strings PackageList
685                         .file$ = Get string... '.i'
686                         .dirname$ = left$(.file$, index(.file$, ".sgc")-1)
687                         .wordlistDirectory$ = .targetDirectory$+"/"+.dirname$
688                         if not (fileReadable(.dirname$) or fileReadable(.wordlistDirectory$))
689                                 createDirectory(.wordlistDirectory$)
690                                 if macintosh or unix
691                                         system cp ''.sourceDir$'/'.file$'' ''.wordlistDirectory$'/'
692                                         system cd ''.wordlistDirectory$'';unzip ''.file$'';rm ''.file$''
693                                 elsif windows
694                                 endif
695                         else
696                                 # printline '.dirname$' already exists
697                         endif
698                 endfor
700                 select Strings PackageList
701                 Remove
702         endif
703 endproc
705 # The Credits
706 procedure write_credits
707         .xleft = 20
708         .xright = 90
709         .ylow = 20
710         .yhigh = 85
711         .lineHeight = 2.5
712         .referenceText$ = "organisational, and financial support from the staff and board of the Digitale Universiteit."
713         .creditsFontSize = 12
715         # Adapt size of button to length of text
716         .maxWidth = (.xright - .xleft) - 3
717         call adjustFontSizeOnWidth '.creditsFontSize' '.maxWidth' '.referenceText$'
718         .creditsFontSize = adjustFontSizeOnWidth.newFontSize
719         if adjustFontSizeOnWidth.diff > 0
720                 .xright += adjustFontSizeOnWidth.diff/4
721                 .xleft -= 3*adjustFontSizeOnWidth.diff/4
722         endif
723         call set_font_size '.creditsFontSize'
725         demo Line width... 8
726         demo Colour... {0.5,0.5,1}
727         demo Paint rectangle... {0.9,0.9,1} '.xleft' '.xright' '.ylow' '.yhigh'
728         demo Draw rectangle... '.xleft' '.xright' '.ylow' '.yhigh'
729         demo Line width... 'defaultLineWidth'
730         demo Black
731         .xleft += 2
732         .dy = .lineHeight
733         .ytext = .yhigh - 2 - .dy
734         demo Text... '.xleft' Left '.ytext' Bottom SpeakGoodChinese version 2.0
735         .ytext -= 2*.dy
736         demo Text... '.xleft' Left '.ytext' Bottom For more information, visit our website: http://www.speakgoodchinese.org
737         .ytext -= .dy
738         demo Text... '.xleft' Left '.ytext' Bottom Based on Praat (http://www.praat.org)
739         .ytext -= 2*.dy
740         demo Text... '.xleft' Left '.ytext' Bottom SpeakGoodChinese was supported by grant 6046 from the Digitale Universiteit
741         .ytext -= 2* .dy
742         demo Text... '.xleft' Left '.ytext' Bottom The SpeakGoodChinese Team 
743         .ytext -= .dy
744         demo Text... '.xleft' Left '.ytext' Bottom * Guanqin Chen (HRO) - Founder and project manager, Language and Teaching
745         .ytext -= .dy
746         demo Text... '.xleft' Left '.ytext' Bottom * Zongyan Chen (HvA) - Language and Teaching
747         .ytext -= .dy
748         demo Text... '.xleft' Left '.ytext' Bottom * Eveline van Hagen (Fontys) - Language and Teaching
749         .ytext -= .dy
750         demo Text... '.xleft' Left '.ytext' Bottom * Stefan de Konink (UvA) - Lead programmer, User Interface
751         .ytext -= .dy
752         demo Text... '.xleft' Left '.ytext' Bottom * Lifeng Liu (HRO) - Language assistant
753         .ytext -= .dy
754         demo Text... '.xleft' Left '.ytext' Bottom * Rob van Son (UvA) - Coordinator technical work, Speech technology, demo GUI
755         .ytext -= .dy
756         demo Text... '.xleft' Left '.ytext' Bottom * Dennis Vierkant (UT) - User Interface and Language
757         .ytext -= .dy
758         demo Text... '.xleft' Left '.ytext' Bottom * David Weenink (UvA) - Praat programming, Algorithms We would like to thank
759         .ytext -= 2*.dy
760         demo Text... '.xleft' Left '.ytext' Bottom We would like to thank Paul Boersma (UvA) for his help with Praat linking 
761         .ytext -= .dy
762         demo Text... '.xleft' Left '.ytext' Bottom and Tristian van Berkom for additional help with the localization code. 
763         .ytext -= .dy
764         demo Text... '.xleft' Left '.ytext' Bottom J.E. Raaijmakers, R. van Rijsselt and S. Verhagen for feedback on the GUI and
765     .ytext -= .dy
766         demo Text... '.xleft' Left '.ytext' Bottom Praat library integration on Windows. 
767         .ytext -= 2*.dy
768         demo Text... '.xleft' Left '.ytext' Bottom We are very grateful for all the practical, organisational, and financial
769         .ytext -= .dy
770         demo Text... '.xleft' Left '.ytext' Bottom support from the staff and board of the Digitale Universiteit.
771   
772         demoShow()      
773         call set_font_size 'defaultFontSize'
774 endproc