
//====================================================
//  Portuguese  - based on Base2
//====================================================

phoneme I   // epenthetic i
  vowel starttype #i endtype #i
  unstressed
  length 90
  FMT(vowel/ii_6)
endphoneme

phoneme e~
  vowel starttype #e endtype #e
  length 240
  FMT(vnasal/e_n)
endphoneme

phoneme i~
  vowel starttype #i endtype #i
  length 240
  IfNextVowelAppend(;)
  FMT(vnasal/i_n)
endphoneme

phoneme o~
  vowel starttype #o endtype #o
  length 240
  FMT(vnasal/o_n)
endphoneme

phoneme u~
  vowel starttype #u endtype #u
  length 180
  FMT(vnasal/u_n)
endphoneme

phoneme &~
  vowel  starttype #@ endtype #@
  ipa ɐU+0303
  length 180
  IF thisPh(isFinalVowel) THEN
    FMT(vnasal/a#_n2)
  ELSE
    FMT(vnasal/a#_n)
  ENDIF
endphoneme

phoneme &U~
  vowel  starttype #@ endtype #u
  ipa ɐU+0303ʊU+0303
  length 240
  FMT(vnasal/a#u_n)
endphoneme

phoneme oI~
  vowel starttype #o endtype #i
  ipa oU+0303ɪU+0303
  length 260
  FMT(vnasal/oi_n)
endphoneme




phoneme &
  vowel starttype #@ endtype #@
  length 180
  FMT(vowel/a#_3)
endphoneme

phoneme &/       // Used for final "a" when next word starts with "a"
  vowel starttype #@ endtype #@
  length 180
  IF nextPh(isVowel) THEN
    ChangePhoneme(NULL)
  ENDIF
  FMT(vowel/a#_3)
endphoneme


phoneme A            // for "al" in European Portuguese, don't reduce to [&]
  vowel starttype #a endtype #a
  length 200
  FMT(vowel/a_2)
endphoneme



phoneme E
  vowel starttype #e endtype #e
  length 170
  FMT(vowel/ee_3)
endphoneme

phoneme e
  vowel starttype #e endtype #e
  length 160
  FMT(vowel/e)
endphoneme


phoneme y          // this is the same as [i] for Brazil
  vowel starttype #i endtype #i
  length 110
  IfNextVowelAppend(;)
  FMT(vowel/ii_6)
endphoneme


phoneme i/            // changes to [j] before a vowel
  vowel starttype #i endtype #i
  length 150
  IF nextPh(isVowel) THEN
    ChangePhoneme(j)
  ENDIF
  IfNextVowelAppend(;)
  FMT(vowel/ii_6)
endphoneme


phoneme O
  vowel starttype #o endtype #o
  length 170
  FMT(vowel/0)
endphoneme


phoneme u
  vowel starttype #u endtype #u
  length 160
  FMT(vowel/u_bck)
endphoneme

phoneme U
  vowel starttype #u endtype #u
  length 140
  IF thisPh(isWordEnd) AND thisPh(isAfterStress) AND nextPh(isVowel) THEN
    ChangePhoneme(w)
  ENDIF
  FMT(vowel/uu_bck)
endphoneme




phoneme aI
  vowel starttype #a endtype #i
  length 230
  IfNextVowelAppend(;)
  FMT(vdiph/ai)
endphoneme


phoneme eI
  vowel starttype #e endtype #i
  length 210
  IfNextVowelAppend(;)
  FMT(vdiph/ei)
endphoneme


phoneme OI
  vowel starttype #o endtype #i
  length 230
  IfNextVowelAppend(;)
  FMT(vdiph/0i)
endphoneme


phoneme eU
  vowel starttype #e endtype #u
  length 230
  FMT(vdiph/eu)
endphoneme


phoneme EU
  vowel starttype #e endtype #u
  length 230
  FMT(vdiph/eeu)
endphoneme




phoneme l
  import_phoneme en/l   // use 'dark' [l] after a vowel, should be [w]
endphoneme


phoneme x
  CALL base/h
  ipa x
endphoneme


phoneme r-
  import_phoneme en/r-
endphoneme


phoneme s#     // This is [s] for Brazil, [S] for Portugal
  IF nextPh(isVoiced) THEN
    ChangePhoneme(z)
  ENDIF

  CALL base/s
  ipa s
endphoneme


phoneme *
  vcd alv stop
  lengthmod 6
  ipa ɾ
  Vowelin f1=1  f2=1700 -300 300  f3=0 80
  Vowelout f1=2 f2=1700 -300 300  f3=0 80
  IF PreVoicing THEN
    FMT(d/x_tap)
  ENDIF
  FMT(d/tap2) addWav(x/d, 40)
endphoneme

