Skip to content

Commit

Permalink
feat: expose the tokenize option to api/v1/g2p
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise authored and roedoejet committed May 2, 2023
1 parent 07e87d6 commit 3f572c4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion g2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ def __init__(self):
required=False,
help="Debugging information about the transduction process",
)
self.parser.add_argument(
"tokenize",
dest="tokenize",
type=inputs.boolean,
location="args",
default=False,
required=False,
help="Tokenize before transducing",
)

def get(self):
args = self.parser.parse_args()
Expand All @@ -118,8 +127,9 @@ def get(self):
text = args["text"]
index = args["index"]
debugger = args["debugger"]
tokenize = args["tokenize"]
try:
transducer = make_g2p(in_lang, out_lang, tokenize=False)
transducer = make_g2p(in_lang, out_lang, tokenize=tokenize)
tg = transducer(text)
text = tg.output_string
input_text = tg.input_string
Expand Down

0 comments on commit 3f572c4

Please sign in to comment.