3 # Synthesize Mandarin by concatenating syllables.
4 # Has some very rudimentary kludges for creating
5 # neutral tone syllables from fourth tone syllables
6 # (should not sound acceptable)
8 # The sourcedir should be the mandaring sounds dir.
12 word sourcedir ../wordlists/MandarinSounds
15 pinyinProcessed$ = replace_regex$(pinyin$, "^\s*([a-zA-Z]+)3([a-zA-Z]+)3$", "\12\23", 0)
18 while pinyinProcessed$ > " "
19 currentsyllable$ = replace_regex$(pinyinProcessed$, "^\s*([a-zA-Z]+[0-9]).*$", "\1", 0)
20 pinyinProcessed$ = replace_regex$(pinyinProcessed$, "^\s*[a-zA-Z]+[0-9](.*)$", "\1", 0)
22 if rindex_regex(currentsyllable$, "0\s*$") > 0
23 newSyllable$ = replace_regex$(currentsyllable$, "^\s*([a-zA-Z]+)0$", "\14", 0)
24 Read from file... 'sourcedir$'/'newSyllable$'.wav
25 Rename... 'currentsyllable$'
26 Lengthen (PSOLA)... 75 600 0.7
28 select Sound 'currentsyllable$'
30 select Sound Shortened
32 To Manipulation... 0.01 75 600
35 Shift frequencies... 0 1000 -6 semitones
36 select Manipulation Shortened
37 plus PitchTier Shortened
39 select Manipulation Shortened
40 Get resynthesis (PSOLA)
41 Rename... 'currentsyllable$'
44 select Manipulation Shortened
46 plus PitchTier Shortened
49 select Sound 'currentsyllable$'
51 Read from file... 'sourcedir$'/'currentsyllable$'.wav
54 To TextGrid (silences)... 100 0 -20 0.1 0.1 silent sounding
56 numIntervals = Get number of intervals... 1
59 for i from 1 to numIntervals
61 currentLabel$ = Get label of interval... 1 'i'
62 if currentLabel$ = "sounding"
64 startTime = Get starting point... 1 'i'
66 endTime = Get end point... 1 'i'
69 if startTime > 0.050 and rindex_regex(currentsyllable$, "^[ktpgdbz]") > 0
70 startTime = startTime - 0.050
73 Extract part... 'startTime' 'endTime' Rectangular 1.0 0
74 Rename... 'currentsyllable$'
80 numSounds = numSounds + 1
82 select Sound 'currentsyllable$'
85 select Sound 'pinyin$'
86 plus Sound 'currentsyllable$'
89 select Sound 'pinyin$'
90 plus Sound 'currentsyllable$'