// This is the master phoneme file.

//*******************************************************************
// Stress Phonemes
//*******************************************************************

phoneme %  //  Unstressed
  stress
  stress_type 1
endphoneme

phoneme %%   //  Diminished stress
  stress
  stress_type 0
endphoneme

phoneme \,   //  [,] Secondary stress
  stress
  stress_type 2
endphoneme

phoneme \,\,  //  [,,] Secondary stress
  stress
  stress_type 3
endphoneme

phoneme '   //  Primary stress
  stress
  stress_type 4
endphoneme

phoneme ''  //  Primary stress (priority)
  stress
  stress_type 5
endphoneme

phoneme '!  //  Primary stress (emphasized)
  stress
  stress_type 6
endphoneme

phoneme =   //  Place stress on previous vowel
  stress
  stress_type 2
endphoneme

//*******************************************************************
// IPA Phonemes
//*******************************************************************

phonemetable ipa base
include ph_ipa

phonemetable base1 base

// The base phoneme table contains the utility phonemes, the consonants,
// and a schwa.  The vowels are defined in the language specific phoneme
// tables, which can also redefine consonants if they wish.


//*******************************************************************
// UTILITY PHONEMES
//*******************************************************************

phoneme ||  //   End Word
  pause
  lengthmod 9  // no effect
endphoneme

phoneme _  //  Short pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 25
endphoneme

phoneme _! //   Short pause, don't replace by linking
  pause
  starttype _ endtype _
  lengthmod 1
  nolink
  length 35
endphoneme

phoneme _|   //  Very short pause
  pause
  starttype _ endtype _
  lengthmod 5
  length 1
endphoneme

phoneme _:   //   Standard pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 75
endphoneme

phoneme _::  //   Long pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 150
endphoneme

phoneme _;_  //   clause pause
  pause
  starttype _ endtype _
  lengthmod 1
  length 200
endphoneme

phoneme  _^_  //  Change dictionary (followed by language-code in ascii
  pause
  starttype _ endtype _
  lengthmod 1
  length 10
endphoneme 

phoneme  _X1  //  a language specific action
  pause
  starttype _ endtype _
  lengthmod 1
  length 10
endphoneme 

phoneme ?  // glottal stp
  vls glt stp
  lengthmod 3   // ??
  nolink
  Vowelin  glstop
  Vowelout glstop
  WAV(ustop/null)
endphoneme


phoneme : //  lengthen previous vowel by "length"
  virtual
  length 70
endphoneme

phoneme - //  Indicates the previous phoneme is a syllabic consonant
  virtual
endphoneme


// Some default vowel definitions

phoneme @    //  Schwa, e.g. alph**a**
  vwl   starttype #@  endtype #@
  unstressed
  length 140
  FMT(vowel/@)
endphoneme


phoneme @-   //  very short schwa
  vwl starttype #@  endtype #@
  unstressed nsy

  ipa ə
  IF nextPhW(*) OR nextPhW(r) THEN
    ipa NULL   // @-* is used to make 'r'
  ENDIF
  length 50
  FMT(vowel/@-)
endphoneme


phoneme a // tr**a**p
  vwl starttype #a endtype #a
  length 180
  FMT(vowel/a)
endphoneme


phoneme e // German **eh**, French **é**
  vwl starttype #e endtype #e
  length 170
  FMT(vowel/e)
endphoneme


phoneme i
  vwl starttype #i endtype #i
  length 170
  IfNextVowelAppend(;)
  FMT(vowel/i)
endphoneme


phoneme o // German **oo**, French **o**
  vwl starttype #o endtype #o
  length 170
  FMT(vowel/oo)
endphoneme


phoneme u
  vwl starttype #u endtype #u
  length 170
  FMT(vowel/u)
endphoneme


// Syllablic consonants
//=====================

phoneme m-
  vwl starttype #@ endtype #@
  ipa mU+0329
  lengthmod 4
  length 170

  IF thisPh(isWordStart) THEN
    length 190
  ENDIF
  IF KlattSynth THEN
    FMT(klatt/m-syl)
  ENDIF
  FMT(m/m-syl)
