---
title: speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch
canonical_url: "https://www.modelscope.cn/models/iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch"
md_url: "https://www.modelscope.cn/models/iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch.md"
repository: iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch
chinese_name: "语音合成-laura-英文-libritts-16k-codec_nq2-pytorch"
last_updated: 2023-12-22
license: "Apache License 2.0"
pipeline_tag: text-to-speech
tasks:
  - text-to-speech
model_type:
  - laura-codec
library_name:
  - pytorch
frameworks:
  - pytorch
language:
  - en_US
domain:
  - audio
downloads: 1243
stars: 5
tags:
  - Text-to-speech
  - Zero-shot
  - LauraGPT
  - Alibaba
---

# speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch

> speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch - iic 在 ModelScope 开源的模型。基于语音离散token，类似 LauraGPT 的英文语音合成模型

iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch 是 ModelScope 魔搭社区上的text-to-speech模型，采用 Apache License 2.0 许可。

- **Repository**: iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch
- **License**: Apache License 2.0
- **Tasks**: text-to-speech
- **Tags**: Text-to-speech, Zero-shot, LauraGPT, Alibaba
- **Downloads**: 1243
- **Stars**: 5
- **Last updated**: 2023-12-22

Source: https://www.modelscope.cn/models/iic/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch

---

# Highlights
适用于英文语音合成，具备 zero-shot 说话人自适应能力，也可以作为普通的语音合成器，可用于多种语音合成场景。
- 较高的语音合成质量
- 具备 zero-shot 说话人自适应能力
- 可以用于多种场景，例如音色转换(Voice conversion)

