PlayVoice/vits_chinese

浅浅 这个单词发音永远都是 渐渐 请问如何修改?

gdtiti opened this issue · 1 comments

gdtiti commented
浅浅 这个单词发音永远都是 渐渐 请问如何修改?

这是pypinyin的问题,pypinyin可以设置用户词典,设置特定词汇的发音:

from pypinyin.core import Pinyin, load_phrases_dict

def load_pinyin_dict():
    my_dict={}
    with open("./pypinyin-local.dict", "r", encoding='utf-8') as f:
        content = f.readlines()
        for line in content:
            cuts = line.strip().split()
            hanzi = cuts[0]
            pinyin = cuts[1:]
            tmp = []
            for one in pinyin:
                onelist = [one]
                tmp.append(onelist)
            my_dict[hanzi] = tmp
    load_phrases_dict(my_dict)

pypinyin-local.dict内容为

渐渐 jian4 jian4
浅浅 qian3 qian3

然后在创建Pinyin之前加载

load_pinyin_dict()
pinyin_parser = Pinyin(MyConverter())