VITS(Conditional Variational Autoencoder with Adversarial Learning)论文解读及实现(一)

本文主要是介绍VITS(Conditional Variational Autoencoder with Adversarial Learning)论文解读及实现(一),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  • 此篇为VITS论文解读第一部份
    论文地址Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech
  • 模型使用了VAE,GAN,FLOW以及transorflomer(文本处理有用到),即除了未diffusion模型,将生成式模型都融入进来了,是一篇集大成的文章。涉及的知识点和公式也比较多(好在都是常用的公式)
  • 模型结构及术语
    ①后验编码器posterior encoder p ( z ∣ x ) p(z|x) p(zx)
    a.解释:在给定语音波形时,生成隐变量z的模型,
    b. 输入是语音,
    c. 输出是隐变量
    ②先验编码器prior encoder p ( z ∣ c t e x t , a ) p(z|c_{text},a) p(zctext,a)
    a. 解释:给定文本和文本语音对齐矩阵A时,生成隐变量z的模型
    b. 输入是文本和对齐矩阵A,
    c. 输出是隐变量z
    ③解码器decoder p ( x ∣ z ) p(x|z) p(xz),
    a. 解释:解码器是给定隐变量z时,生成音频波形x的模型,
    b. 输入是隐变量
    c. 输出是音频波形
    ④判别器discriminator D
    a. 解释:判断一个音频波形数据是解码器生成的还是真时存在的
    b. 输入音频波形,判断是真实音频还是模型生成的音频
    c. 输出0~1的值
    ⑤随机时长预测 stochastic duration predictor
    预测一个文本对应的波形时长(同一个人在一句话中同一个字的时长也是不同的,因此使用随机时长预测模型)

(备注,上面的音频波形都转换为mel线性谱使用,书写只是方便理解)

0 Abstract

In this work, we present a parallel endto-end TTS method that generates more natural sounding audio than current two-stage models. Our method adopts variational inference augmented with normalizing flows and an adversarial training process, which improves the expressive power of generative modeling. We also propose a stochastic duration predictor to synthesize speech with diverse rhythms from input text. With the uncertainty modeling over latent variables and the stochastic duration predictor, our method expresses the natural one-to-many relationship in which a text input can be spoken in multiple ways with different pitches and rhythms.

在这项工作中,我们提出了一种并行的端到端TTS方法,该方法比当前的两阶段模型产生更自然的声音。该方法采用normalizing flows(glow)增强的变分推理和对抗训练过程,提高了生成建模的表达能力。我们还提出了一个随机持续时间预测器,用于从输入文本合成具有不同节奏的语音。通过对潜在变量的不确定性建模和随机持续时间预测,我们的方法表达了一种自然的一对多关系,在这种关系中,文本输入可以以多个形式出现

1. Introduction

  • Text-to-speech (TTS)通常被简化为两阶段模型,
    第一阶段是从文本生成语音的中间表征,如mel谱或者语音特征
    第二阶段是根据中间表征生成波形图

  • 我们提出了一种并行的端到端TTS方法
    ①Using a variational autoencoder (VAE) (Kingma & Welling, 2014), we connect two modules of TTS systems through latent variables to enable efficient end-to-end learning
    使用VAE,我们通过隐变量连接TTS系统的两个模块,实现高效的端到端学习
    ②we apply normalizing flows to our conditional prior distribution and adversarial training on the waveform domain
    我们将normalizing flow应用于我们的条件先验分布和波形域上的对抗训练。
    ③ we also propose a stochastic duration predictor to synthesize speech with diverse rhythms from input text.

我们还提出了一个随机持续时间预测器,用于从输入文本合成具有不同节奏的语音。

2 Method

  • The proposed method is mostly described in the first three subsections:
    ①conditional VAE formulation;
    ②alignment estimation derived from variational inference; adversarial ③training for improving synthesis quality
  • 所提出的方法主要在前三个小节中进行描述:
    ①条件VAE公式;
    ②基于变分推理的对齐估计;
    ③提高合成质量的对抗性训练

在这里插入图片描述

2.1 Variational Inference

