Small typo corrected in SGC_ToneProt/README.txt
[sgc.git] / SGC_ToneProt / Wav2CoG.praat
blob11376ab66e544a430bf69f71275e3208f0500f67
1 #! praat
3 # Bulk conversion of WAV to CoG files
4 # Only converts files that do not yet exist in the target directory
6 form Convert sounds to CoG
7     word source_dir ../wordlists/MandarinSounds
8     word target_dir ../wordlists/MandarinSounds/cog
9 endform
11 sourceExt$ = "wav"
12 targetExt$ = "cog"
14 # clearinfo
15 include CoGcalculation.praat
17 Create Strings as file list... SourceList 'source_dir$'/*.'sourceExt$'
18 numberOfFiles = Get number of strings
20 #    printline 'source_dir$'/*.'sourceExt$' 'numberOfFiles' 
22 for i from 1 to numberOfFiles
23     select Strings SourceList
24     inFile$ = Get string... 'i'
25     outputFile$ = replace_regex$(inFile$, sourceExt$+"$", targetExt$, 1)
27     if 1 or not fileReadable("'target_dir$'/'outputFile$'")
28         Read from file... 'source_dir$'/'inFile$'
29         Rename... Source
30         call CoGcalculation
31         Rename... Source
33         Write to short text file... 'target_dir$'/'outputFile$'
35         # Clean up
36         select Sound Source
37         plus Pitch Source
38         Remove
39     endif
40 endfor
41 select Strings SourceList
42 Remove