File size: 30,141 Bytes
739b228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
"""
IPA Data Module — Shared phoneme data for all IPA Hugging Face Spaces.

Contains:
- Full IPA consonant inventory with articulatory features
- Full IPA vowel inventory with height/backness/rounding
- Spanish phoneme annotations and example words
- Chart layout constants (place/manner ordering, vowel trapezoid coordinates)
"""

# =============================================================================
# CONSONANT CHART DATA
# =============================================================================

# Column order for the consonant chart (place of articulation)
CONSONANT_PLACES = [
    "bilabial",
    "labiodental",
    "dental",
    "alveolar",
    "postalveolar",
    "retroflex",
    "palatal",
    "velar",
    "uvular",
    "pharyngeal",
    "glottal",
]

# Row order for the consonant chart (manner of articulation)
CONSONANT_MANNERS = [
    "plosive",
    "nasal",
    "trill",
    "tap/flap",
    "fricative",
    "lateral fricative",
    "approximant",
    "lateral approximant",
]

# Full IPA consonant data
# Each entry: symbol -> {place, manner, voicing, name, spanish, spanish_example, espeak_code, languages}
CONSONANTS = {
    # === PLOSIVES ===
    "p": {
        "place": "bilabial", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless bilabial plosive",
        "spanish": True, "spanish_example": "padre",
        "espeak_code": "p",
        "languages": ["English", "Spanish", "French", "German", "Mandarin"],
    },
    "b": {
        "place": "bilabial", "manner": "plosive", "voicing": "voiced",
        "name": "voiced bilabial plosive",
        "spanish": True, "spanish_example": "boca",
        "espeak_code": "b",
        "languages": ["English", "Spanish", "French", "Arabic"],
    },
    "t": {
        "place": "alveolar", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless alveolar plosive",
        "spanish": True, "spanish_example": "taza",
        "espeak_code": "t",
        "languages": ["English", "Spanish", "French", "German"],
    },
    "d": {
        "place": "alveolar", "manner": "plosive", "voicing": "voiced",
        "name": "voiced alveolar plosive",
        "spanish": True, "spanish_example": "dedo",
        "espeak_code": "d",
        "languages": ["English", "Spanish", "French", "Italian"],
    },
    "t\u0288": {  # ʈ
        "place": "retroflex", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless retroflex plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": "t.",
        "languages": ["Hindi", "Swedish", "Norwegian"],
    },
    "\u0256": {  # ɖ
        "place": "retroflex", "manner": "plosive", "voicing": "voiced",
        "name": "voiced retroflex plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": "d.",
        "languages": ["Hindi", "Tamil", "Swedish"],
    },
    "c": {
        "place": "palatal", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless palatal plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": "c",
        "languages": ["Hungarian", "Turkish", "Greek"],
    },
    "\u025f": {  # ɟ
        "place": "palatal", "manner": "plosive", "voicing": "voiced",
        "name": "voiced palatal plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": "J",
        "languages": ["Hungarian", "Turkish", "Latvian"],
    },
    "k": {
        "place": "velar", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless velar plosive",
        "spanish": True, "spanish_example": "casa",
        "espeak_code": "k",
        "languages": ["English", "Spanish", "French", "German", "Mandarin"],
    },
    "\u0261": {  # ɡ
        "place": "velar", "manner": "plosive", "voicing": "voiced",
        "name": "voiced velar plosive",
        "spanish": True, "spanish_example": "gato",
        "espeak_code": "g",
        "languages": ["English", "Spanish", "French", "German"],
    },
    "q": {
        "place": "uvular", "manner": "plosive", "voicing": "voiceless",
        "name": "voiceless uvular plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": "q",
        "languages": ["Arabic", "Quechua", "Inuktitut"],
    },
    "\u0262": {  # ɢ
        "place": "uvular", "manner": "plosive", "voicing": "voiced",
        "name": "voiced uvular plosive",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Somali", "Inuktitut"],
    },
    "\u0294": {  # ʔ
        "place": "glottal", "manner": "plosive", "voicing": "voiceless",
        "name": "glottal stop",
        "spanish": False, "spanish_example": None,
        "espeak_code": "?",
        "languages": ["English (uh-oh)", "Arabic", "Hawaiian", "German"],
    },

    # === NASALS ===
    "m": {
        "place": "bilabial", "manner": "nasal", "voicing": "voiced",
        "name": "voiced bilabial nasal",
        "spanish": True, "spanish_example": "madre",
        "espeak_code": "m",
        "languages": ["English", "Spanish", "French", "German", "Mandarin"],
    },
    "\u0271": {  # ɱ
        "place": "labiodental", "manner": "nasal", "voicing": "voiced",
        "name": "voiced labiodental nasal",
        "spanish": False, "spanish_example": None,
        "espeak_code": "M",
        "languages": ["English (comfort)", "Italian", "Dutch"],
    },
    "n": {
        "place": "alveolar", "manner": "nasal", "voicing": "voiced",
        "name": "voiced alveolar nasal",
        "spanish": True, "spanish_example": "noche",
        "espeak_code": "n",
        "languages": ["English", "Spanish", "French", "German", "Mandarin"],
    },
    "\u0273": {  # ɳ
        "place": "retroflex", "manner": "nasal", "voicing": "voiced",
        "name": "voiced retroflex nasal",
        "spanish": False, "spanish_example": None,
        "espeak_code": "n.",
        "languages": ["Hindi", "Swedish", "Norwegian"],
    },
    "\u0272": {  # ɲ
        "place": "palatal", "manner": "nasal", "voicing": "voiced",
        "name": "voiced palatal nasal",
        "spanish": True, "spanish_example": "niño (ñ)",
        "espeak_code": "n^",
        "languages": ["Spanish", "French (cognac)", "Italian", "Portuguese"],
    },
    "\u014b": {  # ŋ
        "place": "velar", "manner": "nasal", "voicing": "voiced",
        "name": "voiced velar nasal",
        "spanish": True, "spanish_example": "tengo (before g/k)",
        "espeak_code": "N",
        "languages": ["English (sing)", "Spanish", "German", "Mandarin"],
    },
    "\u0274": {  # ɴ
        "place": "uvular", "manner": "nasal", "voicing": "voiced",
        "name": "voiced uvular nasal",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Japanese", "Inuktitut"],
    },

    # === TRILLS ===
    "\u0299": {  # ʙ
        "place": "bilabial", "manner": "trill", "voicing": "voiced",
        "name": "voiced bilabial trill",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Nias", "Titan"],
    },
    "r": {
        "place": "alveolar", "manner": "trill", "voicing": "voiced",
        "name": "voiced alveolar trill",
        "spanish": True, "spanish_example": "perro",
        "espeak_code": "r",
        "languages": ["Spanish", "Italian", "Russian", "Arabic"],
    },
    "\u0280": {  # ʀ
        "place": "uvular", "manner": "trill", "voicing": "voiced",
        "name": "voiced uvular trill",
        "spanish": False, "spanish_example": None,
        "espeak_code": "R",
        "languages": ["French", "German", "Dutch"],
    },

    # === TAPS / FLAPS ===
    "\u2c71": {  # ⱱ
        "place": "labiodental", "manner": "tap/flap", "voicing": "voiced",
        "name": "voiced labiodental flap",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Mono", "some Central African languages"],
    },
    "\u027e": {  # ɾ
        "place": "alveolar", "manner": "tap/flap", "voicing": "voiced",
        "name": "voiced alveolar tap",
        "spanish": True, "spanish_example": "pero",
        "espeak_code": "*",
        "languages": ["Spanish", "Japanese", "Korean", "Portuguese"],
    },
    "\u027d": {  # ɽ
        "place": "retroflex", "manner": "tap/flap", "voicing": "voiced",
        "name": "voiced retroflex flap",
        "spanish": False, "spanish_example": None,
        "espeak_code": "*.",
        "languages": ["Hindi", "Urdu", "Hausa"],
    },

    # === FRICATIVES ===
    "\u0278": {  # ɸ
        "place": "bilabial", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless bilabial fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "F",
        "languages": ["Japanese (fu)", "Ewe"],
    },
    "\u03b2": {  # β
        "place": "bilabial", "manner": "fricative", "voicing": "voiced",
        "name": "voiced bilabial fricative",
        "spanish": True, "spanish_example": "lobo (allophone of /b/)",
        "espeak_code": "B",
        "languages": ["Spanish (allophone)", "Ewe", "Japanese"],
    },
    "f": {
        "place": "labiodental", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless labiodental fricative",
        "spanish": True, "spanish_example": "fuego",
        "espeak_code": "f",
        "languages": ["English", "Spanish", "French", "German"],
    },
    "v": {
        "place": "labiodental", "manner": "fricative", "voicing": "voiced",
        "name": "voiced labiodental fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "v",
        "languages": ["English", "French", "German", "Russian"],
    },
    "\u03b8": {  # θ
        "place": "dental", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless dental fricative",
        "spanish": True, "spanish_example": "zapato (Castilian)",
        "espeak_code": "T",
        "languages": ["English (think)", "Spanish (Castilian)", "Greek"],
    },
    "\u00f0": {  # ð
        "place": "dental", "manner": "fricative", "voicing": "voiced",
        "name": "voiced dental fricative",
        "spanish": True, "spanish_example": "dedo (allophone of /d/)",
        "espeak_code": "D",
        "languages": ["English (the)", "Spanish (allophone)", "Icelandic"],
    },
    "s": {
        "place": "alveolar", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless alveolar fricative",
        "spanish": True, "spanish_example": "sol",
        "espeak_code": "s",
        "languages": ["English", "Spanish", "French", "German", "Mandarin"],
    },
    "z": {
        "place": "alveolar", "manner": "fricative", "voicing": "voiced",
        "name": "voiced alveolar fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "z",
        "languages": ["English", "French", "Italian", "Russian"],
    },
    "\u0283": {  # ʃ
        "place": "postalveolar", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless postalveolar fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "S",
        "languages": ["English (ship)", "French (chat)", "German (schön)"],
    },
    "\u0292": {  # ʒ
        "place": "postalveolar", "manner": "fricative", "voicing": "voiced",
        "name": "voiced postalveolar fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "Z",
        "languages": ["English (measure)", "French (je)", "Portuguese"],
    },
    "\u0282": {  # ʂ
        "place": "retroflex", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless retroflex fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "s.",
        "languages": ["Mandarin (sh)", "Polish", "Sanskrit"],
    },
    "\u0290": {  # ʐ
        "place": "retroflex", "manner": "fricative", "voicing": "voiced",
        "name": "voiced retroflex fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "z.",
        "languages": ["Mandarin (r-)", "Polish", "Russian"],
    },
    "\u00e7": {  # ç
        "place": "palatal", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless palatal fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "C",
        "languages": ["German (ich)", "Greek", "Japanese (hi)"],
    },
    "\u029d": {  # ʝ
        "place": "palatal", "manner": "fricative", "voicing": "voiced",
        "name": "voiced palatal fricative",
        "spanish": True, "spanish_example": "mayo (some dialects)",
        "espeak_code": "j",
        "languages": ["Spanish (some dialects)", "Greek", "Irish"],
    },
    "x": {
        "place": "velar", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless velar fricative",
        "spanish": True, "spanish_example": "jota",
        "espeak_code": "x",
        "languages": ["Spanish", "German (Bach)", "Russian", "Arabic"],
    },
    "\u0263": {  # ɣ
        "place": "velar", "manner": "fricative", "voicing": "voiced",
        "name": "voiced velar fricative",
        "spanish": True, "spanish_example": "lago (allophone of /g/)",
        "espeak_code": "Q",
        "languages": ["Spanish (allophone)", "Greek", "Irish"],
    },
    "\u03c7": {  # χ
        "place": "uvular", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless uvular fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "X",
        "languages": ["German (some dialects)", "Hebrew", "Welsh"],
    },
    "\u0281": {  # ʁ
        "place": "uvular", "manner": "fricative", "voicing": "voiced",
        "name": "voiced uvular fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "g\"",
        "languages": ["French (r)", "German (r)", "Dutch"],
    },
    "\u0127": {  # ħ
        "place": "pharyngeal", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless pharyngeal fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "H",
        "languages": ["Arabic (ح)", "Hebrew", "Somali"],
    },
    "\u0295": {  # ʕ
        "place": "pharyngeal", "manner": "fricative", "voicing": "voiced",
        "name": "voiced pharyngeal fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "Q\"",
        "languages": ["Arabic (ع)", "Hebrew", "Somali"],
    },
    "h": {
        "place": "glottal", "manner": "fricative", "voicing": "voiceless",
        "name": "voiceless glottal fricative",
        "spanish": True, "spanish_example": "huevo (some dialects)",
        "espeak_code": "h",
        "languages": ["English", "German", "Japanese", "Arabic"],
    },
    "\u0266": {  # ɦ
        "place": "glottal", "manner": "fricative", "voicing": "voiced",
        "name": "voiced glottal fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "h\\",
        "languages": ["Dutch", "Czech", "Ukrainian"],
    },

    # === LATERAL FRICATIVES ===
    "\u026c": {  # ɬ
        "place": "alveolar", "manner": "lateral fricative", "voicing": "voiceless",
        "name": "voiceless alveolar lateral fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": "l#",
        "languages": ["Welsh (ll)", "Zulu", "Navajo"],
    },
    "\u026e": {  # ɮ
        "place": "alveolar", "manner": "lateral fricative", "voicing": "voiced",
        "name": "voiced alveolar lateral fricative",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Mongolian", "Zulu"],
    },

    # === APPROXIMANTS ===
    "\u028b": {  # ʋ
        "place": "labiodental", "manner": "approximant", "voicing": "voiced",
        "name": "voiced labiodental approximant",
        "spanish": False, "spanish_example": None,
        "espeak_code": "v#",
        "languages": ["Dutch", "Finnish", "Hindi"],
    },
    "\u0279": {  # ɹ
        "place": "alveolar", "manner": "approximant", "voicing": "voiced",
        "name": "voiced alveolar approximant",
        "spanish": False, "spanish_example": None,
        "espeak_code": "r\\",
        "languages": ["English (red)", "some Dutch dialects"],
    },
    "\u027b": {  # ɻ
        "place": "retroflex", "manner": "approximant", "voicing": "voiced",
        "name": "voiced retroflex approximant",
        "spanish": False, "spanish_example": None,
        "espeak_code": "r\\.",
        "languages": ["Tamil", "American English (r)"],
    },
    "j": {
        "place": "palatal", "manner": "approximant", "voicing": "voiced",
        "name": "voiced palatal approximant",
        "spanish": True, "spanish_example": "yo (some dialects)",
        "espeak_code": "j\\",
        "languages": ["English (yes)", "Spanish", "French", "German"],
    },
    "w": {
        "place": "velar", "manner": "approximant", "voicing": "voiced",
        "name": "voiced labial-velar approximant",
        "spanish": True, "spanish_example": "huevo",
        "espeak_code": "w",
        "languages": ["English", "Spanish", "French", "Mandarin"],
    },

    # === LATERAL APPROXIMANTS ===
    "l": {
        "place": "alveolar", "manner": "lateral approximant", "voicing": "voiced",
        "name": "voiced alveolar lateral approximant",
        "spanish": True, "spanish_example": "luna",
        "espeak_code": "l",
        "languages": ["English", "Spanish", "French", "German"],
    },
    "\u026d": {  # ɭ
        "place": "retroflex", "manner": "lateral approximant", "voicing": "voiced",
        "name": "voiced retroflex lateral approximant",
        "spanish": False, "spanish_example": None,
        "espeak_code": "l.",
        "languages": ["Tamil", "Hindi", "Norwegian"],
    },
    "\u028e": {  # ʎ
        "place": "palatal", "manner": "lateral approximant", "voicing": "voiced",
        "name": "voiced palatal lateral approximant",
        "spanish": True, "spanish_example": "calle (traditional)",
        "espeak_code": "l^",
        "languages": ["Spanish (traditional)", "Italian", "Portuguese", "Catalan"],
    },
    "\u029f": {  # ʟ
        "place": "velar", "manner": "lateral approximant", "voicing": "voiced",
        "name": "voiced velar lateral approximant",
        "spanish": False, "spanish_example": None,
        "espeak_code": "L",
        "languages": ["Mid-Waghi", "some PNG languages"],
    },
}


