mirror of https://github.com/coqui-ai/TTS.git
Make lint
This commit is contained in:
parent
a44a0e1fd2
commit
1a6a5710fd
|
@ -1,5 +1,4 @@
|
||||||
import re
|
import re
|
||||||
from typing import List
|
|
||||||
|
|
||||||
import bangla
|
import bangla
|
||||||
from bnnumerizer import numerize
|
from bnnumerizer import numerize
|
||||||
|
@ -59,15 +58,15 @@ def tag_text(text: str):
|
||||||
|
|
||||||
|
|
||||||
def normalize(sen):
|
def normalize(sen):
|
||||||
global bnorm
|
global bnorm # pylint: disable=global-statement
|
||||||
_words = [bnorm(word)["normalized"] for word in sen.split()]
|
_words = [bnorm(word)["normalized"] for word in sen.split()]
|
||||||
return " ".join([word for word in _words if word is not None])
|
return " ".join([word for word in _words if word is not None])
|
||||||
|
|
||||||
|
|
||||||
def expand_full_attribution(text):
|
def expand_full_attribution(text):
|
||||||
for word in attribution_dict:
|
for word, attr in attribution_dict.items():
|
||||||
if word in text:
|
if word in text:
|
||||||
text = text.replace(word, normalize(attribution_dict[word]))
|
text = text.replace(word, normalize(attr))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ def collapse_whitespace(text):
|
||||||
return re.sub(_whitespace_re, " ", text)
|
return re.sub(_whitespace_re, " ", text)
|
||||||
|
|
||||||
|
|
||||||
def bangla_text_to_phonemes(text: str, seperator: str = "|") -> str:
|
def bangla_text_to_phonemes(text: str) -> str:
|
||||||
# english numbers to bangla conversion
|
# english numbers to bangla conversion
|
||||||
res = re.search("[0-9]", text)
|
res = re.search("[0-9]", text)
|
||||||
if res is not None:
|
if res is not None:
|
||||||
|
@ -110,8 +109,8 @@ def bangla_text_to_phonemes(text: str, seperator: str = "|") -> str:
|
||||||
sentences = sentenceEnders.split(str(bn_text))
|
sentences = sentenceEnders.split(str(bn_text))
|
||||||
|
|
||||||
data = ""
|
data = ""
|
||||||
for i in range(len(sentences)):
|
for sent in sentences:
|
||||||
res = re.sub("\n", "", sentences[i])
|
res = re.sub("\n", "", sent)
|
||||||
res = normalize(res)
|
res = normalize(res)
|
||||||
# expand attributes
|
# expand attributes
|
||||||
res = expand_full_attribution(res)
|
res = expand_full_attribution(res)
|
||||||
|
|
|
@ -33,8 +33,8 @@ class BN_Phonemizer(BasePhonemizer):
|
||||||
return "bn_phonemizer"
|
return "bn_phonemizer"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def phonemize_bn(text: str, separator: str = "|") -> str:
|
def phonemize_bn(text: str, separator: str = "|") -> str: # pylint: disable=unused-argument
|
||||||
ph = bangla_text_to_phonemes(text, separator)
|
ph = bangla_text_to_phonemes(text)
|
||||||
return ph
|
return ph
|
||||||
|
|
||||||
def _phonemize(self, text, separator):
|
def _phonemize(self, text, separator):
|
||||||
|
@ -52,11 +52,11 @@ class BN_Phonemizer(BasePhonemizer):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
text = "রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়া সাল্লাম শিক্ষা দিয়েছেন যে, কেউ যদি কোন খারাপ কিছুর সম্মুখীন হয়, তখনও যেন বলে."
|
txt = "রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়া সাল্লাম শিক্ষা দিয়েছেন যে, কেউ যদি কোন খারাপ কিছুর সম্মুখীন হয়, তখনও যেন বলে."
|
||||||
e = BN_Phonemizer()
|
e = BN_Phonemizer()
|
||||||
print(e.supported_languages())
|
print(e.supported_languages())
|
||||||
print(e.version())
|
print(e.version())
|
||||||
print(e.language)
|
print(e.language)
|
||||||
print(e.name())
|
print(e.name())
|
||||||
print(e.is_available())
|
print(e.is_available())
|
||||||
print("`" + e.phonemize(text) + "`")
|
print("`" + e.phonemize(txt) + "`")
|
||||||
|
|
Loading…
Reference in New Issue