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
Princeton NLP's pre-training library based on fairseq with DeepSpeed kernel integration 🚃

This repository provides a library for efficient training of masked language models (MLM), built with fairseq. We fork fairseq to give researchers mor

Princeton Natural Language Processing 92 Dec 27, 2022
Unsupervised Abstract Reasoning for Raven’s Problem Matrices

Unsupervised Abstract Reasoning for Raven’s Problem Matrices This code is the implementation of our TIP paper. This is the first unsupervised abstract

Tao Zhuo 9 Dec 17, 2022
💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants

Rasa Open Source Rasa is an open source machine learning framework to automate text-and voice-based conversations. With Rasa, you can build contextual

Rasa 15.3k Jan 03, 2023
Trains an OpenNMT PyTorch model and SentencePiece tokenizer.

Trains an OpenNMT PyTorch model and SentencePiece tokenizer. Designed for use with Argos Translate and LibreTranslate.

Argos Open Tech 61 Dec 13, 2022
Script to generate VAD dataset used in Asteroid recipe

About the dataset LibriVAD is an open source dataset for voice activity detection in noisy environments. It is derived from LibriSpeech signals (clean

11 Sep 15, 2022
NLP command-line assistant powered by OpenAI

NLP command-line assistant powered by OpenAI

Axel 16 Dec 09, 2022
Torchrecipes provides a set of reproduci-able, re-usable, ready-to-run RECIPES for training different types of models, across multiple domains, on PyTorch Lightning.

Recipes are a standard, well supported set of blueprints for machine learning engineers to rapidly train models using the latest research techniques without significant engineering overhead.Specifica

Meta Research 193 Dec 28, 2022
Code for Findings at EMNLP 2021 paper: "Learn Continually, Generalize Rapidly: Lifelong Knowledge Accumulation for Few-shot Learning"

Learn Continually, Generalize Rapidly: Lifelong Knowledge Accumulation for Few-shot Learning This repo is for Findings at EMNLP 2021 paper: Learn Cont

INK Lab @ USC 6 Sep 02, 2022
NLP-based analysis of poor Chinese movie reviews on Douban

douban_embedding 豆瓣中文影评差评分析 1. NLP NLP(Natural Language Processing)是指自然语言处理,他的目的是让计算机可以听懂人话。 下面是我将2万条豆瓣影评训练之后,随意输入一段新影评交给神经网络,最终AI推断出的结果。 "很好,演技不错

3 Apr 15, 2022
ChatBotProyect - This is an unfinished project about a simple chatbot.

chatBotProyect This is an unfinished project about a simple chatbot. (union_todo.ipynb) Reminders for the project: Find why one of the vectorizers fai

Tomás 0 Jul 24, 2022
Mesh TensorFlow: Model Parallelism Made Easier

Mesh TensorFlow - Model Parallelism Made Easier Introduction Mesh TensorFlow (mtf) is a language for distributed deep learning, capable of specifying

1.3k Dec 26, 2022
NLPretext packages in a unique library all the text preprocessing functions you need to ease your NLP project.

NLPretext packages in a unique library all the text preprocessing functions you need to ease your NLP project.

Artefact 114 Dec 15, 2022
A 30000+ Chinese MRC dataset - Delta Reading Comprehension Dataset

Delta Reading Comprehension Dataset 台達閱讀理解資料集 Delta Reading Comprehension Dataset (DRCD) 屬於通用領域繁體中文機器閱讀理解資料集。 本資料集期望成為適用於遷移學習之標準中文閱讀理解資料集。 本資料集從2,108篇

272 Dec 15, 2022
Paddlespeech Streaming ASR GUI

Paddlespeech-Streaming-ASR-GUI Introduction A paddlespeech Streaming ASR GUI. Us

Niek Zhen 3 Jan 05, 2022
Dust model dichotomous performance analysis

Dust-model-dichotomous-performance-analysis Using a collated dataset of 90,000 dust point source observations from 9 drylands studies from around the

1 Dec 17, 2021
A python wrapper around the ZPar parser for English.

NOTE This project is no longer under active development since there are now really nice pure Python parsers such as Stanza and Spacy. The repository w

ETS 49 Sep 12, 2022
MHtyper is an end-to-end pipeline for recognized the Forensic microhaplotypes in Nanopore sequencing data.

MHtyper is an end-to-end pipeline for recognized the Forensic microhaplotypes in Nanopore sequencing data. It is implemented using Python.

willow 6 Jun 27, 2022
Local cross-platform machine translation GUI, based on CTranslate2

DesktopTranslator Local cross-platform machine translation GUI, based on CTranslate2 Download Windows Installer You can either download a ready-made W

Yasmin Moslem 29 Jan 05, 2023
Various Algorithms for Short Text Mining

Short Text Mining in Python Introduction This package shorttext is a Python package that facilitates supervised and unsupervised learning for short te

Kwan-Yuet 466 Dec 06, 2022
Adversarial Examples for Extreme Multilabel Text Classification

Adversarial Examples for Extreme Multilabel Text Classification The code is adapted from the source codes of BERT-ATTACK [1], APLC_XLNet [2], and Atte

1 May 14, 2022