首页 > 编程语言 >python训练阿里云语音合成模型

python训练阿里云语音合成模型

时间:2023-11-03 17:34:31浏览次数:83  
标签:hifigan 语音 python 24k sambert -- 阿里 file path

训练阿里云多人训练语音合成模型

需要下载pytorch及其他kantts算法依赖

转换采样率

import os
from pydub import AudioSegment

input_folder = "/path/aida/wav_24k"
output_folder = "/path/aida/new_wav_24k"

if not os.path.exists(output_folder):
    os.makedirs(output_folder)

for file in os.listdir(input_folder):
    if file.endswith(".wav"):
        input_file = os.path.join(input_folder, file)
        output_file = os.path.join(output_folder, file)

        audio = AudioSegment.from_file(input_file, format="wav")
        audio = audio.set_frame_rate(24000)
        audio.export(output_file, format="wav")

print("转换完成!")

# 检验采样率
import wave

def get_sample_rate(file_path):
    with wave.open(file_path, 'rb') as wav_file:
        sample_rate = wav_file.getframerate()
    return sample_rate

file_path = '/path/aida/wav_24k/002192.wav'
sample_rate = get_sample_rate(file_path)
print(f'采样率为:{sample_rate} Hz')
  • 5.特征提取
# 特征提取
python kantts/preprocess/data_process.py --voice_input_dir aishell3_16k/SSB0009 --voice_output_dir training_stage/SSB0009_feats --audio_config kantts/configs/audio_config_16k.yaml --speaker SSB0009

这是特征提取后的结果
image

主要是注意am_train.lst/am_vilid.lst/raw_metafile.txt里面是否有内容
提取完成后需要训练am
命令提示linux:

查看显卡nvdia-msi

  • 6.训练am(声学模型)
CUDA_VISIBLE_DEVICES=0 python kantts/bin/train_sambert.py --model_config speech_sambert-hifigan_tts_zh-cn_multisp_pretrain_16k/basemodel_16k/sambert/config.yaml --resume_path speech_sambert-hifigan_tts_zh-cn_multisp_pretrain_16k/basemodel_16k/sambert/ckpt/checkpoint_980000.pth --root_dir training_stage/SSB0009_feats --stage_dir training_stage/SSB0009_sambert_ckpt

可以添加nohup后台挂起,这个时间稍微有一点久

  • 7.训练voc
CUDA_VISIBLE_DEVICES=7 python kantts/bin/train_hifigan.py --model_config /home/syl01840793/speech_sambert-hifigan_tts_zh-cn_multisp_pretrain_24k/basemodel_24k/hifigan/config.yaml --resume_path /home/syl01840793/speech_sambert-hifigan_tts_zh-cn_multisp_pretrain_24k/basemodel_24k/hifigan/ckpt/checkpoint_2000000.pth --root_dir /home/syl01840793/train_config_test/Training_stage/aida/feat --stage_dir /home/syl01840793/train_config_test/Training_stage/aida/hifigan
mode_config 在基础base_model的chekpoint上增加100k,10ksave
  • 8.合成语音
    voc结束后会输出这些东西
    找到hifigan/ckpt下,最新(最大的)check_point

运行合成语音

CUDA_VISIBLE_DEVICES=0 python kantts/bin/text_to_wav.py --txt test.txt --output_dir res/SSB0009_syn --res_zip speech_sambert-hifigan_tts_zh-cn_multisp_pretrain_16k/resource.zip --am_ckpt training_stage/SSB0009_sambert_ckpt/ckpt/checkpoint_1100000.pth --voc_ckpt training_stage/SSB0009_hifigan_ckpt/ckpt/checkpoint_2100000.pth --speaker SSB0009

合成语音且通过audition来检测质量即可

标签:hifigan,语音,python,24k,sambert,--,阿里,file,path
From: https://www.cnblogs.com/ddsuifeng/p/17798197.html

相关文章

  • Python_web开发基础内容
    网络长连接的HTTP协议,会在响应头有加入这个头部字段:Connection:keep-aliveWebSocket:需要通过网络传输的任何实时更新或连续数据流,则可以使用WebSocketHTTP:不需要很频繁或仅获取一次的数据可以通过简单的HTTP请求查询都是用来跟踪浏览器用户身份的会话方式.cookie......
  • 如何使用Poco库采集阿里云信息
    阿里云是一个云主机平台,我们在购买云主机的时候,往往会因为挑选自己心意的产品而眼花缭乱。今天我就使用Poco库编写一个采集阿里云信息的程序,有了它,我们在挑选阿里云产品你轻松了许多,一起来看看吧。```cpp//引入Poco库#include<Poco/Net/HTTPClientSession.h>#include<Po......
  • Python-运算符
    Python-运算符1.Python运算符的优先级以下表格列出了从最高到最低优先级的所有运算符:如果是同优先级则从左往右依次递减运算符描述**乘方,指数(最高优先级)~+-按位翻转,一元加号和减号(最后两个的方法名为+@和-@)*/%//乘,除,取模和取整除+-......
  • Python 中的 __init__.py 和__all__ 详解(抄袭的joker) 因为写的实在是太好了
    Python中的__init__.py和__all__详解JOKER没意思先生 之前不论是自己写代码还是用别人的代码,都没有注意过这个东西,今天忽然看了一下,网上的教程感觉讲的都不是很清楚,自己又研究了研究,总结一下,如果有不对的地方,大家帮忙指正一下。在Python工程里,当pyth......
  • python 中[1:]、[:-1]和[::-1]
    代码分析:str='abcdefg'print(str[1:])print(str[:-1])print(str[-1:])print(str[::-1])print(str[::-2])print(str[:])-------------------------------------------------------------------------------------------结果bcdefgabcdefggfedcbagecaabcdefg1234567......
  • [Python] 基于 flask 构建 Web API 实现参数注入和校验
    在python中,flask包是一个轻量级的WEB框架,常用于快速构建HTTP服务。但它并没有提供参数校验和注入的功能。习惯了java等高级编程语言开发webapi的同学,应该都不想每定义一个api都要写很多代码去做校验和获取请求参数吧,至少我是这样。幸运的是,已经有人提供了参数校验相......
  • 基础环境(python,gpu等)
    anaconda:清华镜像站中anaconda的所有版本的网址:Indexof/anaconda/archive/|清华大学开源软件镜像站|TsinghuaOpenSourceMirrorminianaconda:Indexof/(anaconda.com) wgethttps://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.shbashMiniconda3-......
  • Linux版python安装教程
    如果你希望在CentOS上使用源码编译的方式安装Python3,请按照以下步骤进行操作:安装编译工具和依赖项:在开始编译前,需要安装一些编译工具和Python3的依赖项。在终端中运行以下命令:sudoyumgroupinstall"DevelopmentTools"sudoyuminstallopenssl-develbzip2-devellibff......
  • 在Python脚本中执行shell命令
    在Python脚本中执行shell命令,你可以使用subprocess模块。这个模块允许你运行系统命令并与其交互。例一如果你想在Python脚本中执行一个简单的shell命令,比如列出当前目录下的文件:importsubprocess#执行shell命令result=subprocess.run(['ls','-l'],capture_output=True,......
  • python 自定义序列化器
    @Serialization是一个自定义装饰器,通常用于序列化Python对象。使用@Serialization装饰器可以将一个类转换为可序列化的对象,这样就可以将其存储到文件或通过网络传输。下面是一个使用@Serialization装饰器的示例:importjsondefSerialization(cls):defserialize(......