-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipa.py
60 lines (55 loc) · 951 Bytes
/
ipa.py
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
import logging
PHONEMES="""arpabet ipa class
aa ɑ vowel
ae æ vowel
ah ə vowel
ao ɔ vowel
aw aʊ vowel
ay aɪ vowel
b b plosive
ch tʃ affricate
d d plosive
dh ð fricative
eh ɛ vowel
er ɚ vowel
ey e vowel
f f fricative
g g plosive
hh h fricative
ih ɪ vowel
iy i vowel
jh dʒ affricate
k k plosive
l l approximant
m m nasal
n n nasal
ng ŋ nasal
ow o vowel
oy ɔɪ vowel
p p plosive
r ɹ approximant
s s fricative
sh ʃ fricative
t t plosive
th θ fricative
uh ʊ vowel
uw u vowel
v v fricative
w w approximant
y j approximant
z z fricative
zh ʒ fricative"""
def parseipa():
mapping = {}
lines = PHONEMES.split("\n")
for line in lines[1:]:
arpa, ipa, _ = line.split()
mapping[arpa] = ipa
return mapping
_arpa2ipa = parseipa()
def arpa2ipa(arpa, default=None):
try:
return _arpa2ipa[arpa]
except KeyError:
logging.warning("Key not found: {}".format(arpa))
return default