endphoneme

phoneme n-
  vwl starttype #@ endtype #@
  ipa nU+0329
  lengthmod 4
  length 170

  IF thisPh(isWordStart) THEN
    length 190
  ENDIF
  IF KlattSynth THEN
    FMT(klatt/n-syl)
  ENDIF
  FMT(n/n-syl)
endphoneme

phoneme N-
  vwl starttype #e endtype #e
  ipa ŋU+0329
  lengthmod 4
  length 190
  FMT(nn/nn-syl)
endphoneme


//*******************************************************************
// Other sounds
//*******************************************************************

phoneme #X1  // click, use for indicating capital letters
  vls alv frc sib
  lengthmod 3
  WAV(ustop/percus10, 60)
endphoneme


//*******************************************************************
// VIRTUAL - referred to in vowels'   vwl  starttype and endtype
// These each apply to a class of vowels
//*******************************************************************

phoneme #@  virtual
endphoneme

phoneme #a  virtual
endphoneme

phoneme #e  virtual
endphoneme

phoneme #i  virtual
endphoneme

phoneme #o  virtual
endphoneme

phoneme #u  virtual
endphoneme


//*******************************************************************
// SONORANTS
//*******************************************************************


phoneme r-   // syllabic r
  vwl  starttype #@  endtype #@
  ipa rU+0329
  unstressed
  length 220
  FMT(vowelr/r-voc)
endphoneme

phoneme l-   // syllabic l
  vwl  starttype #@  endtype #@
  ipa lU+0329
  unstressed
  length 200
  FMT(vwl_hi/l-voc)
endphoneme


phoneme r // **r**ed (Omitted if not immediately followed by a vowel)
  import_phoneme ipa/r\\
endphoneme

phoneme r/   // used for [r] when not preceding a vowel
  import_phoneme ipa/r\\
endphoneme



phoneme R
  liquid trl
  lengthmod 6
  ipa r
  IF nextPhW(R2) THEN
    ipa NULL
  ENDIF
  Vowelin  f1=0  f2=1600 -300 300  f3=-200 80
  Vowelout f1=2  f2=1600 -300 300  f3=-200 80 brk
  FMT(r3/r_trill2) addWav(r3/r_trill2.wav, 65)
endphoneme

phoneme R2   // this is [R] from Slovak/Czech
  liquid trl
  lengthmod 6
  ipa r
  Vowelin  f1=0  f2=1700 -300 300  f3=-300 80
  Vowelout f1=2  f2=1700 -300 300  f3=-300 80 brk
  FMT(r3/r_trill) addWav(r3/r_trill.wav, 50)
endphoneme

phoneme R3  // Afrikaans
  liquid trl
  lengthmod 6
  length 60
  ipa r
  Vowelin  f1=2  f2=2700 -300 -200  f3=-1300 80  
  Vowelout f1=2  f2=1700 -300 -200  f3=-1300 80

  // vowel modifier is the same as for [r]
  NextVowelStarts
    VowelStart(r/r@, -15)
    VowelStart(r/ra, -15)
    VowelStart(r/re, -15)
    VowelStart(r/ri, -15)
    VowelStart(r/ro, -15)
    VowelStart(r/ru, -15)
  EndSwitch

  IF prevPh(isVowel) THEN
    VowelEnding(r/xr, -50)
  ENDIF

  FMT(r3/r_trill) addWav(r3/r_trill3.wav)
endphoneme


phoneme r"     // uvular trill
  vcd uvl frc
  ipa ʀ
  lengthmod 6
  IF nextPh(isNotVowel) THEN
    FMT(r3/r_uvl) addWav(r3/r_uvl.wav, 50)
  ENDIF
  FMT(r3/r_uvl) addWav(r3/r_uvl.wav, 75)
endphoneme


