Skip to content

Commit

Permalink
Revise TTS, SpeechT5Model to end the last audio chunk at the correct …
Browse files Browse the repository at this point in the history
…punctuation mark location (#513)

* Revise SpeechT5Model to end the last audio chunk at the correct punctuation mark

Signed-off-by: Chun Tao <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* still append the last chunk if it contains no punctuation

Signed-off-by: Chun Tao <[email protected]>

---------

Signed-off-by: Chun Tao <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ctao456 and pre-commit-ci[bot] authored Aug 19, 2024
1 parent cd83854 commit 20fc8ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion comps/tts/speecht5/speecht5_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ def split_long_text_into_batch(self, text, batch_length=128):
cur_end = idx
idx += 1
# deal with the last sequence
res.append(text[cur_start:idx])
if cur_start < len(text):
last_chunk = text[cur_start:]
last_punc_idx = max([last_chunk.rfind(punc) for punc in hitted_ends[:-1]]) # exclude " "
if last_punc_idx != -1:
last_chunk = last_chunk[: last_punc_idx + 1]
res.append(last_chunk[: last_punc_idx + 1])
else:
res.append(last_chunk)
res = [i + "." for i in res] # avoid unexpected end of sequence
return res

Expand Down

0 comments on commit 20fc8ca

Please sign in to comment.