README.md 3.43 KB
Newer Older
ACzhangchao's avatar
ACzhangchao committed
1
2
3
4
5
6
# Tacotron 2 (without wavenet)

## 论文

https://arxiv.org/abs/1712.05884

7
8
9
10
## 模型结构

Tacotron2与第一代相比剔除了CBHG模块,改为LSTM和卷积层,在保证语音合成质量的前提下简化了模型结构,提高训练和推理效率,在Vocoder部分使用可训练的WaveNet替换掉第一代中的Griffin-Lim算法,能够以高质量和高保真度生成音频波形

ACzhangchao's avatar
ACzhangchao committed
11
![](https://developer.sourcefind.cn/codes/modelzoo/tacotron2/-/raw/main/tacotron2%E6%A8%A1%E5%9E%8B%E7%BB%93%E6%9E%84.png?inline=false)
12
13
14
15
16

## 算法原理

Tacotron 2 模型通过使用编码器-解码器架构结合注意力机制,将文本序列转换为梅尔频谱图,然后利用WaveNet声码器将这些频谱图转化为自然语音波形,其核心在于端到端的训练方式和高质量语音合成能力。

ACzhangchao's avatar
ACzhangchao committed
17
![](https://developer.sourcefind.cn/codes/modelzoo/tacotron2/-/raw/main/LSTM.png?inline=false)
18

ACzhangchao's avatar
ACzhangchao committed
19
20
## 环境配置

21
### Docker(方法一)
ACzhangchao's avatar
ACzhangchao committed
22
23
24
25

拉取镜像,启动并进入容器

```
26
27
28
29
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-py3.10-dtk24.04.3-ubuntu20.04
# <Image ID>用上面拉取docker镜像的ID替换
# <Host Path>主机端路径
# <Container Path>容器映射路径
ACzhangchao's avatar
ACzhangchao committed
30
docker run --shm-size 80g --network=host --name=tacotron2 -v /opt/hyhal:/opt/hyhal:ro --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v <Host Path>:<Container Path> -it <Image ID> /bin/bash
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
```

### Dockerfile(方法二)

```
# <Host Path>主机端路径
# <Container Path>容器映射路径
docker build -t tacotron2_image .
docker run --shm-size 80g \
    --network=host \
    --name=tacotron2 \
    -v /opt/hyhal:/opt/hyhal:ro \
    --privileged \
    --device=/dev/kfd \
    --device=/dev/dri \
    --group-add video \
    --cap-add=SYS_PTRACE \
    --security-opt seccomp=unconfined \
ACzhangchao's avatar
ACzhangchao committed
49
    --v <Host Path>:<Container Path> <Image ID> \
50
51
52
53
54
55
56
57
58
59
60
    -it tacotron2_image
```

### Anaconda(方法三)

```
conda create -n tacotron2 python=3.10
#主要库版本有:
#DTK:24.04.3
#python3.10
#torch:2.1.0
ACzhangchao's avatar
ACzhangchao committed
61
62
63
64
65
```

### 拉取代码仓

```
66
git clone http://developer.sourcefind.cn/codes/modelzoo/tacotron2.git
ACzhangchao's avatar
ACzhangchao committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
```

```
cd tacotron2
```

### 初始化子模块

```
git submodule init; git submodule update
```

### 更新.wav路径

```
sed -i -- 's,DUMMY,/LJSpeech-1.1/wavs,g' filelists/*.txt
```

### 安装python依赖

```
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
```

91
92
93
94
95
96
97
98
99
## 数据集

采用的数据集为LJSpeech-1.1,用于语音合成的数据集,包含语音和文本信息,语音为wav格式,文本以csv格式保存。

官方链接:https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2

## 训练

### 单卡训练
ACzhangchao's avatar
ACzhangchao committed
100
101
102
103
104

```
bash run_single.sh
```

105
### 多卡训练
ACzhangchao's avatar
ACzhangchao committed
106
107
108
109
110

```
bash run_multi.sh
```

111
## 推理
ACzhangchao's avatar
ACzhangchao committed
112
113
114
115

将inference.py中的”checkpoint_path“和”waveglow_path“换成自己的路径,运行inference.py

```python
116
export HIP_VISIBLE_DEVICES 设置可见卡
ACzhangchao's avatar
ACzhangchao committed
117
python inference.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
```

## result

```
输入:"Waveglow is really awesome!"
输出:“./output/output_audio.wav”以及“./output/mel_spectrograms.png”
```

### 精度



## 应用场景

### 算法分类

```
语音合成
```

### 热点应用行业

```
金融、制造、科研、政府、教育、气象
```

## 预训练权重

## 源码仓库及问题反馈

dcuai's avatar
dcuai committed
149
http://developer.sourcefind.cn/codes/modelzoo/tacotron2_pytorch
150
151
152

## 参考

chenzk's avatar
chenzk committed
153
[tacotron2](https://github.com/NVIDIA/tacotron2)