text to speech toolkit. 好用的中文语音合成工具箱,包含语音编码器、语音合成器、声码器和可视化模块。

Overview

ttskit

ttskit

Text To Speech Toolkit: 语音合成工具箱。

安装

pip install -U ttskit
  • 注意
    • 可能需另外安装的依赖包:torch,版本要求torch>=1.6.0,<=1.7.1,根据自己的实际环境安装合适cuda或cpu版本的torch。
    • ttskit的默认音频采样率为22.5k。
    • 自行设置环境变量CUDA_VISIBLE_DEVICES以调用GPU,如果不设置,则默认调用0号GPU,没有GPU则使用CPU。
    • 默认用mspk模式的多发音人的语音合成模型,griffinlim声码器。

资源

使用ttskit的过程中会自动下载模型和语音资源。

如果下载太慢或无法下载,也可自行从百度网盘下载,把下载的资源合并到ttskit目录下(更新resource目录)。

链接:https://pan.baidu.com/s/13RPGNEKrCX3fgiGl7P5bpw

提取码:b7hw

快速使用

import ttskit

ttskit.tts('这是个示例', audio='14')

# 参数介绍
'''语音合成函数式SDK接口,函数参数全部为字符串格式。
text为待合成的文本。
speaker为发音人名称,可选名称为_reference_audio_dict;默认的发音人名称列表见resource/reference_audio/__init__.py。
audio为发音人参考音频,如果是数字,则调用内置的语音作为发音人参考音频;如果是语音路径,则调用audio路径的语音作为发音人参考音频。
注意:如果用speaker来选择发音人,请把audio设置为下划线【_】。
output为输出,如果以.wav结尾,则为保存语音文件的路径;如果以play开头,则合成语音后自动播放语音。
'''

版本

v0.2.1

sdk_api

语音合成SDK接口。 本地函数式地调用语音合成。

  • 简单使用
from ttskit import sdk_api

wav = sdk_api.tts_sdk('文本', audio='24')

cli_api

语音合成命令行接口。 用命令行调用语音合成。

  • 简单使用
from ttskit import cli_api

args = cli_api.parse_args()
cli_api.tts_cli(args)
# 命令行交互模式使用语音合成。
  • 命令行
tkcli

usage: tkcli [-h] [-i INTERACTION] [-t TEXT] [-s SPEAKER] [-a AUDIO]
             [-o OUTPUT] [-m MELLOTRON_PATH] [-w WAVEGLOW_PATH] [-g GE2E_PATH]
             [--mellotron_hparams_path MELLOTRON_HPARAMS_PATH]
             [--waveglow_kwargs_json WAVEGLOW_KWARGS_JSON]

语音合成命令行。

optional arguments:
  -h, --help            show this help message and exit
  -i INTERACTION, --interaction INTERACTION
                        是否交互,如果1则交互,如果0则不交互。交互模式下:如果不输入文本或发音人,则为随机。如果输入文本为exit
                        ,则退出。
  -t TEXT, --text TEXT  Input text content
  -s SPEAKER, --speaker SPEAKER
                        Input speaker name
  -a AUDIO, --audio AUDIO
                        Input audio path or audio index
  -o OUTPUT, --output OUTPUT
                        Output audio path. 如果play开头,则播放合成语音;如果.wav结尾,则保存语音。
  -m MELLOTRON_PATH, --mellotron_path MELLOTRON_PATH
                        Mellotron model file path
  -w WAVEGLOW_PATH, --waveglow_path WAVEGLOW_PATH
                        WaveGlow model file path
  -g GE2E_PATH, --ge2e_path GE2E_PATH
                        Ge2e model file path
  --mellotron_hparams_path MELLOTRON_HPARAMS_PATH
                        Mellotron hparams json file path
  --waveglow_kwargs_json WAVEGLOW_KWARGS_JSON
                        Waveglow kwargs json

web_api

语音合成WEB接口。 构建简单的语音合成服务。

  • 简单使用
from ttskit import web_api

web_api.app.run(host='0.0.0.0', port=2718, debug=False)
# 用POST或GET方法请求:http://localhost:2718/tts,传入参数text、audio、speaker。
# 例如GET方法请求:http://localhost:2718/tts?text=这是个例子&audio=2
  • 使用说明

http_server

语音合成简易界面。 构建简单的语音合成网页服务。

  • 简单使用
from ttskit import http_server

http_server.start_sever()
# 打开网页:http://localhost:9000/ttskit
  • 命令行
tkhttp

usage: tkhttp [-h] [--device DEVICE] [--host HOST] [--port PORT]

optional arguments:
  -h, --help       show this help message and exit
  --device DEVICE  设置预测时使用的显卡,使用CPU设置成-1即可
  --host HOST      IP地址
  --port PORT      端口号
  • 网页界面 index

resource

模型数据等资源。

audio model reference_audio

  • 内置发音人映射表
