本文整理汇总了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