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

【Hackathon 8th No.7】Python版本适配 5 #3972

Merged
merged 8 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
31 changes: 21 additions & 10 deletions paddlespeech/t2s/frontend/tone_sandhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ def _merge_yi(self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
if skip_next:
skip_next = False
continue
if i - 1 >= 0 and word == "一" and i + 1 < len(seg) and seg[i - 1][0] == seg[i + 1][0] and seg[i - 1][1] == "v":
new_seg[-1] = (new_seg[-1][0] + "一" + seg[i + 1][0], new_seg[-1][1])
if i - 1 >= 0 and word == "一" and i + 1 < len(seg) and seg[i - 1][
0] == seg[i + 1][0] and seg[i - 1][1] == "v":
new_seg[-1] = (new_seg[-1][0] + "一" + seg[i + 1][0],
new_seg[-1][1])
skip_next = True
else:
new_seg.append((word, pos))
Expand All @@ -262,11 +264,16 @@ def _merge_yi(self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
def _merge_continuous_three_tones(
self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
new_seg = []
sub_finals_list = [
lazy_pinyin(
sub_finals_list = []
for (word, pos) in seg:
orig_finals = lazy_pinyin(
word, neutral_tone_with_five=True, style=Style.FINALS_TONE3)
for (word, pos) in seg
]
# after pypinyin==0.44.0, '嗯' need to be n2, cause the initial and final consonants cannot be empty at the same time
en_index = [index for index, c in enumerate(word) if c == "嗯"]
for i in en_index:
orig_finals[i] = "n2"
sub_finals_list.append(orig_finals)

assert len(sub_finals_list) == len(seg)
merge_last = [False] * len(seg)
for i, (word, pos) in enumerate(seg):
Expand All @@ -292,11 +299,15 @@ def _is_reduplication(self, word: str) -> bool:
def _merge_continuous_three_tones_2(
self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
new_seg = []
sub_finals_list = [
lazy_pinyin(
sub_finals_list = []
for (word, pos) in seg:
orig_finals = lazy_pinyin(
word, neutral_tone_with_five=True, style=Style.FINALS_TONE3)
for (word, pos) in seg
]
# after pypinyin==0.41.0, 嗯 will be processed as "", so we need to change it to "n2"
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
en_index = [index for index, c in enumerate(word) if c == "嗯"]
for i in en_index:
orig_finals[i] = "n2"
sub_finals_list.append(orig_finals)
assert len(sub_finals_list) == len(seg)
merge_last = [False] * len(seg)
for i, (word, pos) in enumerate(seg):
Expand Down
5 changes: 5 additions & 0 deletions paddlespeech/t2s/frontend/zh_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def _get_initials_finals(self, word: str) -> List[List[str]]:
word, neutral_tone_with_five=True, style=Style.INITIALS)
orig_finals = lazy_pinyin(
word, neutral_tone_with_five=True, style=Style.FINALS_TONE3)
# after pypinyin==0.41.0, 嗯 will be processed as "", so we need to change it to "n2"
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
en_index = [index for index, c in enumerate(word) if c == "嗯"]
for i in en_index:
orig_finals[i] = "n2"

for c, v in zip(orig_initials, orig_finals):
if re.match(r'i\d', v):
if c in ['z', 'c', 's']:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def determine_matplotlib_version():
"praatio>=6.0.0",
"prettytable",
"pydantic",
"pypinyin<=0.44.0",
"pypinyin",
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
"pypinyin-dict",
"python-dateutil",
"pyworld>=0.2.12",
Expand Down