rename
This commit is contained in:
30
melo/text/fr_phonemizer/fr_to_ipa.py
Normal file
30
melo/text/fr_phonemizer/fr_to_ipa.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from .cleaner import french_cleaners
|
||||
from .gruut_wrapper import Gruut
|
||||
|
||||
|
||||
def remove_consecutive_t(input_str):
|
||||
result = []
|
||||
count = 0
|
||||
|
||||
for char in input_str:
|
||||
if char == 't':
|
||||
count += 1
|
||||
else:
|
||||
if count < 3:
|
||||
result.extend(['t'] * count)
|
||||
count = 0
|
||||
result.append(char)
|
||||
|
||||
if count < 3:
|
||||
result.extend(['t'] * count)
|
||||
|
||||
return ''.join(result)
|
||||
|
||||
def fr2ipa(text):
|
||||
e = Gruut(language="fr-fr", keep_puncs=True, keep_stress=True, use_espeak_phonemes=True)
|
||||
# text = french_cleaners(text)
|
||||
phonemes = e.phonemize(text, separator="")
|
||||
# print(phonemes)
|
||||
phonemes = remove_consecutive_t(phonemes)
|
||||
# print(phonemes)
|
||||
return phonemes
|
||||
Reference in New Issue
Block a user