_speaker_dict = {
    1: 'Aibao', 2: 'Aicheng', 3: 'Aida', 4: 'Aijia', 5: 'Aijing',
    6: 'Aimei', 7: 'Aina', 8: 'Aiqi', 9: 'Aitong', 10: 'Aiwei',
    11: 'Aixia', 12: 'Aiya', 13: 'Aiyu', 14: 'Aiyue', 15: 'Siyue',
    16: 'Xiaobei', 17: 'Xiaogang', 18: 'Xiaomei', 19: 'Xiaomeng', 20: 'Xiaowei',
    21: 'Xiaoxue', 22: 'Xiaoyun', 23: 'Yina', 24: 'biaobei', 25: 'cctvfa',
    26: 'cctvfb', 27: 'cctvma', 28: 'cctvmb', 29: 'cctvmc', 30: 'cctvmd'
}

encoder

声音编码器(encoder)

  • 把语音音频编码为指定维度的向量。
  • 向量的相似度反映音频音色的相似度。如果两个音频的编码向量相似度越高,则这两个音频的音色越接近。
  • 编码向量主要用于控制发音的音色。

GE2E声音编码器

  • 谷歌在上发布了GE2E算法的论文,详细介绍了其声纹识别技术的核心实现方法。
  • 这是一种基于批(batch)的训练方法,这种基于批的训练,则是将同一批中每个说话者与其最相似的说话者的声纹特征变得不同。
  • 论文通过理论和实验论证了,这种始终针对最困难案例进行优化的训练方式,能够极大地提升训练速度和效果。

mellotron

语音合成器(synthesizer)

  • 把文本转为语音频谱数据。
  • 语音合成器接收声音编码向量和文本数据,然后结合这些信息把文本转为语音频谱。
  • 语音合成器的任务是把文本转为语音频谱,本质上是序列到序列的任务。
  • 可以把文本看做一个一个字组成的序列,把语音频谱看做是由一个一个语音特征组成的序列,语音合成器就是把文字序列转为语音特征序列的桥梁。
  • 语音合成器的关键就是怎样建立模型让文字准确的转为正确的读音,而且放在正确的位置,同时读音前后应当衔接自然,而且整个语音听起来也应当自然。
  • 要实现这样的目标,应当做很有针对性的模型。

Mellotron语音合成器

  • Mellotron是英伟达团队提出的语音合成模型,主要目标是做韵律风格转换和音乐生成。
  • Mellotron可以更加精细化的调整韵律和音调,将基频信息引入模型刻画声调信息,基频是区别音高的主要元素。
  • Mellotron模型的训练完全端到端化,不需要在数据集中含有音乐数据也可以生成音乐。
  • Mellotron不需要对音调和文本进行人为的对齐就可以学到两者之间的对齐关系。
  • Mellotron可以使用外部输入的注意力映射表,从而实现韵律迁移。

waveglow

声码器(vocoder)

  • 把语音频谱数据转为语音信号。
  • 语音信号和语音频谱数据并不是简单可以相互转换的数据,语音转为频谱是有信息丢失的,但是频谱记录了语音最主要的信息,可以通过其他技术手段把语音频谱尽可能逼真地逆变为语音信号,声码器就是这样的技术。
  • 声码器是把声音特征转为语音信号的技术。
  • 在语音合成任务中,声码器是负责把语音频谱转为语音信号。
  • 通常语音频谱记录的语音信息并不是全面的,例如mel频谱只是记录了部分频段的幅度信息,缺失了相位信息,而且许多频率的信息也丢失了。
  • 而声码器模型就是要从这样的频谱中尽可能准确全面地还原出语音信号。
  • 现在通常的方案是用深度学习的方法来解决,针对语音特征和语音信号的关系进行建模。

Waveglow声码器

  • WaveGlow是英伟达团队提出的一种依靠流的从梅尔频谱图合成高质量语音的模型。
  • Waveglow贡献是基于流的网络,结合了Glow和WaveNet的想法,因此网络称为WaveGlow 。
  • WaveGlow是一个生成模型,通过从分布采样中生成音频。
  • WaveGlow易于实施,仅使用单个网络进行训练,仅使用似然损失函数进行训练。
  • WaveGlow是兼顾生成速度快、生成质量高、稳定性强的模型。
Owner
KDD
Move on, work hard, do what you do.
KDD
A modular framework for vision & language multimodal research from Facebook AI Research (FAIR)

MMF is a modular framework for vision and language multimodal research from Facebook AI Research. MMF contains reference implementations of state-of-t

Facebook Research 5.1k Dec 26, 2022
Sinkhorn Transformer - Practical implementation of Sparse Sinkhorn Attention

Sinkhorn Transformer This is a reproduction of the work outlined in Sparse Sinkhorn Attention, with additional enhancements. It includes a parameteriz

Phil Wang 217 Nov 25, 2022
The code for the Subformer, from the EMNLP 2021 Findings paper: "Subformer: Exploring Weight Sharing for Parameter Efficiency in Generative Transformers", by Machel Reid, Edison Marrese-Taylor, and Yutaka Matsuo

