-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_word.py
41 lines (35 loc) · 1.06 KB
/
test_word.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
#!/usr/bin/env python
# -*- encoding:utf-8 -*-
from __future__ import unicode_literals
from argparse import ArgumentParser
from g2p.g2p import G2PTranscriber
if __name__ == "__main__":
# Initialize ArgumentParser class
parser = ArgumentParser()
# Parse command line arguments
parser.add_argument(
"-s",
"--separator",
dest="separator",
required=True,
type=str,
choices=["silva", "ceci"],
help="Select the separator/syllabification algorithm",
)
parser.add_argument("-w", "--word", dest="word", required=True, help="Word")
args = parser.parse_args()
# Get the input word
try:
word = args.word.decode("utf-8").lower()
except:
word = args.word.lower()
# Initialize G2P transcriber
g2p = G2PTranscriber(word, algorithm=args.separator)
print(
"\n{0} -> [{1}] | {2} | {3}\n".format(
word,
g2p.transcriber(),
g2p.get_syllables_with_hyphen(),
g2p.get_syllables_with_stress_boundaries(),
)
)