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
This library is testing the ethics of language models by using natural adversarial texts.

prompt2slip This library is testing the ethics of language models by using natural adversarial texts. This tool allows for short and simple code and v

9 Dec 28, 2021
PIZZA - a task-oriented semantic parsing dataset

The PIZZA dataset continues the exploration of task-oriented parsing by introducing a new dataset for parsing pizza and drink orders, whose semantics cannot be captured by flat slots and intents.

17 Dec 14, 2022
Label data using HuggingFace's transformers and automatically get a prediction service

Label Studio for Hugging Face's Transformers Website • Docs • Twitter • Join Slack Community Transfer learning for NLP models by annotating your textu

Heartex 135 Dec 29, 2022
An easy-to-use framework for BERT models, with trainers, various NLP tasks and detailed annonations

FantasyBert English | 中文 Introduction An easy-to-use framework for BERT models, with trainers, various NLP tasks and detailed annonations. You can imp

Fan 137 Oct 26, 2022
Text editor on python tkinter to convert english text to other languages with the help of ployglot.

Transliterator Text Editor This is a simple transliteration program which is used to convert english word to phonetically matching word in another lan

Merin Rose Tom 1 Jan 16, 2022
A music comments dataset, containing 39,051 comments for 27,384 songs.

Music Comments Dataset A music comments dataset, containing 39,051 comments for 27,384 songs. For academic research use only. Introduction This datase

Zhang Yixiao 2 Jan 10, 2022
多语言降噪预训练模型MBart的中文生成任务

mbart-chinese 基于mbart-large-cc25 的中文生成任务 Input source input: text + /s + lang_code target input: lang_code + text + /s Usage token_ids_mapping.jso

11 Sep 19, 2022
Abhijith Neil Abraham 2 Nov 05, 2021
This converter will create the exact measure for your cappuccino recipe from the grandiose Rafaella Ballerini!

About CappuccinoJs This converter will create the exact measure for your cappuccino recipe from the grandiose Rafaella Ballerini! Este conversor criar

Arthur Ottoni Ribeiro 48 Nov 15, 2022
Datasets of Automatic Keyphrase Extraction

This repository contains 20 annotated datasets of Automatic Keyphrase Extraction made available by the research community. Following are the datasets and the original papers that proposed them. If yo

LIAAD - Laboratory of Artificial Intelligence and Decision Support 163 Dec 23, 2022
Wake: Context-Sensitive Automatic Keyword Extraction Using Word2vec

Wake Wake: Context-Sensitive Automatic Keyword Extraction Using Word2vec Abstract استخراج خودکار کلمات کلیدی متون کوتاه فارسی با استفاده از word2vec ب

Omid Hajipoor 1 Dec 17, 2021
FewCLUE: 为中文NLP定制的小样本学习测评基准

FewCLUE: 为中文NLP定制的小样本学习测评基准

CLUE benchmark 387 Jan 04, 2023
超轻量级bert的pytorch版本,大量中文注释,容易修改结构,持续更新

bert4pytorch 2021年8月27更新: 感谢大家的star,最近有小伙伴反映了一些小的bug,我也注意到了,奈何这个月工作上实在太忙,更新不及时,大约会在9月中旬集中更新一个只需要pip一下就完全可用的版本,然后会新添加一些关键注释。 再增加对抗训练的内容,更新一个完整的finetune

muqiu 317 Dec 18, 2022
OpenChat: Opensource chatting framework for generative models

OpenChat is opensource chatting framework for generative models.

Hyunwoong Ko 427 Jan 06, 2023
Watson Natural Language Understanding and Knowledge Studio

Material de demonstração dos serviços: Watson Natural Language Understanding e Knowledge Studio Visão Geral: https://www.ibm.com/br-pt/cloud/watson-na

Vanderlei Munhoz 4 Oct 24, 2021
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
GPT-2 Model for Leetcode Questions in python

Leetcode using AI 🤖 GPT-2 Model for Leetcode Questions in python New demo here: https://huggingface.co/spaces/gagan3012/project-code-py Note: the Ans

Gagan Bhatia 100 Dec 12, 2022
Input english text, then translate it between languages n times using the Deep Translator Python Library.

mass-translator About Input english text, then translate it between languages n times using the Deep Translator Python Library. How to Use Install dep

2 Mar 04, 2022
Summarization, translation, sentiment-analysis, text-generation and more at blazing speed using a T5 version implemented in ONNX.

Summarization, translation, Q&A, text generation and more at blazing speed using a T5 version implemented in ONNX. This package is still in alpha stag

Abel 211 Dec 28, 2022