Subformer This repository contains the code for the Subformer. To help overcome this we propose the Subformer, allowing us to retain performance while

Machel Reid 10 Dec 27, 2022
小布助手对话短文本语义匹配的一个baseline

oppo-text-match 小布助手对话短文本语义匹配的一个baseline 模型 参考:https://kexue.fm/archives/8213 base版本线下大概0.952,线上0.866(单模型,没做K-flod融合)。 训练 测试环境:tensorflow 1.15 + keras

苏剑林(Jianlin Su) 132 Dec 14, 2022
Sentence boundary disambiguation tool for Japanese texts (日本語文境界判定器)

Bunkai Bunkai is a sentence boundary (SB) disambiguation tool for Japanese texts. Quick Start $ pip install bunkai $ echo -e '宿を予約しました♪!まだ2ヶ月も先だけど。早すぎ

Megagon Labs 160 Dec 23, 2022
Mednlp - Medical natural language parsing and utility library

Medical natural language parsing and utility library A natural language medical

Paul Landes 3 Aug 24, 2022
Code and dataset for the EMNLP 2021 Finding paper "Can NLI Models Verify QA Systems’ Predictions?"

Code and dataset for the EMNLP 2021 Finding paper "Can NLI Models Verify QA Systems’ Predictions?"

Jifan Chen 22 Oct 21, 2022
Pytorch version of BERT-whitening

BERT-whitening This is the Pytorch implementation of "Whitening Sentence Representations for Better Semantics and Faster Retrieval". BERT-whitening is

Weijie Liu 255 Dec 27, 2022
The simple project to separate mixed voice (2 clean voices) to 2 separate voices.

Speech Separation The simple project to separate mixed voice (2 clean voices) to 2 separate voices. Result Example (Clisk to hear the voices): mix ||

vuthede 31 Oct 30, 2022
lightweight, fast and robust columnar dataframe for data analytics with online update

streamdf Streamdf is a lightweight data frame library built on top of the dictionary of numpy array, developed for Kaggle's time-series code competiti

23 May 19, 2022
Honor's thesis project analyzing whether the GPT-2 model can more effectively generate free-verse or structured poetry.

gpt2-poetry The following code is for my senior honor's thesis project, under the guidance of Dr. Keith Holyoak at the University of California, Los A

Ashley Kim 2 Jan 09, 2022
Entity Disambiguation as text extraction (ACL 2022)

ExtEnD: Extractive Entity Disambiguation This repository contains the code of ExtEnD: Extractive Entity Disambiguation, a novel approach to Entity Dis

Sapienza NLP group 121 Jan 03, 2023
Sentence Embeddings with BERT & XLNet

Sentence Transformers: Multilingual Sentence Embeddings using BERT / RoBERTa / XLM-RoBERTa & Co. with PyTorch This framework provides an easy method t

Ubiquitous Knowledge Processing Lab 9.1k Jan 02, 2023
Ongoing research training transformer language models at scale, including: BERT & GPT-2

Megatron (1 and 2) is a large, powerful transformer developed by the Applied Deep Learning Research team at NVIDIA.

NVIDIA Corporation 3.5k Dec 30, 2022
Repository for the paper "Optimal Subarchitecture Extraction for BERT"

Bort Companion code for the paper "Optimal Subarchitecture Extraction for BERT." Bort is an optimal subset of architectural parameters for the BERT ar

Alexa 461 Nov 21, 2022
PRAnCER is a web platform that enables the rapid annotation of medical terms within clinical notes.

PRAnCER (Platform enabling Rapid Annotation for Clinical Entity Recognition) is a web platform that enables the rapid annotation of medical terms within clinical notes. A user can highlight spans of

Sontag Lab 39 Nov 14, 2022
Generate product descriptions, blogs, ads and more using GPT architecture with a single request to TextCortex API a.k.a Hemingwai

TextCortex - HemingwAI Generate product descriptions, blogs, ads and more using GPT architecture with a single request to TextCortex API a.k.a Hemingw

TextCortex AI 27 Nov 28, 2022
A fast hierarchical dimensionality reduction algorithm.

h-NNE: Hierarchical Nearest Neighbor Embedding A fast hierarchical dimensionality reduction algorithm. h-NNE is a general purpose dimensionality reduc

Marios Koulakis 35 Dec 12, 2022
PORORO: Platform Of neuRal mOdels for natuRal language prOcessing

PORORO: Platform Of neuRal mOdels for natuRal language prOcessing pororo performs Natural Language Processing and Speech-related tasks. It is easy to

Kakao Brain 1.2k Dec 21, 2022
Official PyTorch implementation of SegFormer

SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers Figure 1: Performance of SegFormer-B0 to SegFormer-B5. Project page

NVIDIA Research Projects 1.4k Dec 29, 2022