procedure vowelstart_l
  NextVowelStarts
    VowelStart(l/l@)
    VowelStart(l/la)
    VowelStart(l/le)
    VowelStart(l/li, -10)
    VowelStart(l/lo)
    VowelStart(l/lu)
  EndSwitch
endprocedure

phoneme l
  liquid
  lengthmod 7

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(l/)
  ENDIF

  IF nextPh(isNotVowel) THEN
    // in case the next phoneme is no longer a vowel, in pass=2
    PrevVowelEndings
      VowelEnding(l/L1_@L, -60)
      VowelEnding(l/L1_aL, -40)
      VowelEnding(l/L1_eL, -30)
      VowelEnding(l/L1_iL, -30)
      VowelEnding(l/L1_oL, -40)
      VowelEnding(l/L1_uL, -40)
    EndSwitch

    FMT(l/l_)
    RETURN
  ENDIF

  CALL vowelstart_l

  IF prevPh(#@) THEN
    VowelEnding(l/xl, -50)
  ELIF prevPh(isVowel) THEN
    VowelEnding(l/xl, -40)
  ENDIF

  IF prevPh(isPause) THEN
    FMT(l/_l)
  ENDIF

  IF prevPh(t) THEN
    FMT(l/tl)
  ENDIF

  IF prevPh(l/) THEN
    FMT(l/l_long)    // double l, make it longer
  ENDIF

  FMT(l/l)
endphoneme


phoneme l/    // used for [l] when not before a vowel
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/L1_@L, -60)
    VowelEnding(l/L1_aL, -40)
    VowelEnding(l/L1_eL, -30)
    VowelEnding(l/L1_iL, -30)
    VowelEnding(l/L1_oL, -40)
    VowelEnding(l/L1_uL, -40)
  EndSwitch

  // we need to replace these with new FMT sequeces for jl and wl
  IF prevPhW(j) THEN
    FMT(l/L1_eL)
  ENDIF
  IF prevPhW(w) THEN
    FMT(l/L1_eL)
  ENDIF

  FMT(l/l_)
endphoneme

phoneme l/2    // 'dark' [l] after a vowel
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  CALL vowelstart_l

  IF prevPhW(j) THEN
    FMT(l/L2_eL)
  ENDIF
  IF prevPhW(w) THEN
    FMT(l/L2_uL)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/L2_@L, -60)
    VowelEnding(l/L2_aL, -50)
    VowelEnding(l/L2_eL, -40)
    VowelEnding(l/L2_iL, -30)
    VowelEnding(l/L2_oL, -50)
    VowelEnding(l/L2_uL, -40)
  EndSwitch
endphoneme

phoneme l/3    // Replacement for [l/]
  liquid
  lengthmod 7

  IF nextPh(isVowel) THEN
    ChangePhoneme(l)
  ENDIF

  PrevVowelEndings
    VowelEnding(l/l_@)
    VowelEnding(l/l_a)
    VowelEnding(l/l_e)
    VowelEnding(l/l_i)
    VowelEnding(l/l_o)
    VowelEnding(l/l_u, -20)
  EndSwitch

//  IF nextPh(isLiquid) THEN
//    FMT(l/_l)
//  ENDIF

  FMT(l/l_)
endphoneme

phoneme l^    // palatal l, e.g. Italian **g**li
  import_phoneme ipa/L
endphoneme