# =============================================================================
# VOWEL CHART DATA
# =============================================================================

# Vowel height levels (top to bottom)
VOWEL_HEIGHTS = ["close", "near-close", "close-mid", "mid", "open-mid", "near-open", "open"]

# Vowel backness levels (left to right)
VOWEL_BACKNESSES = ["front", "central", "back"]

# Full IPA vowel data
VOWELS = {
    # === CLOSE VOWELS ===
    "i": {
        "height": "close", "backness": "front", "rounding": "unrounded",
        "name": "close front unrounded vowel",
        "spanish": True, "spanish_example": "sí",
        "espeak_code": "i",
        "languages": ["English (see)", "Spanish", "French", "German"],
    },
    "y": {
        "height": "close", "backness": "front", "rounding": "rounded",
        "name": "close front rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "y",
        "languages": ["French (tu)", "German (über)", "Finnish", "Mandarin (ü)"],
    },
    "\u0268": {  # ɨ
        "height": "close", "backness": "central", "rounding": "unrounded",
        "name": "close central unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "i\"",
        "languages": ["Russian (ы)", "Polish", "Romanian"],
    },
    "\u0289": {  # ʉ
        "height": "close", "backness": "central", "rounding": "rounded",
        "name": "close central rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "u\"",
        "languages": ["Swedish", "Norwegian", "some English dialects"],
    },
    "\u026f": {  # ɯ
        "height": "close", "backness": "back", "rounding": "unrounded",
        "name": "close back unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "u-",
        "languages": ["Turkish", "Japanese", "Korean"],
    },
    "u": {
        "height": "close", "backness": "back", "rounding": "rounded",
        "name": "close back rounded vowel",
        "spanish": True, "spanish_example": "tú",
        "espeak_code": "u",
        "languages": ["English (boot)", "Spanish", "French", "German"],
    },

    # === NEAR-CLOSE VOWELS ===
    "\u026a": {  # ɪ
        "height": "near-close", "backness": "front", "rounding": "unrounded",
        "name": "near-close front unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "I",
        "languages": ["English (bit)", "German"],
    },
    "\u028f": {  # ʏ
        "height": "near-close", "backness": "front", "rounding": "rounded",
        "name": "near-close front rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "Y",
        "languages": ["German (hübsch)", "Swedish"],
    },
    "\u028a": {  # ʊ
        "height": "near-close", "backness": "back", "rounding": "rounded",
        "name": "near-close back rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "U",
        "languages": ["English (book)", "German"],
    },

    # === CLOSE-MID VOWELS ===
    "e": {
        "height": "close-mid", "backness": "front", "rounding": "unrounded",
        "name": "close-mid front unrounded vowel",
        "spanish": True, "spanish_example": "mesa",
        "espeak_code": "e",
        "languages": ["Spanish", "French (été)", "German (Beet)", "Italian"],
    },
    "\u00f8": {  # ø
        "height": "close-mid", "backness": "front", "rounding": "rounded",
        "name": "close-mid front rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "Y\"",
        "languages": ["French (peu)", "German (schön)", "Danish", "Finnish"],
    },
    "\u0258": {  # ɘ
        "height": "close-mid", "backness": "central", "rounding": "unrounded",
        "name": "close-mid central unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Korean", "Paicî"],
    },
    "\u0275": {  # ɵ
        "height": "close-mid", "backness": "central", "rounding": "rounded",
        "name": "close-mid central rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Swedish", "Australian English"],
    },
    "\u0264": {  # ɤ
        "height": "close-mid", "backness": "back", "rounding": "unrounded",
        "name": "close-mid back unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "o-",
        "languages": ["Korean", "Vietnamese", "Thai"],
    },
    "o": {
        "height": "close-mid", "backness": "back", "rounding": "rounded",
        "name": "close-mid back rounded vowel",
        "spanish": True, "spanish_example": "como",
        "espeak_code": "o",
        "languages": ["Spanish", "French (beau)", "German (Boot)", "Italian"],
    },

    # === MID VOWEL ===
    "\u0259": {  # ə (schwa)
        "height": "mid", "backness": "central", "rounding": "unrounded",
        "name": "mid central vowel (schwa)",
        "spanish": False, "spanish_example": None,
        "espeak_code": "@",
        "languages": ["English (about)", "French (le)", "German (bitte)"],
    },

    # === OPEN-MID VOWELS ===
    "\u025b": {  # ɛ
        "height": "open-mid", "backness": "front", "rounding": "unrounded",
        "name": "open-mid front unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "E",
        "languages": ["English (bed)", "French (fête)", "Italian"],
    },
    "\u0153": {  # œ
        "height": "open-mid", "backness": "front", "rounding": "rounded",
        "name": "open-mid front rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "W",
        "languages": ["French (peur)", "German (Hölle)"],
    },
    "\u025c": {  # ɜ
        "height": "open-mid", "backness": "central", "rounding": "unrounded",
        "name": "open-mid central unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "3",
        "languages": ["English (bird - British)"],
    },
    "\u025e": {  # ɞ
        "height": "open-mid", "backness": "central", "rounding": "rounded",
        "name": "open-mid central rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Irish", "some English dialects"],
    },
    "\u028c": {  # ʌ
        "height": "open-mid", "backness": "back", "rounding": "unrounded",
        "name": "open-mid back unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "V",
        "languages": ["English (but)", "Korean"],
    },
    "\u0254": {  # ɔ
        "height": "open-mid", "backness": "back", "rounding": "rounded",
        "name": "open-mid back rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "O",
        "languages": ["English (thought)", "French (mort)", "Italian"],
    },

    # === NEAR-OPEN VOWELS ===
    "\u00e6": {  # æ
        "height": "near-open", "backness": "front", "rounding": "unrounded",
        "name": "near-open front unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "a#",
        "languages": ["English (cat)", "Danish", "Arabic"],
    },
    "\u0250": {  # ɐ
        "height": "near-open", "backness": "central", "rounding": "unrounded",
        "name": "near-open central vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "a\"",
        "languages": ["German (bitter)", "Portuguese", "some English dialects"],
    },

    # === OPEN VOWELS ===
    "a": {
        "height": "open", "backness": "front", "rounding": "unrounded",
        "name": "open front unrounded vowel",
        "spanish": True, "spanish_example": "casa",
        "espeak_code": "a",
        "languages": ["Spanish", "French (patte)", "Italian", "German"],
    },
    "\u0276": {  # ɶ
        "height": "open", "backness": "front", "rounding": "rounded",
        "name": "open front rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": None,
        "languages": ["Danish", "some German dialects"],
    },
    "\u0251": {  # ɑ
        "height": "open", "backness": "back", "rounding": "unrounded",
        "name": "open back unrounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "A",
        "languages": ["English (father)", "French (pâte)", "Persian"],
    },
    "\u0252": {  # ɒ
        "height": "open", "backness": "back", "rounding": "rounded",
        "name": "open back rounded vowel",
        "spanish": False, "spanish_example": None,
        "espeak_code": "A.",
        "languages": ["British English (lot)", "Hungarian"],
    },
}


