Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update multinet_g2p.py (AIS-1569) #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions tool/multinet_g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ def english_g2p(text, alphabet=None):
alphabet={"AE1": "a", "N": "N", " ": " ", "OW1": "b", "V": "V", "AH0": "c", "L": "L", "F": "F", "EY1": "d", "S": "S", "B": "B", "R": "R", "AO1": "e", "D": "D", "AH1": "c", "EH1": "f", "OW0": "b", "IH0": "g", "G": "G", "HH": "h", "K": "K", "IH1": "g", "W": "W", "AY1": "i", "T": "T", "M": "M", "Z": "Z", "DH": "j", "ER0": "k", "P": "P", "NG": "l", "IY1": "m", "AA1": "n", "Y": "Y", "UW1": "o", "IY0": "m", "EH2": "f", "CH": "p", "AE0": "a", "JH": "q", "ZH": "r", "AA2": "n", "SH": "s", "AW1": "t", "OY1": "u", "AW2": "t", "IH2": "g", "AE2": "a", "EY2": "d", "ER1": "k", "TH": "v", "UH1": "w", "UW2": "o", "OW2": "b", "AY2": "i", "UW0": "o", "AH2": "c", "EH0": "f", "AW0": "t", "AO2": "e", "AO0": "e", "UH0": "w", "UH2": "w", "AA0": "n", "AY0": "i", "IY2": "m", "EY0": "d", "ER2": "k", "OY2": "u", "OY0": "u"}

text_list = text.split(";")
count = 1
for item in text_list:
item_out = "" # Danh sách tạm thời cho kết quả của mỗi item
item = item.split(",")
for phrase in item:
labels = g2p(phrase)
word_out = ""
for char in labels:
if char not in alphabet:
print("skip %s, not found in alphabet")
print("skip %s, not found in alphabet" % char)
continue
else:
out += alphabet[char]
word_out += alphabet[char]
item_out += word_out
if phrase != item[-1]:
out += ','
out += ";"
item_out += ','
out += f"{count},{phrase},{item_out}\n"
count += 1

print("in:", text)
print("out:", out)

return out
print(out)

if __name__ == "__main__":

Expand Down