# 项目介绍
[FunCodec](https://github.com/alibaba-damo-academy/FunCodec) 是达摩院语音团队开源的音频量化与合成工具包。
FunCodec 提供了在多领域音频数据集上预训练的音频量化和音频合成模型，可以被应用于低比特率语音通讯、语音离散化表示、zero-shot语音合成、音频合成等相关的学术研究。
本项目提供了在 LibriTTS 上训练的 LauraGPT-style 的语音合成(Text-To-Speech, TTS)模型 LauraTTS。

<p align="center">
<img src="fig/framework.png" alt="LauraGPT TTS Model"/>
</p>

LauraTTS主要包括两个部分：Decoder-only 的自回归 Transformer 模块和Encoder-only 的非自回归 Transformer 模块：
- Decoder-only Transformer可以看做一个conditional 语言模型，它以 prompt text, text 和 prompt audio 作为 conditions，对要合成的语音 token 进行建模。
在本模型中，我们使用 [FunCodec通用语音量化器](https://www.modelscope.cn/models/damo/audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch/summary) 对原始语音进行量化，使用其前 2 组量化结果来表示 prompt audio 和 目标语音。
- Encoder-only Transformer 则以 Decoder-only Transformer 的输出作为输入，以 text 作为 condition，预测[FunCodec通用语音量化器](https://www.modelscope.cn/models/damo/audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch/summary)隐层的连续表征，
该连续表征可以使用量化器的解码器合成为原始音频波形

更多细节详见：
- [FunCodec: A Fundamental, Reproducible and Integrable Open-source Toolkit for Neural Speech Codec](https://arxiv.org/abs/2309.07405)
- [LauraGPT: Listen, Attend, Understand, and Regenerate Audio with GPT](https://arxiv.org/abs/2310.04673)

# 如何使用模型

## 在本地机器中推理

如果您有本地推理或定制模型的需求，请前往下载 [FunCodec](https://github.com/alibaba-damo-academy/FunCodec) 音频量化工具包。

### FunCodec 框架安装

- 安装 FunCodec

```sh
# 安装 Pytorch GPU (version >= 1.12.0):
conda install pytorch==1.12.0
# 对于其他版本，请参考 https://pytorch.org/get-started/locally

# 下载项目代码:
git clone https://github.com/alibaba-damo-academy/FunCodec.git

# 安装 FunCodec:
cd FunCodec
pip install --editable ./
```

### 使用 FunCodec 进行语音合成
接下以 LibriTTS 数据集为例，介绍如何使用 FunCodec 进行语音合成：
```sh
# 进入工作目录
cd egs/LibriTTS/text2speech_laura
model_name="audio_codec-encodec-en-libritts-16k-nq32ds640-pytorch"
# 1. 生成音色随机的语音，生成结果保存在 results 文件夹下
bash demo.sh --stage 1 --model_name ${model_name} --output_dir results --text "hello world"

# 2. 生成给定说话人的语音，生成结果保存在 results 文件夹下
bash demo.sh --stage 2 --model_name ${model_name} --output_dir results --text "hello world" \
  --prompt_text "one of these is context" --prompt_audio "demo/8230_279154_000013_000003.wav"
```

### 使用 ModelScope 进行语音合成
```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
my_pipeline = pipeline(
   task=Tasks.text_to_speech,
   model='damo/speech_synthesizer-laura-en-libritts-16k-codec_nq2-pytorch'
)
text='nothing was to be done but to put about, and return in disappointment towards the north.'
prompt_text='one of these is context'
prompt_speech='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_data/FunCodec/prompt.wav'
# free generation
print(my_pipeline(text))
# zero-shot generation
print(my_pipeline(text, prompt_text, prompt_speech))
```

# Benchmark

## 训练配置
- Feature info: text, raw waveform input
- Train info: Adam, lr 1e-3, batch_bins 10240, 1 gpu(Tesla A100), acc_grad 1, 50 epoch, speech_max_length 30s
- Loss info: cross entropy, L1, L2
- Model info: Transformer, SEANet, Conv, LSTM
- Train config: config.yaml
- Model size: 84.19 M parameters

## 实验结果
- Test set: LibriTTS test-clean
- Metrics: WER and Ins, Del, Sub errors.
- Speaker similarity: Cosine similarity with Resemblyzer encoder

|        testset         | WER  | Ins | Del | Sub | Speaker Simi |
|:----------------------:|:----:|:---:|:---:|:---:|:------------:|
|  LibriTTS test-clean   | 3.01 | 15  |  51 | 200 |    83.53     |    
|         LauraTTS       | 4.56 | 44  |  78 | 278 |    78.20     |


## 使用方式以及适用范围

运行范围
- 已在 Linux-x86_64 通过测试，暂未测试 Mac 和 Windows 。

使用方式
- 直接推理：自由合成英文语音或者根据 prompt 合成某种音色说话人的语音，或进行音色转换
- 微调：请使用 FunCodec 中的 run.sh 进行相关实验

使用范围与目标场景
- 适用于相关学术研究，在英文数据集上进行语音合成、音色转换等任务。

## 模型局限性以及可能的偏差

- 特征提取流程和工具差异，会对 WER 的数值带来一定的差异（ < 0.1 ）

## 相关论文以及引用信息
```BibTeX
@misc{du2023funcodec,
      title={FunCodec: A Fundamental, Reproducible and Integrable Open-source Toolkit for Neural Speech Codec},
      author={Zhihao Du, Shiliang Zhang, Kai Hu, Siqi Zheng},
      year={2023},
      eprint={2309.07405},
      archivePrefix={arXiv},
      primaryClass={cs.Sound}
}
@misc{LauraGPT,
      title={LauraGPT: Listen, Attend, Understand, and Regenerate Audio with GPT},
      author={Jiaming Wang*, Zhihao Du*, Qian Chen, Yunfei Chu, Zhifu Gao, Zerui Li, Kai Hu, Xiaohuan Zhou, Jin Xu, Ziyang Ma, Wen Wang, Siqi Zheng, Chang Zhou, Zhijie Yan, Shiliang Zhang},
      year={2023},
      eprint={2310.04673},
      archivePrefix={arXiv},
      primaryClass={cs.AI}
}
```