# =============================================================================
# VOWEL TRAPEZOID COORDINATES (for SVG rendering)
# =============================================================================

# SVG viewBox: 0 0 500 400
# The trapezoid is narrower at top (close) and wider at bottom (open)
# x increases left-to-right (front → back), y increases top-to-bottom (close → open)
VOWEL_TRAPEZOID_COORDS = {
    # (x, y) positions on the trapezoid SVG
    # Close row
    ("close", "front"): (80, 40),
    ("close", "central"): (250, 40),
    ("close", "back"): (420, 40),
    # Near-close row
    ("near-close", "front"): (110, 95),
    ("near-close", "back"): (400, 95),
    # Close-mid row
    ("close-mid", "front"): (130, 145),
    ("close-mid", "central"): (255, 145),
    ("close-mid", "back"): (380, 145),
    # Mid row
    ("mid", "central"): (260, 200),
    # Open-mid row
    ("open-mid", "front"): (170, 250),
    ("open-mid", "central"): (265, 250),
    ("open-mid", "back"): (360, 250),
    # Near-open row
    ("near-open", "front"): (195, 305),
    ("near-open", "central"): (270, 305),
    # Open row
    ("open", "front"): (215, 355),
    ("open", "back"): (340, 355),
}


# =============================================================================
# HELPER FUNCTIONS
# =============================================================================

