Files
OpenVoice/openvoice/text/cleaners.py
Felipe Moreira Ferreira 41aaecdceb refactor!: Converts Project into a Python Compatible Package
- Moves all core functionality files to the package "openvoice";
- Adjusts all inner package references to the new format;
- Adds "setup.py" file following the specification present on "https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools";

BREAKING CHANGE: All the core functionality files were moved to the "openvoice" package
2024-02-14 00:45:40 -03:00

16 lines
846 B
Python

import re
from openvoice.text.english import english_to_lazy_ipa, english_to_ipa2, english_to_lazy_ipa2
from openvoice.text.mandarin import number_to_chinese, chinese_to_bopomofo, latin_to_bopomofo, chinese_to_romaji, chinese_to_lazy_ipa, chinese_to_ipa, chinese_to_ipa2
def cjke_cleaners2(text):
text = re.sub(r'\[ZH\](.*?)\[ZH\]',
lambda x: chinese_to_ipa(x.group(1))+' ', text)
text = re.sub(r'\[JA\](.*?)\[JA\]',
lambda x: japanese_to_ipa2(x.group(1))+' ', text)
text = re.sub(r'\[KO\](.*?)\[KO\]',
lambda x: korean_to_ipa(x.group(1))+' ', text)
text = re.sub(r'\[EN\](.*?)\[EN\]',
lambda x: english_to_ipa2(x.group(1))+' ', text)
text = re.sub(r'\s+$', '', text)
text = re.sub(r'([^\.,!\?\-…~])$', r'\1.', text)
return text