Skip to content

Commit

Permalink
fix: make chinese g2p deps optional
Browse files Browse the repository at this point in the history
  • Loading branch information
eginhard committed May 8, 2024
1 parent 73cfeb5 commit aad6c98
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ The following extras allow the installation of optional dependencies:
| `server` | Dependencies to run the TTS server |
| `bn` | Bangla G2P |
| `ja` | Japanese G2P |
| `zh` | Chinese G2P |
| `languages` | All language-specific dependencies |

You can install them with one of the following commands:
You can install extras with one of the following commands:

```bash
pip install coqui-tts[server,ja]
Expand Down
5 changes: 4 additions & 1 deletion TTS/tts/layers/xtts/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import textwrap
from functools import cached_property

import pypinyin
import torch
from hangul_romanize import Transliter
from hangul_romanize.rule import academic
Expand Down Expand Up @@ -577,6 +576,10 @@ def basic_cleaners(text):


def chinese_transliterate(text):
try:
import pypinyin
except ImportError as e:
raise ImportError("Chinese requires: pypinyin") from e
return "".join(
[p[0] for p in pypinyin.pinyin(text, style=pypinyin.Style.TONE3, heteronym=False, neutral_tone_with_five=True)]
)
Expand Down
7 changes: 5 additions & 2 deletions TTS/tts/utils/text/chinese_mandarin/phonemizer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import List

import jieba
import pypinyin
try:
import jieba
import pypinyin
except ImportError as e:
raise ImportError("Chinese requires: jieba, pypinyin") from e

from .pinyinToPhonemes import PINYIN_DICT

Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ dependencies = [
# Coqui stack
"coqui-tts-trainer>=0.1",
"coqpit>=0.0.16",
# Chinese
"jieba",
"pypinyin",
# Korean
"hangul_romanize",
"jamo",
Expand Down Expand Up @@ -123,6 +120,11 @@ ja = [
"unidic-lite==1.0.8",
"cutlet",
]
# Chinese
zh = [
"jieba",
"pypinyin",
]
# All language-specific dependencies
languages = [
"coqui-tts[bn,ja]",
Expand Down

0 comments on commit aad6c98

Please sign in to comment.