2.1.1 OVERVIEW

  • VITS can be expressed as a conditional VAE with the objective of maximizing the variational lower bound, also called the evidence lower bound (ELBO), of the intractable marginal log-likelihood of data l o g p θ ( x ∣ c ) log p_\theta (x|c) logpθ(xc)
    VITS可以表示为一个条件VAE,其目标是最大化 l o g p θ ( x ∣ c ) log p_\theta (x|c) logpθ(xc)的变分下界,也称为证据下界(ELBO)
    变分公式:
    l o g p θ ( x ∣ c ) > = ∑ q ϕ ( z ∣ x ) [ l o g p θ ( x ∣ z ) − l o g q ϕ ( z ∣ x ) p θ ( z ∣ c ) ] logp_\theta (x|c)>= \sum q_\phi (z|x)[logp_\theta (x|z)-log\frac{q_\phi(z|x)}{p_\theta (z|c)}] logpθ(xc)>=qϕ(zx)[logpθ(xz)logpθ(zc)qϕ(zx)]
    等式后面可以展开为两项:
    l o g p θ ( x ∣ c ) > = ∑ q ϕ ( z ∣ x ) l o g p θ ( x ∣ z ) − ∑ q ϕ ( z ∣ x ) l o g q ϕ ( z ∣ x ) p θ ( z ∣ c ) logp_\theta (x|c)>= \sum q_\phi (z|x)logp_\theta (x|z)- \sum q_\phi (z|x)log\frac{q_\phi(z|x)}{p_\theta (z|c)} logpθ(xc)>=qϕ(zx)logpθ(xz)qϕ(zx)logpθ(zc)qϕ(zx)

上式中第一项即为ELBO,第二项为KL散度

pθ(z|c) 是给定条件c 情况下,因变量z的先验分布
pθ(x|z) 是数据x的似然函数, (及解码器)
qφ(z|x) 是后验分布
训练损失是-ELBO, 及重构损失 − log pθ(x|z)

2.1.2. RECONSTRUCTION LOSS

  • 重构loss,使用梅尔谱图,而不是原始波形
  • 我们通过解码器将隐变量z上采样到波形y,并将y变换到频谱域x_mel。然后将预测与目标mel谱图之间的L1 loss作为重建loss:
    L r e c o n = ∣ ∣ ∣ x m e l − x ^ m e l ∣ ∣ 1 L_{recon}=|||x_{mel} - \hat x_{mel}||_1 Lrecon=∣∣∣xmelx^mel1
  • 使用mel图谱作为损失的原因
    1 能改善感知质量,因为mel图谱更能代表人的听觉系统
    2 mel图片来自音频,因此不需要训练,只需要STFT和一个线性变换
    3 只在训练阶段使用,对推理没有影响

2.1.3. KL-DIVERGENCE

  • 条件c (由两部分组成ctext和A)
    1 文本条件ctext
    2 文本波形对齐矩阵A
  • 为了提高后验编码器能力,使用线性mel谱代替之前的mel谱
  • 则KL 散度如下
    在这里插入图片描述
  • normalizing flow引入
    发现增加后验分布的表现能力对真实样本对生成非常重要,引入flow ,使简单的分布变成更复杂的分布,
    即对正太分布采样的z,先过一个normalizing flow,生成 f θ ( z ) f_\theta (z) fθ(z),再正太分布生成 p θ ( z ∣ c ) p_\theta (z|c) pθ(zc)
    在这里插入图片描述

2.2. Alignment Estimation

2.2.1. MONOTONIC ALIGNMENT SEARCH

使用Monotonic Alignment Search方法,估计文本和目标语音的对齐矩阵A,

一个方法通过normalizing flow 最大化数据似然,算法感兴趣可以参考Monotonic Alignment Search论文

在这里插入图片描述
因为是优化ELBO,而不是直接优化p(x),因此对上述等式(5)进行变换,只提出和A有关的一项,得到下式(6)
在这里插入图片描述

2.2.2. DURATION PREDICTION FROM TEXT

