Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_finals_tone3_no_final():
assert convert('ń', Style.FINALS_TONE3, True, None) == 'n2'
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')