def get_consonant_at(place, manner, voicing):
    """Get the IPA symbol for a consonant at a specific position in the chart."""
    for symbol, data in CONSONANTS.items():
        if data["place"] == place and data["manner"] == manner and data["voicing"] == voicing:
            return symbol
    return None


def get_vowel_at(height, backness, rounding):
    """Get the IPA symbol for a vowel at a specific position in the chart."""
    for symbol, data in VOWELS.items():
        if data["height"] == height and data["backness"] == backness and data["rounding"] == rounding:
            return symbol
    return None


def get_spanish_consonants():
    """Return all consonants that appear in Spanish."""
    return {sym: data for sym, data in CONSONANTS.items() if data["spanish"]}


def get_spanish_vowels():
    """Return all vowels that appear in Spanish."""
    return {sym: data for sym, data in VOWELS.items() if data["spanish"]}


def get_all_spanish_phonemes():
    """Return all Spanish phonemes (consonants + vowels)."""
    return {**get_spanish_consonants(), **get_spanish_vowels()}


def get_phoneme_info(symbol):
    """Look up any IPA symbol and return its full data."""
    if symbol in CONSONANTS:
        return {"type": "consonant", **CONSONANTS[symbol]}
    if symbol in VOWELS:
        return {"type": "vowel", **VOWELS[symbol]}
    return None