Debian Codegraph @

docs/phontab.md

raw symbols SCIP
1 # Phoneme Tables
2
3 - [Phoneme files](#phoneme-files)
4 - [Phoneme Definitions](#phoneme-definitions)
5 - [Phoneme Properties](#phoneme-properties)
6 - [Type](#type)
7 - [Properties](#properties)
8 - [starttype](#starttype)
9 - [endtype](#endtype)
10 - [lengthmod](#lengthmod)
11 - [voicingswitch](#voicingswitch)
12 - [Phoneme Instructions](#phoneme-instructions)
13 - [length](#length)
14 - [ipa](#ipa)
15 - [WAV](#wav)
16 - [FMT](#fmt)
17 - [VowelStart](#vowelstart)
18 - [VowelEnding](#vowelending)
19 - [Vowelin](#vowelin)
20 - [Vowelout](#vowelout)
21 - [ChangePhoneme](#changephoneme)
22 - [ChangeIfDiminished](#changeifdiminished)
23 - [ChangeIfUnstressed](#changeifunstressed)
24 - [ChangeIfNotStressed](#changeifnotstressed)
25 - [ChangeIfStressed](#changeifstressed)
26 - [IfNextVowelAppend](#ifnextvowelappend)
27 - [RETURN](#return)
28 - [CALL](#call)
29 - [Conditional Statements](#conditional-statements)
30 - [Conditions](#conditions)
31 - [Attributes](#attributes)
32 - [Sound Specifications](#sound-specifications)
33 - [Vowel Transitions](#vowel-transitions)
34 - [Customization of sound source files](#customization-of-sound-source-files)
35
36 ----------
37
38 A phoneme table defines all the phonemes which are used by a language,
39 together with their properties and the data for their production as
40 sounds.
41
42 Generally each language has its own phoneme table, although additional
43 phoneme tables can be used for different voices within the language.
44 These alternatives are referenced from Voice files.
45
46 A phoneme table does not need to define all the phonemes used by a
47 language. It can inherit the phonemes from a previously defined phoneme
48 table. For example, a phoneme table may redefine (or add) some of the
49 vowels that it uses, but inherit most of its consonants from a standard
50 set.
51
52 The source files for the phoneme data are in the "phsource" directory.
53 "Vowel files", which are referenced in `FMT()`, `VowelStart()`, and `VowelEnding()`
54 instructions are made using the `espeakedit` program which is not part of this project.
55 See more in [Customization of sound source files](#customization-of-sound-source-files).
56
57 ## Phoneme Files
58
59 The phoneme tables are defined in a master phoneme file, named
60 `phonemes`. This starts with the `base` phoneme table followed by
61 phoneme tables for other languages and voices. These inherit phonemes
62 from the `base` table or previously defined tables.
63
64 In addition to phoneme definitions, the phoneme file can contain the
65 following:
66
67 include <filename>
68
69 Includes the text of the specified file at this point. This allows
70 different phoneme tables to be kept in different text files, for
71 convenience. \<filename\> is a relative path. The included file can
72 itself contain `include` statements.
73
74 phonemetable <name> <parent>
75
76 Starts a new phoneme table, and ends the previous table.
77
78 \<name\> Is the name of this phoneme table. This name is used in Voice files.
79
80 \<parent\> Is the name of a previously defined phoneme table whose phoneme
81 definitions are inherited by this one. The name `base` indicates the first
82 (base) phoneme table. The name `_` indicates no parent phoneme table.
83
84 ## Phoneme Definitions
85
86 A phoneme table contains a list of phoneme definitions. Each starts with
87 the keyword `phoneme` and the phoneme name (this is the name used in
88 the pronunciation rules in a language's \*\_rules and \*\_list files),
89 and ends with the keyword `endphoneme`.
90
91 For example:
92
93 phoneme aI
94 vwl
95 starttype #a endtype #i
96 length 230
97 FMT(vowels/ai)
98 endphoneme
99
100 phoneme s
101 vls alv sib frc
102 voicingswitch z
103 lengthmod 3
104 Vowelin f1=0 f2=1700 -300 300 f3=-100 80
105 Vowelout f1=0 f2=1700 -300 250 f3=-100 80 rms=20
106
107 IF nextPh(isPause) THEN
108 WAV(ufric/s_)
109 ELIF nextPh(p) OR nextPh(t) OR nextPh(k) THEN
110 WAV(ufric/s!)
111 ENDIF
112 WAV(ufric/s)
113 endphoneme
114
115 A phoneme definition contains both static properties and executed
116 instructions. The instructions may contain conditional statements, so
117 that the effect of the phoneme may be different depending on adjacent
118 phonemes, whether the syllable is stressed, etc.
119
120 The instructions of a phoneme are interpreted in two different phases.
121 In the first phase, the instructions may change the phoneme and replace
122 it by a different phoneme. In the second phase, instructions are used to
123 produce the sound for the phoneme.
124
125 The `import_phoneme` statement can be used to copy a previously
126 defined phoneme from a specified phoneme table. For example:
127
128 phoneme t
129 import_phoneme base/t[
130 endphoneme
131
132 means: `phoneme t` in this phoneme table is a copy of`phoneme t[` from phoneme
133 table `base`. A `length` instruction can be used after `import\_phoneme` to
134 vary the length from the original.
135
136 ## Phoneme Properties
137
138 The phoneme features are described in the [Phonemes](phonemes.md) document. These
139 should be included within the `phoneme` to fully describe that phoneme.
140
141 Within the phoneme definition the following lines may also occur: (`(V)` indicates
142 only for vowels, `(C)` only for consonants).
143
144 ### Type
145
146 One of these or a manner of articulation from the [Phonemes](phonemes.md) document
147 must be present.
148
149 | Type | Description |
150 |-----------|-------------|
151 | `liquid` | semi-vowels, such as: `r`, `l`, `j`, `w` |
152 | `pause` | |
153 | `stress` | Used for stress symbols, eg: `'` `,` `=` `%` |
154 | `virtual` | Used to represent a class of phonemes. |
155
156 ### Properties
157
158 | Property | Type | Description |
159 |--------------|------|-------------|
160 | `rhotic` | (C) | An `r` type consonant. |
161 | `unstressed` | (V) | This vowel is always unstressed, unless explicitly marked otherwise. |
162 | `nolink` | | Prevent any linking from the previous phoneme. |
163 | `nopause` | | Used in a `liquid` or `nasal` phoneme to prevent eSpeak NG inserting a short pause if a word starts with this phoneme and the previous word ends with a vowel. |
164 | `trill` | (C) | Apply trill to the voicing. |
165
166 ### starttype
167
168 starttype <phoneme>
169
170 Allocates this phoneme to a group so that conditions such as `nextPh(#e)` can
171 test for any of a group of phonemes. Pre-defined groups for use for vowels are:
172 `#@` `#a` `#e` `#i` `#o` `#u`. Additional groups can be defined as phonemes
173 with type `virtual`.
174
175 ### endtype
176
177 endtype <phoneme>
178
179 Allocates this phoneme to a group so that conditions such as `prevPh(#e)` can
180 test for any of a group of phonemes. Pre-defined groups for use for vowels are:
181 `#@` `#a` `#e` `#i` `#o` `#u`. Additional groups can be defined as phonemes
182 with type `virtual`.
183
184 ### lengthmod
185
186 lengthmod <integer>
187
188 (C) Determines how this consonant affects the length of the previous vowel.
189
190 This value is used as index into the `length_mods` table in the `CalcLengths()`
191 function in the eSpeak NG program.
192
193 ### voicingswitch
194
195 voicingswitch <phoneme>
196
197 This is used for some languages to change between voiced and unvoiced phonemes.
198
199 ## Phoneme Instructions
200
201 Phoneme Instructions may be included within conditional statements.
202
203 During the first phase of phoneme interpretation, an instruction which
204 causes a change to a different phoneme will terminate the instructions.
205 During the second phase, `FMT()` and `WAV()` instructions will terminate the
206 instructions.
207
208 ### length
209
210 length <length>
211
212 The relative length of the phoneme in milliseconds. Typical values are about
213 140 for a short vowel and from 200 to 300 for a long vowel or a diphthong.
214 A `length()` instruction is needed for vowels. It is optional for consonants.
215
216 ### ipa
217
218 ipa <ipa string>
219
220 In many cases, eSpeak NG makes IPA (International Phonetic Alphabet) phoneme
221 names automatically from eSpeak NG phoneme names. If this is not correct, then
222 the phoneme definition can include an `ipa` instruction to specify the correct
223 IPA name. IPA strings may include non-ascii characters. They may also include
224 characters specified by their character codes in the form `U+` followed by 4
225 hexadecimal digits. For example a string: `aU+0303` indicates 'a' with a
226 'combining tilde'.
227
228 ### WAV
229
230 WAV(<wav file>, <amplitude>)
231
232 \<wav file\> is a path to a WAV file (22 kHz, 16 bits, mono) within `phsource/`
233 which will be played to produce the sound. This method is used for unvoiced
234 consonants. \<wavefile\> does not include a .WAV filename extension, although
235 the file to which it refers may or may not have one.
236
237 \<amplitude\> is optional. It is a percentage change to the amplitude of the
238 WAV file. So, `WAV(ufric/s, 50)` means: play file 'ufric/s.wav' at 50% amplitude.
239 Default value is 100.
240
241 ### FMT
242
243 FMT(<vowel file>, <amplitude>)
244
245 \<vowel file\> is a path to a file (within `phsource/`) which defines how to
246 generate the sound (a vowel or voiced consonant) from a sequence of formant
247 values. Vowel files are made using the `espeakedit` program which is not part
248 of this project.
249
250 \<amplitude\> is optional. It is a percentage change to the amplitude of the
251 sound which is synthesized from the `FMT()` instruction. Default value is 100.
252
253 FMT(<vowel file>, <amplitude>) addWav(<wav file>, <amplitude>)
254
255 For voiced consonants, a `FMT()` instruction may be followed by an `addWav()`
256 instruction. `addWav()` has the same format as a `WAV()` instruction, but the
257 WAV file is mixed with the sound which is synthesized from the `FMT()` instruction.
258
259 ### VowelStart
260
261 VowelStart(<vowel file>, <length adjust>)
262
263 This is used to modify the start of a vowel when it follows after a sonorant consonant
264 (such as `[l]` or `[j]`). It replaces the first frame of the \<vowel file\> which
265 is specified in a `FMT()` instruction by this \<vowel file\>, and adjusts the
266 length of the original by a signed value \<length adjust\>. The `VowelStart()`
267 instruction may be specified either in the phoneme definition of the vowel, or
268 in the phoneme definition of the sonorant consonant which precedes the vowel.
269 The former takes precedence.
270
271 ### VowelEnding
272
273 VowelEnding(<vowel file>, <length adjust>)
274
275 This is used to modify the end of a vowel when it is followed by a sonorant
276 consonant (such as `[l]` or `[j]`). It is appended to the \<vowel file\> which
277 is specified in a `FMT()` instruction by this \<vowel file\>, and adjusts the
278 length of the original by a signed value \<length adjust\>. The `VowelEnding()`
279 instruction may be specified either in the phoneme definition of the vowel, or
280 in the phoneme definition of the sonorant consonant which follows the vowel.
281 The former takes precedence.
282
283 ### Vowelin
284
285 Vowelin <vowel transition data>
286
287 (C) Specifies the effects of this consonant on the formants of a following
288 vowel. See [vowel transitions](#vowel-transitions).
289
290 ### Vowelout
291
292 Vowelout <vowel transition data>
293
294 (C) Specifies the effects of this consonant on the formants of a preceding
295 vowel. See [vowel transitions](#vowel-transitions).
296
297 ### ChangePhoneme
298
299 ChangePhoneme(<phoneme>)
300
301 Change to the specified phoneme.
302
303 ### ChangeIfDiminished
304
305 ChangeIfDiminished(<phoneme>)
306
307 Change to the specified phoneme (such as schwa, `@`) if this syllable has
308 "diminished" stress.
309
310 ### ChangeIfUnstressed
311
312 ChangeIfUnstressed(<phoneme>)
313
314 Change to the specified phoneme if this syllable has "diminished" or
315 "unstressed" stress.
316
317 ### ChangeIfNotStressed
318
319 ChangeIfNotStressed(<phoneme>)
320
321 Change to the specified phoneme if this syllable does not have "primary" stress.
322
323 ### ChangeIfStressed
324
325 ChangeIfStressed(<phoneme>)
326
327 Change to the specified phoneme if this syllable has "primary" stress.
328
329 ### IfNextVowelAppend
330
331 IfNextVowelAppend(<phoneme>)
332
333 If the following phoneme is a vowel then this additional phoneme will be
334 inserted before it. Usually it is short pause to distinguish two vowels from
335 diphthongs.
336
337 ### RETURN
338
339 Ends executions of instructions.
340
341 ### CALL
342
343 CALL <phoneme table>/<phoneme>
344
345 Executes the instructions of the specified phoneme.
346
347 ## Conditional Statements
348
349 Phoneme definitions can contain conditional statements such as:
350
351 IF <condition> THEN
352 <statements>
353 ENDIF
354
355 or more generally:
356
357 IF <condition> THEN
358 <statements>
359 ELIF <condition> THEN
360 <statements>
361 ...
362 ELSE
363 <statements>
364 ENDIF
365
366 where the `ELSE` and multiple `ELSE` parts are optional.
367
368 Multiple conditions may be joined with `AND` or `OR`, but not a mixture of
369 `AND`s and `OR`s.
370
371 A condition may be preceded by `NOT`. For example:
372
373 IF <condition> AND NOT <condition> THEN
374 <statements>
375 ENDIF
376
377 ### Conditions
378
379 Conditions can be:
380
381 thisPh(<attribute>)
382
383 Test this current phoneme
384
385 prevPh(<attribute>)
386
387 Test the previous phoneme
388
389 prevPhW(<attribute>)
390
391 Test the previous phoneme, but only within the same word. Returns false if
392 there is no previous phoneme in the word.
393
394 prev2PhW(<attribute>)
395
396 Test the phoneme before the previous phoneme, but only within the same word.
397 Returns false if it is not in this word.
398
399 nextPh(<attribute>)
400
401 Test the following phoneme
402
403 next2Ph(<attribute>)
404
405 Test the phoneme after the next phoneme.
406
407 nextPhW(<attribute>)
408
409 Test the next phoneme, but only within the same word. Returns false if there
410 is no following phoneme in the word.
411
412 next2PhW(<attribute>)
413
414 Test the phoneme after the next phoneme, but only within the same word. Returns
415 false if not found before the word end.
416
417 next3PhW(<attribute>)
418
419 Test the third phoneme after the current phoneme, but only within the same word.
420 Returns false if not found before the word end.
421
422 nextVowel(<attribute>)
423
424 Test the next vowel after the current phoneme, but only within the same word.
425 Returns false if there is none.
426
427 prevVowel(<attribute>)
428
429 Test the previous vowel before the current phoneme, but only within the same
430 word. Returns false if there is none.
431
432 PreVoicing()
433
434 This is used as part of the instructions for voiced stop consonants (e.g. `[d]`
435 and `[g]`). If true then produce a voiced murmur before the stop.
436
437 KlattSynth()
438
439 Returns true if the voice is using the Klatt synthesizer rather than the eSpeak synthesizer.
440
441 ### Attributes
442
443 <phoneme name>
444
445 True if the phoneme has this phoneme name.
446
447 <phoneme group>
448
449 True if the phoneme has this `starttype` (or if it has this `endtype` if it is
450 used in `prevPh()`). The pre-defined phoneme groups are `#@`, `#a`, `#e`, `#i`,
451 `#o`, `#u`.
452
453 isPause
454
455 True if the phoneme is a pause.
456
457 isPause2
458
459 `nextPh(isPause2)` is used to test whether the next phoneme is not a vowel or
460 liquid consonant within the same word.
461
462 isVowel
463 isNotVowel
464 isLiquid
465 isNasal
466 isVFricative
467
468 These test the phoneme type.
469
470 isPalatal
471 isRhotic
472
473 These test whether the phoneme has this property.
474
475 isWordStart
476 notWordStart
477
478 These text whether this is the first phoneme in a word.
479
480 isWordEnd
481
482 True if this is the final phoneme in a word.
483
484 isFirstVowel
485 isSecondVowel
486 isFinalVowel
487
488 True if this is the First, Second, or Last vowel in a word.
489
490 isAfterStress
491
492 True if this phoneme is after the stressed vowel in a word.
493
494 isVoiced
495
496 True if this phoneme is a vowel or a voiced consonant.
497
498 isDiminished
499
500 True if the syllable stress is "diminished"
501
502 isUnstressed
503
504 True if the syllable stress is "diminished" or "unstressed"
505
506 isNotStressed
507
508 True if the syllable stress is not "primary stress".
509
510 isStressed
511
512 True if the syllable stress is "primary stress".
513
514 isMaxStress
515
516 True if this is the highest stressed syllable in the word.
517
518 ## Sound Specifications
519
520 There are three ways to produce sounds:
521
522 * Playing a WAV file, by using a `WAV()` instruction. This is used for unvoiced
523 consonants such as `[p]`, `[t]` and `[s]`.
524 * Generating a wave from a sequence of formant parameters, by using a `FMT()`
525 instruction. This is used for vowels and also for sonorants such as `[l]`,
526 `[j]` and `[n]`.
527 * A mixture of these. A stored `WAV` file is mixed with a wave generated from
528 formant parameters. Use a `FMT()` instruction followed by `addWav()`. This is
529 used for voiced stops and fricatives such as `[b]`, `[g]`, `[v]` and `[z]`.
530
531 ## Vowel Transitions
532
533 These specify how a consonant affects an adjacent vowel. A consonant may
534 cause a transition in the vowel's formants as the mouth changes shape
535 between the consonant and the vowel. The following attributes may be
536 specified. Note that the maximum rate of change of formant frequencies
537 is limited by the program.
538
539 len=<integer>
540
541 Nominal length of the transition in milliseconds. If omitted a default value is used.
542
543 rms=<integer>
544
545 Adjusts the amplitude of the vowel at the end of the transition. If omitted
546 a default value is used.
547
548 f1=<integer>
549
550 0: f1 formant frequency unchanged.
551
552 1: f1 formant frequency decreases.
553
554 2: f1 formant frequency decreases more.
555
556 f2=<freq> <min> <max>
557
558 \<freq\>: The frequency towards which the f2 formant moves (Hz).
559
560 \<min\>: Signed integer (Hz). The minimum f2 frequency change.
561
562 \<max\>: Signed integer (Hz). The maximum f2 frequency change.
563
564 f3=<change> <amplitude>
565
566 \<change\>: Signed integer (Hz). Frequency change of f3, f4, and f5 formants.
567
568 \<amplitude\>: Amplitude of the f3, f4, and f5 formants at the end of the
569 transition. 100 = no change.
570
571 brk
572
573 Break. Do not merge the synthesized wave of the consonant into the vowel. This
574 will produce a discontinuity in the formants.
575
576 rate
577
578 Allow a greater maximum rate of change of formant frequencies.
579
580 glstop
581
582 Indicates a glottal stop.
583
584
585 ## Customization of sound source files
586
587 * You need [Espeakedit](http://espeak.sourceforge.net/editor.html) to change sound parameters of vowel definition files.
588
589 On Debian/Ubuntu based systems you can install it with command:
590
591 ```
592 sudo apt-get install espeakedit
593 ```
594
595 If your 64-bit Linux system doesn't have this package, you can download just compiled binary file from
596 [here](https://github.com/valdisvi/espeak-ng-espeakedit/blob/master/bin/espeakedit?raw=true).
597
598 To edit *.wav files for sonorant/consonant phonemes you may also need:
599
600 * [Audacity](https://www.audacityteam.org/) can be used as sound editor for consonant sounds (*.wav) files.
601 Audacity may be also used to analyse [sound spectrum](https://manual.audacityteam.org/man/spectrogram_view.html)
602 (use maximum window size to see harmonics clearly).
603
604 On Debian/Ubuntu based systems you can install it with command:
605
606 ```
607 sudo apt-get install audacity
608 ```
609
610 * [Praat](http://www.fon.hum.uva.nl/praat/) can be used to do more detailed analysis of recorded voice files.
611
612 On Debian/Ubuntu based systems you can install it with command:
613
614 ```
615 sudo apt-get install praat
616 ```
617
618 `Praat` can also provide initial settings for vowel definitions to `espeakedit`.
619