文本持续时间预测

  • 通过文本语音对齐矩阵,将语音求和 ∑ j A i j \sum_j A_{ij} jAij可以得到文本的持续时间,然后训练一个持续时间预测模型
    缺点:不能表现一个人同一时刻的不同语速,(即统一因素时长都是同一个值)

  • 我们设计了一个随机时长预测模型,该模型基于flow ,目标是最大化似然,

  • 因为每个因素的输入都是1,有以下2个问题
    ①是一个离散的整数,需要被量化后才能输入连续的 normalizing flows,
    ②是一个标量,阻止了高维变换,

  • 我们使用了variational dequantization和 variational data augmentation两种方法,
    ①我们引入两个随机变量u和ν,它们与持续时间序列d具有相同的时间分辨率和维度,分别用于variational dequatization 和 variational data augmentation,
    ②限制u的取值范围为 [0, 1),那么d-u就为正数,
    ③我们将ν和d通道连接起来,以获得更高维度的潜在表示。
    ④然后从后验分布 q ϕ ( u , v ∣ d , c t e x t ) q_\phi (u,v|d,ctext) qϕ(u,vd,ctext)中采样u,v,,目标是音素持续时间的对数似然的变分下界:
    ⑤loss为负变分下界

在这里插入图片描述

2.3. Adversarial Training

我们添加了一个判别器D来识别解码器G产生的输出和真实波形y
对抗损失和其他gan区别不大

在这里插入图片描述

2.4. Final Loss

结合VAE和GAN的训练,整体的VAE损失可以表示如下
在这里插入图片描述

2.5. Model Architecture

  • 该模型的整体架构由下面5部份组成。其中后验编码器 p ( z ∣ x ) p(z|x) p(zx)和判别器D只用于训练,不用于推理。
    ①posterior encoder p ( z ∣ x ) p(z|x) p(zx)
    ②prior encoder p ( z ∣ c t e x t , a ) p(z|c_{text},a) p(zctext,a)
    ③decoder p ( x ∣ z ) p(x|z) p(xz),
    ④discriminator D
    ⑤ stochastic duration predictor

2.5.1. POSTERIOR ENCODER

  • For the posterior encoder, we use the non-causal WaveNet residual blocks used in WaveGlow
    对于后验编码器,我们使用WaveGlow中使用的非因果WaveNet残差块
  • A WaveNet residual block consists of layers of dilated convolutions with a gated activation unit and skip connection. The linear projection layer above the blocks produces the mean and variance of the normal posterior distribution. For the multi-speaker case, we use global conditioning in residual blocks to add speaker embedding.
    WaveNet残差块由带有门控激活单元和跳跃连接的膨胀卷积层组成。block层上方的线性投影层产生正态后验分布的均值和方差。对于多说话人的情况,我们在残差块中使用全局调节来添加说话人嵌入

2.5.2. PRIOR ENCODER

  • encode 组成:
    The prior encoder consists of a text encoder that processes the input phonemes ctext and a normalizing flow fθ that improves the flexibility of the prior distribution
    先验编码器由处理输入音素文本的文本编码器和提高先验分布灵活性的规范化流fθ组成
  • 文本编码器:
    The text encoder is a transformer encoder that uses relative positional representation
    文本编码器是使用相对位置表示的转换器编码器
  • 模型输出
    We can obtain the hidden representation htext from ctext through the text encoder and a linear projection layer above the text encoder that produces the mean and variance used for constructing the prior distribution.
    我们可以通过文本编码器和文本编码器上面的线性投影层从文本中获得隐藏表示htext,该层产生用于构造先验分布的均值和方差。
  • normalizing flow结构
    The normalizing flow is a stack of affine coupling layers consisting of a stack of WaveNet residual blocks. For simplicity, we design
    the normalizing flow to be a volume-preserving transformation with the Jacobian determinant of one.
    归一化流是由一堆WaveNet残差块组成的一堆仿射耦合层。为了简单,我们设计归一化流是一个雅可比行列式为1,体积不变变换。
  • 多说话人
    For the multispeaker setting, we add speaker embedding to the residual blocks in the normalizing flow through global conditioning.
    对于多说话人设置,我们通过全局调节将说话人嵌入到归一化流中的剩余块中。

2.5.3. DECODER

  • decoder结构
    The decoder is essentially the HiFi-GAN V1 generator
    解码器本质上是HiFi-GAN V1发生器
  • 结构组成:
    It is composed of a stack of transposed convolutions, each of which is followed by a multireceptive field fusion module (MRF). The output of the MRF is the sum of the output of residual blocks that have different receptive field sizes
    它由一堆转置卷积组成,每个转置卷积之后都有一个多接受场融合模块(MRF)。MRF的输出是具有不同接受野大小的剩余块的输出之和
  • 多说话人设置
    For the multi-speaker setting, we add a linear layer that transforms speaker embedding and add it to the input latent variables z.
    对于多说话人设置,我们添加了一个线性层来转换说话人嵌入并将其添加到输入潜在变量z中。

