EmotiVoice Documentation
repository·main·Indexed 27 days ago
https://github.com/netease-youdao/emotivoiceAn open-source, multi-voice, and prompt-controlled text-to-speech (TTS) engine supporting English and Chinese. EmotiVoice features emotional synthesis for controlling speech with emotions such as happy, sad, or angry. The project provides tools for finetuning models using datasets like DataBaker and LJSpeech, an OpenAI-compatible TTS API, a Streamlit interactive demo, and Docker deployment options.
What's inside EmotiVoice
- Speaker information for EmotiVoice is primarily sourced from the LibriTTS and HiFiTTS datasets. You can find detailed descriptions of available voices in the EmotiVoice 😊 wiki page. For additional speaker details, you can search for speaker names on LibriVox.
Download and extract LJSpeech data
mainDownload the LJSpeech-1.1 corpus and extract it into the
data/LJspeech/rawdirectory.mkdir data/LJspeech/raw # download wget -P data/LJspeech/raw http://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2 # extract tar -xjf data/LJspeech/raw/LJSpeech-1.1.tar.bz2 -C data/LJspeech/rawFull Installation via Conda and Pip
mainTo install EmotiVoice manually in a local environment, create a Conda environment with Python 3.8 and install the required dependencies:
conda create -n EmotiVoice python=3.8 -y conda activate EmotiVoice pip install torch torchaudio pip install numpy numba scipy transformers soundfile yacs g2p_en jieba pypinyin pypinyin_dict python -m nltk.downloader "averaged_perceptron_tagger_eng"Run EmotiVoice via Docker
mainThe fastest way to run EmotiVoice is using a Docker image. This requires a machine with an NVIDIA GPU and the NVIDIA container toolkit installed (for Linux or Windows WSL2).
To run the standard version with a web interface at
http://localhost:8501:docker run -dp 127.0.0.1:8501:8501 syq163/emoti-voice:latestTo run a version that includes the OpenAI-compatible TTS API at
http://localhost:8000:docker run -dp 127.0.0.1:8501:8501 -p 127.0.0.1:8000:8000 syq163/emoti-voice:latestFinetune the model
mainStart the joint training of the acoustic model and vocoder usingtorchrun. Checkpoints are saved inexp/LJspeech/ckpt. You can monitor progress using TensorBoard.Prepare Pretrained Model Files
mainEmotiVoice requires pretrained models. You can download them using Git LFS from HuggingFace or via ModelScope.
Option 1: HuggingFace (requires git-lfs)
git lfs install git lfs clone https://huggingface.co/WangZeJun/simbert-base-chinese WangZeJun/simbert-base-chineseOption 2: ModelScope
git clone https://www.modelscope.cn/syq163/WangZeJun.gitInstall EmotiVoice for training
mainTo finetune models using the LJSpeech recipe, create a Conda environment with Python 3.8 and install the package with the
[train]extra. You must also prepare pre-trained models as specified in the project documentation.conda create -n EmotiVoice python=3.8 -y conda activate EmotiVoice # Install via pip pip install EmotiVoice[train] # Or via git clone git clone https://github.com/netease-youdao/EmotiVoice pip install -e .[train]Configure environment and credentials for EmotiVoice API Demo
mainTo run the demo, ensure you meet the following requirements:
- Python Version: Python 3.6 or higher.
- API Credentials: You must obtain an Application ID (应用ID) and an Application Secret (应用密钥) from the Youdao Zhiyun official website.
- Parameter Configuration: Locate the code sections marked with Chinese prompts (中文提示) and fill in the required interface parameters. Specific parameter values can be found in the Youdao Zhiyun documentation.
Install EmotiVoice on Linux
mainFollow these steps to set up EmotiVoice in a Linux environment. This requires a GPU and CUDA installation.
Create a Conda environment (Python 3.8 is required):
conda create -n EmotiVoice python=3.8 conda init conda activate EmotiVoiceInstall git-lfs:
- Ubuntu:
sudo apt update sudo apt install git sudo apt-get install git-lfs - CentOS:
sudo yum update sudo yum install git sudo yum install git-lfs
- Ubuntu:
Clone the repository:
git lfs install git lfs clone https://github.com/netease-youdao/EmotiVoice.gitInstall dependencies:
pip install torch torchaudio pip install numpy numba scipy transformers soundfile yacs g2p_en jieba pypinyin pypinyin_dict python -m nltk.downloader "averaged_perceptron_tagger_eng"
conda create -n EmotiVoice python=3.8 conda init conda activate EmotiVoiceFinetune the EmotiVoice model
mainStart the training process using
torchrun. Checkpoints are saved inexp/DataBaker/ckpt. You can monitor training with TensorBoard using--logdir=exp/DataBaker.torchrun \ --nproc_per_node=1 \ --master_port 8008 \ train_am_vocoder_joint.py \ --config_folder exp/DataBaker/config \ --load_pretrained_model TrueInstall MFA (Montreal Forced Aligner) environment
mainFor the recommended alignment step, install the required Conda and Pip dependencies for MFA.
conda install -c conda-forge kaldi sox librosa biopython praatio tqdm requests colorama pyyaml pynini openfst baumwelch ngram postgresql -y pip install pgvector hdbscan montreal-forced-alignerRun the EmotiVoice Python API Demo
mainThis project provides Python examples for calling Youdao Zhiyun PaaS interfaces. You can quickly test the related API services by executing themainfunction within the project.