本文整理匯總了Python中text.cleaners方法的典型用法代碼示例。如果您正苦於以下問題:Python text.cleaners方法的具體用法?Python text.cleaners怎麽用?Python text.cleaners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類text
的用法示例。
在下文中一共展示了text.cleaners方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sequence_to_text
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def sequence_to_text(sequence, skip_eos_and_pad=False, combine_jamo=False):
'''Converts a sequence of IDs back to a string'''
cleaner_names=[x.strip() for x in hparams.cleaners.split(',')]
if 'english_cleaners' in cleaner_names and isEn==False:
convert_to_en_symbols()
result = ''
for symbol_id in sequence:
if symbol_id in _id_to_symbol:
s = _id_to_symbol[symbol_id]
# Enclose ARPAbet back in curly braces:
if len(s) > 1 and s[0] == '@':
s = '{%s}' % s[1:]
if not skip_eos_and_pad or s not in [EOS, PAD]:
result += s
result = result.replace('}{', ' ')
if combine_jamo:
return jamo_to_korean(result)
else:
return result
示例2: _clean_text
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def _clean_text(text, cleaner_names):
for name in cleaner_names:
cleaner = getattr(cleaners, name)
if not cleaner:
raise Exception('Unknown cleaner: %s' % name)
text = cleaner(text)
return text
示例3: _clean_text
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def _clean_text(text, cleaner_names):
for name in cleaner_names:
cleaner = getattr(cleaners, name)
if not cleaner:
raise Exception('Unknown cleaner: %s' % name)
text = cleaner(text) # '존경하는' --> ['ᄌ', 'ᅩ', 'ᆫ', 'ᄀ', 'ᅧ', 'ᆼ', 'ᄒ', 'ᅡ', 'ᄂ', 'ᅳ', 'ᆫ', '~']
return text
示例4: text_to_sequence
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def text_to_sequence(text, as_token=False):
cleaner_names = [x.strip() for x in hparams.cleaners.split(',')]
if ('english_cleaners' in cleaner_names) and isEn==False:
convert_to_en_symbols()
return _text_to_sequence(text, cleaner_names, as_token)
示例5: _clean_text
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def _clean_text(text, cleaner_names):
for name in cleaner_names:
cleaner = getattr(cleaners, name)
if not cleaner:
raise Exception('Unknown cleaner: %s' % name)
text = cleaner(text) # '존경하는' --> ['ᄌ', 'ᅩ', 'ᆫ', 'ᄀ', 'ᅧ', 'ᆼ', 'ᄒ', 'ᅡ', 'ᄂ', 'ᅳ', 'ᆫ', '~']
return text
示例6: _clean_text
# 需要導入模塊: import text [as 別名]
# 或者: from text import cleaners [as 別名]
def _clean_text(text, cleaner_names):
for name in cleaner_names:
cleaner = getattr(cleaners, name)
if not cleaner:
raise Exception('Unknown cleaner: %s' % name)
text = cleaner(text)
return text