phoneme l.
  import_phoneme ipa/l`
endphoneme

phoneme L/
  import_phoneme base1/l/2
endphoneme

phoneme L   // velar L
  import_phoneme ipa/L\\
endphoneme

phoneme w
  import_phoneme ipa/w
endphoneme

phoneme j // **y**es
  import_phoneme ipa/j
endphoneme

phoneme ;     // linking j, used between (i) vowels and a following vowel
              // also to palatalize consonants
  liquid pzd
  lengthmod 0

  IF prevPh(#i) THEN
    ipa NULL   // linking after i vowel, don't show in ipa
  ENDIF

  IF nextPh(isNotVowel) THEN
    ChangePhoneme(NULL)   // this is to ignore this phoneme if not before a vowel
  ENDIF

  NextVowelStarts
    VowelStart(j2/j2@)
    VowelStart(j2/j2a)
    VowelStart(j2/j2e)
    VowelStart(j2/j2i)
    VowelStart(j2/j2o)
    VowelStart(j2/j2u)
  EndSwitch

  IF prevPh(#i) THEN
    VowelEnding(j2/xj2, -40)
  ENDIF

  IF prevPh(isPause) THEN
    FMT(j2/_j2)
  ENDIF
endphoneme


//*******************************************************************
// NASAL CONSONANTS
//*******************************************************************

phoneme m
  import_phoneme ipa/m
endphoneme

phoneme n
  import_phoneme ipa/n
endphoneme

phoneme n.
  import_phoneme ipa/n`
endphoneme

phoneme n^ // Spanish **ñ**
  import_phoneme ipa/J
endphoneme

phoneme N // si**ng** 
  import_phoneme ipa/N
endphoneme


