当前位置: 首页>>代码示例>>Python>>正文


Python Style.TONE3属性代码示例

本文整理汇总了Python中pypinyin.Style.TONE3属性的典型用法代码示例。如果您正苦于以下问题:Python Style.TONE3属性的具体用法?Python Style.TONE3怎么用?Python Style.TONE3使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pypinyin.Style的用法示例。


在下文中一共展示了Style.TONE3属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_lab

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def _add_lab(txtlines, wav_dir_path):
    logger = logging.getLogger('mtts')
    for line in txtlines:
        numstr, txt = line.split(' ')
        txt = re.sub('#\d', '', txt)
        pinyin_list = pinyin(txt, style=Style.TONE3)
        new_pinyin_list = []
        for item in pinyin_list:
            if not item:
                logger.warning(
                    '{file_num} do not generate right pinyin'.format(numstr))
            if not item[0][-1].isdigit():
                phone = item[0] + '5'
            else:
                phone = item[0]
            new_pinyin_list.append(phone)
        lab_file = os.path.join(wav_dir_path, numstr + '.lab')
        with open(lab_file, 'w') as oid:
            oid.write(' '.join(new_pinyin_list)) 
开发者ID:Jackiexiao,项目名称:MTTS,代码行数:21,代码来源:mtts.py

示例2: _add_pinyin

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def _add_pinyin(txtlines, output_path):
    ''' txt2pinyin in one file '''
    logger = logging.getLogger('mtts')
    all_pinyin = []
    for line in txtlines:
        numstr, txt = line.split(' ')
        txt = re.sub('#\d', '', txt)
        pinyin_list = pinyin(txt, style=Style.TONE3)
        new_pinyin_list = []
        for item in pinyin_list:
            if not item:
                logger.warning(
                    '{file_num} do not generate right pinyin'.format(numstr))
            if not item[0][-1].isdigit():
                phone = item[0] + '5'
            else:
                #phone = item[0]
                phone = item[0].replace('v', 'u')
            new_pinyin_list.append(phone)
        all_pinyin.append(numstr + ' ' + ' '.join(new_pinyin_list))
    all_pinyin_file = os.path.join(output_path, 'all_pinyin.lab')
    with open(all_pinyin_file, 'w') as oid:
        for item in all_pinyin:
            oid.write(item + '\n') 
开发者ID:Jackiexiao,项目名称:MTTS,代码行数:26,代码来源:mtts.py

示例3: pypinyin_g2p_phone

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def pypinyin_g2p_phone(text) -> List[str]:
    from pypinyin import pinyin
    from pypinyin import Style
    from pypinyin.style._utils import get_finals
    from pypinyin.style._utils import get_initials

    phones = [
        p
        for phone in pinyin(text, style=Style.TONE3)
        for p in [
            get_initials(phone[0], strict=True),
            get_finals(phone[0], strict=True),
        ]
        if len(p) != 0
    ]
    return phones 
开发者ID:espnet,项目名称:espnet,代码行数:18,代码来源:phoneme_tokenizer.py

示例4: __convert_transcript

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def __convert_transcript(raw_transcript):
    """
    Converts a Chinese transcript to a Chinese pinyin sequence.
    """
    waveid, raw_trans = raw_transcript.split("\t")[:2]
    wavename = waveid + ".wav"
    symbols = ",.!?"
    # For simplicity, we only retain the Chinese chars and symbols
    trans = ''.join([_char for _char in __replace_symbols(raw_trans) if __is_chinese(_char) or _char in symbols])
    pinyin_trans = []
    for pinyin in lazy_pinyin(trans, style=Style.TONE3):
        if pinyin not in symbols and not pinyin[-1].isdigit():
            pinyin_trans.append(pinyin + "0")
        else:
            pinyin_trans.append(pinyin)
    return wavename, " ".join(pinyin_trans) 
开发者ID:NVIDIA,项目名称:NeMo,代码行数:18,代码来源:get_databaker_data.py

示例5: txt2pinyin

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def txt2pinyin(txt):
    phone_list = []
    '''
    if isinstance(txt, str):
        pinyin_list = pinyin(unicode(txt,'utf-8'), style = Style.TONE3)
    elif isinstance(txt, unicode):
        pinyin_list = pinyin(txt, style = Style.TONE3)
    else:
        print('error: unsupport coding form')
    '''

    pinyin_list = pinyin(txt, style = Style.TONE3)
    for item in pinyin_list:
        phone_list.append(seprate_syllable(pinyinformat(item[0])))
    return phone_list 
开发者ID:Jackiexiao,项目名称:MTTS,代码行数:17,代码来源:txt2pinyin.py

示例6: chs_pinyin

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def chs_pinyin(text):
	pys = pinyin(text, style=Style.TONE3)
	results = []
	sentence = []
	for i in range(len(pys)):
		if pys[i][0][0] == "," or pys[i][0][0] == "、" or pys[i][0][0] == '·':
			pys[i][0] = ','
		elif pys[i][0][0] == '。' or pys[i][0][0] == "…":
			pys[i][0] = '.'
		elif pys[i][0][0] == '―' or pys[i][0][0] == "――" or pys[i][0][0] == '—' or pys[i][0][0] == '——':
			pys[i][0] = ','
		elif pys[i][0][0] == ";":
			pys[i][0] = ';'
		elif pys[i][0][0] == ":":
			pys[i][0] = ':'
		elif pys[i][0][0] == "?":
			pys[i][0] = '?'
		elif pys[i][0][0] == "!":
			pys[i][0] = '!'
		elif pys[i][0][0] == "《" or pys[i][0][0] == '》' or pys[i][0][0] == '(' or pys[i][0][0] == ')':
			continue
		elif pys[i][0][0] == '“' or pys[i][0][0] == '”' or pys[i][0][0] == '‘' or pys[i][0][0] == '’' or pys[i][0][0] == '"':
			continue
		elif pys[i][0][0] == '(' or pys[i][0][0] == ')' or pys[i][0][0] == '"' or pys[i][0][0] == '\'':
			continue
		elif pys[i][0][0] == ' ' or pys[i][0][0] == '/' or pys[i][0][0] == '<' or pys[i][0][0] == '>' or pys[i][0][0] == '「' or pys[i][0][0] == '」':
			continue

		sentence.append(pys[i][0])
		if pys[i][0] in ",.;?!:":
			results.append(' '.join(sentence))
			sentence = []

	if len(sentence) > 0:
		results.append(' '.join(sentence))

	for i, res in enumerate(results):
		print(res)

	return results 
开发者ID:Joee1995,项目名称:tacotron2-mandarin-griffin-lim,代码行数:42,代码来源:demo_server.py

示例7: pypinyin_g2p

# 需要导入模块: from pypinyin import Style [as 别名]
# 或者: from pypinyin.Style import TONE3 [as 别名]
def pypinyin_g2p(text) -> List[str]:
    from pypinyin import pinyin
    from pypinyin import Style

    phones = [phone[0] for phone in pinyin(text, style=Style.TONE3)]
    return phones 
开发者ID:espnet,项目名称:espnet,代码行数:8,代码来源:phoneme_tokenizer.py


注:本文中的pypinyin.Style.TONE3属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。