Skip to content

Commit

Permalink
【Fix Speech Issue No.8】issue 3652 merge_yi function has a bug (#3786)
Browse files Browse the repository at this point in the history
* 【Fix Speech Issue No.8】issue 3652 merge_yi function has a bug

* 【Fix Speech Issue No.8】issue 3652 merge_yi function has a bug
  • Loading branch information
mattheliu authored Jun 5, 2024
1 parent 03022f2 commit 09e5d8a
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions paddlespeech/t2s/frontend/tone_sandhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,25 @@ def _merge_bu(self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
# output seg: [['听一听', 'v']]
def _merge_yi(self, seg: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
new_seg = []
skip_next = False
# function 1
for i, (word, pos) in enumerate(seg):
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":
if i - 1 < len(new_seg):
new_seg[i -
1][0] = new_seg[i - 1][0] + "一" + new_seg[i - 1][0]
else:
new_seg.append([word, pos])
new_seg.append([seg[i + 1][0], pos])
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])
skip_next = True
else:
if i - 2 >= 0 and seg[i - 1][0] == "一" and seg[i - 2][
0] == word and pos == "v":
continue
else:
new_seg.append([word, pos])
new_seg.append((word, pos))
seg = new_seg
new_seg = []
# function 2
for i, (word, pos) in enumerate(seg):
if new_seg and new_seg[-1][0] == "一":
new_seg[-1][0] = new_seg[-1][0] + word
new_seg[-1] = (new_seg[-1][0] + word, new_seg[-1][1])
else:
new_seg.append([word, pos])
new_seg.append((word, pos))
return new_seg

# the first and the second words are all_tone_three
Expand Down

0 comments on commit 09e5d8a

Please sign in to comment.