最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Ai生成語音怎么調(diào)速(paddleSpeech)

2023-07-24 16:36 作者:ddzjzyxn  | 我要投稿

依賴源碼finetuneTTS.py 的功能,搜索這個項目就能找到這個文件,把這些文件拷到本地使用,以下是核心的兩步

1.生成音素

2.生成語音

生成音素.py

import os
from Text2Speech.util.finetuneTTS import load_fs2_model, fs2_inference, get_tts_phone_ids, \
    get_idx2ph_dict, list_to_durations, \
    duration_phones_to_list_fix_speed
import paddle
import json


def generate_yinsu(text, gen_exp_name, outPath, speed=1):
    ff = open(text, "r", encoding="utf-8")
    sentences = ff.read()
    ff.close()
    text_list = sentences.split("\n")

    model = load_fs2_model(gen_exp_name)


    num = 0
    for i in text_list:
        phone_ids = get_tts_phone_ids(i, gen_exp_name, exp_fun=True)
        duration = fs2_inference(model, text=phone_ids[0], spk_id=paddle.to_tensor(0), alpha=1.0, duration=None,
                                 return_duration=True)
        idx2ph_dict = get_idx2ph_dict(gen_exp_name)
        phs_lists = duration_phones_to_list_fix_speed(duration, phone_ids, idx2ph_dict,speed)
        phs_lists_json = outPath + "/phs_list.json" + f'{num}'
        if os.path.exists(phs_lists_json):
            os.remove(phs_lists_json)
        with open(phs_lists_json, "w", encoding="utf8") as f:
            json.dump(phs_lists, f, indent=3)
        num += 1
    print("------------完成因素生成--------------")

def read_yinsu(outPath,index):
    phs_lists_json = outPath + "/phs_list.json" + f'{index}'
    if os.path.exists(phs_lists_json):
        with open(phs_lists_json, "r", encoding="utf8") as f:
            phs_lists = json.load(f)
    new_duration = list_to_durations(phs_lists)
    print(new_duration)
    return new_duration

if __name__ == '__main__':
    rootPath = "D:/Text2Speech/"
    # 模型路徑
    am_inference_dir = rootPath + "model/" + "guanbo2"
    # 聲碼器路徑
    voc_inference_dir = rootPath + "soundCoder/" + "pwgan_aishell3_static_1.1.0"
    # 合成音頻輸出路徑
    wav_output_dir = rootPath + "output"
    # 加速設(shè)備cpu gpu,amd pytorch-dml仍然很多不兼容,使用cpu就好
    device = "cpu"
    # 想要生成語音的文本文檔對應文件名
    txt_name = rootPath + "speechtxt.txt"

    # 生成音素可以對特定詞語 語句進行微調(diào),應該先生成這個數(shù)據(jù),后面使用這個數(shù)據(jù),有什么不對的可以進行調(diào)整
    generate_yinsu(txt_name, am_inference_dir, wav_output_dir,-1.4)

Ai生成語音怎么調(diào)速(paddleSpeech)的評論 (共 條)

分享到微博請遵守國家法律
荥经县| 德保县| 辽宁省| 黑山县| 洞头县| 响水县| 包头市| 南通市| 山西省| 都兰县| 永平县| 柳江县| 三门县| 泽州县| 临夏县| 东方市| 台州市| 中超| 铜梁县| 民县| 楚雄市| 宜昌市| 巴林左旗| 昭通市| 金乡县| 定兴县| 昂仁县| 淮南市| 兰坪| 漯河市| 汝阳县| 同仁县| 奉新县| 比如县| 明水县| 绥宁县| 莫力| 定安县| 中方县| 个旧市| 凭祥市|