2.5.4. DISCRIMINATOR

We follow the discriminator architecture of the multi-period discriminator proposed in HiFi-GAN The multi-period discriminator is a mixture of Markovian window-based sub-discriminators , each of which operates on different periodic patterns of input waveforms.
我们借鉴HiFi-GAN中提出的多周期鉴别器的鉴别器结构,多周期鉴别器是基于马尔可夫窗的子鉴别器的混合物,每个子鉴别器对输入波形的不同周期模式起作用。

2.5.5. STOCHASTIC DURATION PREDICTOR

The stochastic duration predictor estimates the distribution of phoneme duration from a conditional input htext.
随机持续时间预测器从条件输入文本中估计音素持续时间的分布。

For the efficient parameterization of the stochastic duration predictor, we stack residual blocks with dilated and depth-separable convolutional layers. We also apply neural spline flows, which take the form of invertible nonlinear transformations by using monotonic rational-quadratic splines, to coupling layers.
为了有效地参数化随机持续时间预测器,我们用膨胀的和深度可分的卷积层叠加残差块。我们还应用neural spline flows用于耦合层,它采用单调有理-二次样条曲线的可逆非线性变换形式。

For the multi-speaker setting, we add a linear layer that transforms speaker embedding and add it to the input htext.
对于多speaker设置,我们添加了一个线性层来转换speaker嵌入并将其添加到输入文本中。

3. Experiments

文章涉及知识点和公式证明较多,自行查看相关资料

这篇关于VITS(Conditional Variational Autoencoder with Adversarial Learning)论文解读及实现(一)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/605041

相关文章

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

在 Spring Boot 中实现异常处理最佳实践

《在SpringBoot中实现异常处理最佳实践》本文介绍如何在SpringBoot中实现异常处理,涵盖核心概念、实现方法、与先前查询的集成、性能分析、常见问题和最佳实践,感兴趣的朋友一起看看吧... 目录一、Spring Boot 异常处理的背景与核心概念1.1 为什么需要异常处理?1.2 Spring B

Python位移操作和位运算的实现示例

《Python位移操作和位运算的实现示例》本文主要介绍了Python位移操作和位运算的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 位移操作1.1 左移操作 (<<)1.2 右移操作 (>>)注意事项:2. 位运算2.1

如何在 Spring Boot 中实现 FreeMarker 模板

《如何在SpringBoot中实现FreeMarker模板》FreeMarker是一种功能强大、轻量级的模板引擎,用于在Java应用中生成动态文本输出(如HTML、XML、邮件内容等),本文... 目录什么是 FreeMarker 模板?在 Spring Boot 中实现 FreeMarker 模板1. 环

Qt实现网络数据解析的方法总结

《Qt实现网络数据解析的方法总结》在Qt中解析网络数据通常涉及接收原始字节流,并将其转换为有意义的应用层数据,这篇文章为大家介绍了详细步骤和示例,感兴趣的小伙伴可以了解下... 目录1. 网络数据接收2. 缓冲区管理(处理粘包/拆包)3. 常见数据格式解析3.1 jsON解析3.2 XML解析3.3 自定义

SpringMVC 通过ajax 前后端数据交互的实现方法

《SpringMVC通过ajax前后端数据交互的实现方法》:本文主要介绍SpringMVC通过ajax前后端数据交互的实现方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价... 在前端的开发过程中,经常在html页面通过AJAX进行前后端数据的交互,SpringMVC的controll

Spring Security自定义身份认证的实现方法

《SpringSecurity自定义身份认证的实现方法》:本文主要介绍SpringSecurity自定义身份认证的实现方法,下面对SpringSecurity的这三种自定义身份认证进行详细讲解,... 目录1.内存身份认证(1)创建配置类(2)验证内存身份认证2.JDBC身份认证(1)数据准备 (2)配置依

利用python实现对excel文件进行加密

《利用python实现对excel文件进行加密》由于文件内容的私密性,需要对Excel文件进行加密,保护文件以免给第三方看到,本文将以Python语言为例,和大家讲讲如何对Excel文件进行加密,感兴... 目录前言方法一:使用pywin32库(仅限Windows)方法二:使用msoffcrypto-too