Skip to content

Commit

Permalink
Add new text segmentation library for better TTS quality
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDong committed Oct 5, 2023
1 parent 399daf3 commit 47b4ab5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nemo/collections/tts/g2p/models/zh_cn_pinyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(
assert word_segmenter in [
None,
'jieba',
'pkuseg',
], f"{word_segmenter} is not supported now. Please choose correct word_segmenter."

if phoneme_prefix is None:
Expand Down Expand Up @@ -118,6 +119,13 @@ def __init__(

# Cut sentences into words to improve polyphone disambiguation
self.word_segmenter = jieba.cut
elif word_segmenter == "pkuseg":
try:
import pkuseg
except ImportError as e:
logging.error(e)

self.word_segmenter = pkuseg.pkuseg().cut
else:
self.word_segmenter = lambda x: [x]

Expand Down
1 change: 1 addition & 0 deletions requirements/requirements_tts.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
attrdict
einops
jieba
pkuseg
kornia
librosa
matplotlib
Expand Down

0 comments on commit 47b4ab5

Please sign in to comment.