Japanese and Mandarin Chinese (#20)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
__version__ = '0.3.0'
|
__version__ = '0.3.1'
|
||||||
|
|
||||||
from .model import KModel
|
from .model import KModel
|
||||||
from .pipeline import KPipeline
|
from .pipeline import KPipeline
|
||||||
|
|||||||
@@ -7,13 +7,22 @@ import re
|
|||||||
import torch
|
import torch
|
||||||
|
|
||||||
LANG_CODES = dict(
|
LANG_CODES = dict(
|
||||||
|
# pip install misaki[en]
|
||||||
a='American English',
|
a='American English',
|
||||||
b='British English',
|
b='British English',
|
||||||
|
|
||||||
|
# espeak-ng
|
||||||
e='es',
|
e='es',
|
||||||
f='fr-fr',
|
f='fr-fr',
|
||||||
h='hi',
|
h='hi',
|
||||||
i='it',
|
i='it',
|
||||||
p='pt-br',
|
p='pt-br',
|
||||||
|
|
||||||
|
# pip install misaki[ja]
|
||||||
|
j='Japanese',
|
||||||
|
|
||||||
|
# pip install misaki[zh]
|
||||||
|
z='Mandarin Chinese',
|
||||||
)
|
)
|
||||||
|
|
||||||
class KPipeline:
|
class KPipeline:
|
||||||
@@ -55,6 +64,20 @@ class KPipeline:
|
|||||||
print('⚠️ WARNING: EspeakFallback not enabled. OOD words will be skipped.', e)
|
print('⚠️ WARNING: EspeakFallback not enabled. OOD words will be skipped.', e)
|
||||||
fallback = None
|
fallback = None
|
||||||
self.g2p = en.G2P(trf=trf, british=lang_code=='b', fallback=fallback)
|
self.g2p = en.G2P(trf=trf, british=lang_code=='b', fallback=fallback)
|
||||||
|
elif lang_code == 'j':
|
||||||
|
try:
|
||||||
|
from misaki import ja
|
||||||
|
self.g2p = ja.JAG2P()
|
||||||
|
except ImportError:
|
||||||
|
print("❌ ERROR: You need to `pip install misaki[ja]` to use lang_code='j'")
|
||||||
|
raise
|
||||||
|
elif lang_code == 'z':
|
||||||
|
try:
|
||||||
|
from misaki import zh
|
||||||
|
self.g2p = zh.ZHG2P()
|
||||||
|
except ImportError:
|
||||||
|
print("❌ ERROR: You need to `pip install misaki[zh]` to use lang_code='z'")
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
language = LANG_CODES[lang_code]
|
language = LANG_CODES[lang_code]
|
||||||
print(f"⚠️ WARNING: Using EspeakG2P(language='{language}'). Chunking logic not yet implemented, so long texts may be truncated unless you split them with '\\n'.")
|
print(f"⚠️ WARNING: Using EspeakG2P(language='{language}'). Chunking logic not yet implemented, so long texts may be truncated unless you split them with '\\n'.")
|
||||||
@@ -147,6 +170,7 @@ class KPipeline:
|
|||||||
if isinstance(text, str):
|
if isinstance(text, str):
|
||||||
text = re.split(split_pattern, text.strip()) if split_pattern else [text]
|
text = re.split(split_pattern, text.strip()) if split_pattern else [text]
|
||||||
for graphemes in text:
|
for graphemes in text:
|
||||||
|
# TODO(misaki): Unify G2P interface between English and non-English
|
||||||
if self.lang_code in 'ab':
|
if self.lang_code in 'ab':
|
||||||
_, tokens = self.g2p(graphemes)
|
_, tokens = self.g2p(graphemes)
|
||||||
for gs, ps in self.en_tokenize(tokens):
|
for gs, ps in self.en_tokenize(tokens):
|
||||||
|
|||||||
18
setup.py
18
setup.py
@@ -1,10 +1,10 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='kokoro', # Name of the package
|
name='kokoro',
|
||||||
version='0.3.0', # Initial version
|
version='0.3.1',
|
||||||
packages=find_packages(), # Automatically finds packages
|
packages=find_packages(),
|
||||||
install_requires=[ # List your dependencies here
|
install_requires=[
|
||||||
'huggingface_hub',
|
'huggingface_hub',
|
||||||
'misaki[en]>=0.6.1',
|
'misaki[en]>=0.6.1',
|
||||||
'numpy==1.26.4',
|
'numpy==1.26.4',
|
||||||
@@ -12,15 +12,15 @@ setup(
|
|||||||
'torch',
|
'torch',
|
||||||
'transformers',
|
'transformers',
|
||||||
],
|
],
|
||||||
python_requires='>=3.6', # Minimum Python version required
|
python_requires='>=3.6',
|
||||||
author='hexgrad',
|
author='hexgrad',
|
||||||
author_email='hello@hexgrad.com',
|
author_email='hello@hexgrad.com',
|
||||||
description='TTS',
|
description='TTS',
|
||||||
long_description=open('README.md').read(), # Content from your README
|
long_description=open('README.md').read(),
|
||||||
long_description_content_type='text/markdown', # Required for markdown
|
long_description_content_type='text/markdown',
|
||||||
url='https://github.com/hexgrad/kokoro', # GitHub repo URL
|
url='https://github.com/hexgrad/kokoro',
|
||||||
license='Apache 2.0',
|
license='Apache 2.0',
|
||||||
classifiers=[ # This helps users discover your package
|
classifiers=[
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
'License :: OSI Approved :: Apache Software License',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
|
|||||||
Reference in New Issue
Block a user