phoneme **    //   TEST flap
  liquid alv rhotic
  ipa ɾ
  lengthmod 3
  Vowelout f1=3 f2=1600 -300 300  f3=-300 80 rms=35 len=15
  Vowelin f1=2  f2=1600 -300 300  f3=-100 80 len=20

  IF prevPh(#i) OR prevPh(#e) THEN
    FMT(r3/@tap2)
  ENDIF
  FMT(r3/@tap)
endphoneme



phoneme *    //   flap
  vcd alv flp rhotic
  brkafter
  ipa ɾ
  lengthmod 3

  IF prevPhW(@-) THEN
    ipa r   // @-*  sequence for [r]
  ENDIF

  IF nextPh(#e) OR nextPh(#i) THEN
    Vowelin f1=0  f2=1500 -300 300  f3=-200 80
    FMT(d/tap1) addWav(r3/rx, 150)
    FMT(d/tap1) addWav(r3/rx, 150)
  ENDIF

  Vowelin f1=2  f2=1500 -300 300  f3=-200 80
  IF nextPh(#a) THEN
    FMT(d/tap3) addWav(r3/rx, 200)
  ENDIF

  IF nextPh(r) THEN
    FMT(d/dr)
  ENDIF

  Vowelout f1=3 f2=1500 -400 300  f3=-200 80 rms=35 len=50
  Vowelin f1=0  f2=1500 -300 300  f3=-200 80
  FMT(d/tap3) addWav(r3/rx, 200)
endphoneme



phoneme r.    //   retroflex
  liquid rfx
  lengthmod 3
  Vowelout f1=3 f2=1400 -400 300  f3=-400 80 rms=35 len=15 colr=2
  Vowelin f1=2  f2=1400 -400 300  f3=-400 80 len=20
  
  IF nextPh(isNotVowel) THEN
    FMT(r3/@tap_rfx_)
  ENDIF
  FMT(r3/@tap_rfx)
endphoneme


//*******************************************************************
// VOICED STOPS
//*******************************************************************


phoneme b
  import_phoneme ipa/b
  voicingswitch p 
endphoneme

phoneme d
  import_phoneme ipa/d
  voicingswitch t
endphoneme

phoneme d[
  import_phoneme ipa/d_d
  voicingswitch t[
endphoneme

phoneme dZ // **j**udge
  import_phoneme ipa/dZ\)
  voicingswitch tS
endphoneme

phoneme dZ;
  import_phoneme ipa/dz\\\)
  voicingswitch tS;
endphoneme

phoneme J
  import_phoneme ipa/J\\
  voicingswitch c
endphoneme

phoneme g
  import_phoneme ipa/g
  voicingswitch k
endphoneme


//*******************************************************************
// VOICED fricatives
//*******************************************************************


phoneme B
  import_phoneme ipa/B
  voicingswitch f
endphoneme

phoneme v
  import_phoneme ipa/v
  voicingswitch f
endphoneme

phoneme v#
  import_phoneme ipa/P
  voicingswitch f
endphoneme

phoneme D // **th**is
  import_phoneme ipa/D
  voicingswitch T
endphoneme

phoneme z
  import_phoneme ipa/z
  voicingswitch s
endphoneme

phoneme Z // plea**s**ure
  import_phoneme ipa/Z
  voicingswitch S
endphoneme

phoneme z.
  import_phoneme ipa/z`
  voicingswitch s.
endphoneme

phoneme z;
  import_phoneme ipa/z_j
  voicingswitch s;
endphoneme

phoneme Z;
  import_phoneme ipa/z\\
  voicingswitch S;
endphoneme

phoneme J^   // palatal fricative (Kirshenbaum C<vcd>)
  import_phoneme ipa/j\\
  ipa ʝ
endphoneme

phoneme Q
  import_phoneme ipa/G
  voicingswitch x
endphoneme

phoneme Q"
  import_phoneme ipa/R
endphoneme


//*******************************************************************
// UNVOICED STOPS
//*******************************************************************


phoneme p
  import_phoneme ipa/p
  voicingswitch b
endphoneme

phoneme t
  import_phoneme ipa/t
  voicingswitch d
endphoneme

phoneme t[        // dental variant of /t/
  import_phoneme ipa/t_d
  voicingswitch d[
endphoneme

phoneme tS     // **ch**urch
  import_phoneme ipa/tS\)
  voicingswitch dZ
endphoneme

phoneme tS;
  import_phoneme ipa/ts\\\)
  voicingswitch dZ;
endphoneme

phoneme c
  import_phoneme ipa/c
  voicingswitch J
endphoneme

phoneme k
  import_phoneme ipa/k
  voicingswitch g
endphoneme

phoneme q
  import_phoneme ipa/q
endphoneme


//*******************************************************************
// UNVOICED fricatives
//*******************************************************************


phoneme f
  import_phoneme ipa/f
  voicingswitch v
endphoneme

phoneme T   // **th**in
  import_phoneme ipa/T
  voicingswitch D
endphoneme

phoneme s
  import_phoneme ipa/s
  voicingswitch z
endphoneme

phoneme S // **sh**op
  import_phoneme ipa/S
  voicingswitch Z
endphoneme

phoneme s.
  import_phoneme ipa/s`
  voicingswitch z.
endphoneme

phoneme s;
  import_phoneme ipa/s_j
  voicingswitch z;
endphoneme

phoneme S;
  import_phoneme ipa/s\\
  voicingswitch Z;
endphoneme

phoneme l#   // Lateral fricative (eg. Welsh "ll")
  import_phoneme ipa/K
endphoneme

phoneme C // German i**ch**
  import_phoneme ipa/C
endphoneme

phoneme x // German bu**ch**
  import_phoneme ipa/x
  voicingswitch Q
endphoneme

phoneme X
  import_phoneme ipa/X
  voicingswitch Q"
endphoneme

phoneme h
  import_phoneme ipa/h
endphoneme


//*******************************************************************
// ADDITIONAL PHONEME TABLES
//*******************************************************************

phonemetable jp base1
include ph_japanese

phonemetable consonants base1
include ph_consonants


phonemetable base2 base1
include ph_base2

phonemetable en base1
include ph_english

phonemetable en-n en
include ph_english_n

phonemetable en-us en
include ph_english_us

phonemetable en-sc en
include ph_english_sc

phonemetable en-rp en
include ph_english_rp

phonemetable en-wm en
include ph_english_wm

phonemetable en-wi en
include ph_english_wi


phonemetable af base1
include ph_afrikaans

phonemetable cy base1
include ph_welsh

phonemetable ga base1
include ph_irish

phonemetable de base1
include ph_german

phonemetable eo base1
include ph_esperanto

phonemetable ia eo
include ph_interlingua

phonemetable jbo eo
include ph_lojban

phonemetable nci base2
include ph_nahuatl

phonemetable fi base1
include ph_finnish

phonemetable et base1
include ph_estonian

phonemetable fr base1
include ph_french

phonemetable fr-ca fr
include ph_french_ca

phonemetable nl base1
include ph_dutch


phonemetable hi_base base1
include ph_hindi_base

phonemetable hi hi_base
include ph_hindi

phonemetable bn hi_base
include ph_bengali

phonemetable ne hi_base
include ph_nepali

phonemetable ur hi_base
include ph_urdu

phonemetable pa hi_base
include ph_punjabi

phonemetable ta hi_base
include ph_tamil

phonemetable kn hi_base
include ph_kannada

phonemetable ml hi_base
include ph_malayalam

phonemetable gu hi_base
include ph_gujarati

phonemetable mr hi_base
include ph_marathi

phonemetable kok hi_base
include ph_konkani


phonemetable hu base1
include ph_hungarian

phonemetable lt base1
include ph_lithuanian


phonemetable lv base1
include ph_latvian

phonemetable pl base1
include ph_polish

phonemetable sk pl
include ph_slovak

phonemetable cs sk
include ph_czech

phonemetable hr sk
include ph_croatian

phonemetable mk hr
include ph_macedonian

phonemetable sr hr
include ph_serbian

phonemetable ru base1
include ph_russian

phonemetable bg pl
include ph_bulgarian


phonemetable it base2
include ph_italian

phonemetable la base1
include ph_latin

phonemetable es base2
include ph_spanish

phonemetable es-la es
include ph_spanish_la

phonemetable ca es
include ph_catalan

phonemetable an es
include ph_aragon

phonemetable eu base2
include ph_basque

phonemetable pt base2
include ph_pt_brazil

phonemetable pt-pt pt
include ph_portugal

phonemetable ro base2
include ph_romanian

phonemetable el base2
include ph_greek

phonemetable grc base2
include ph_greek_ancient

phonemetable sv base1
include ph_swedish

phonemetable no base1
include ph_norwegian

phonemetable is base1
include ph_icelandic

phonemetable vi base1
include ph_vietnam

phonemetable vi-hue vi
include ph_vietnam_hue

phonemetable vi-sgn vi
include ph_vietnam_sgn

phonemetable zhy base1
include ph_zh_yue

phonemetable zh base1
include ph_zh


phonemetable sw base1
include ph_swahili

phonemetable tr base2
include ph_turkish

phonemetable ku base2
include ph_kurdish

phonemetable id base2
include ph_indonesian

phonemetable sq base1
include ph_albanian

phonemetable hy base1
include ph_armenian

phonemetable da base1
include ph_danish

phonemetable ka base1
include ph_georgian

phonemetable fa base1
include ph_farsi

phonemetable ar base1
include ph_arabic

phonemetable rw base2
include ph_kinyarwanda

phonemetable prs base1
include ph_dari

phonemetable sl pl
include ph_slovenian

phonemetable gd base1
include ph_s_gaelic

phonemetable nso base1
include ph_northern-sotho

phonemetable ht fr
include ph_haitian

phonemetable az tr
include ph_azerbaijani

phonemetable ak base1
include ph_akan

phonemetable am base1
include ph_amhari

phonemetable wo base1
include ph_wolof

phonemetable dv hi_base
include ph_divehi

phonemetable te hi_base
include ph_telugu

phonemetable si hi_base
include ph_sinhala

phonemetable as bn
include ph_assamese

phonemetable or bn
include ph_oriya

phonemetable bpy bn
include ph_manipuri

phonemetable sd ur
include ph_sindhi

phonemetable tn base1
include ph_setswana

phonemetable mt base1
include ph_maltese

phonemetable bo hi
include ph_tibetan

phonemetable kk base1
include ph_kazakh

phonemetable tt base1
include ph_tatar

phonemetable ko base1
include ph_korean

phonemetable kl base1
include ph_greenlandic

phonemetable om base1
include ph_oromo

phonemetable my base1
include ph_burmese

phonemetable gn base1
include ph_guarani

phonemetable ky base1
include ph_kyrgyz

phonemetable mi base1
include ph_maori
