AISHELL-3: A Multi-speaker Mandarin TTS Corpus and the Baselines
Paper • 2010.11567 • Published
How to use writeAPoemForYou/piper-voices-zh-AISHELL-3 with Piper:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
A standard Piper multi-speaker Mandarin (zh_CN) voice, trained on
AISHELL-3.
zh_CN (Chinese, China)pinyin (g2pW polyphone disambiguation) — phoneme_type=pinyinSSB0033)Note:
espeakis not used at inference for Chinese. Piper's pinyin frontend downloads the g2pW model automatically (fromrhasspy/piper-checkpointszh/zh_CN/_resources/g2pw.tar.gz) on first use.
zh/zh_CN/cn_aishell3/medium/
zh_CN-cn_aishell3-medium.onnx
zh_CN-cn_aishell3-medium.onnx.json
Checkpoint + config: https://huggingface.co/datasets/writeAPoemForYou/piper-checkpoints-zh-AISHELL-3
pip install piper-tts # provides `python -m piper`
pip install -U "huggingface_hub[cli]"
hf download writeAPoemForYou/piper-voices-zh-AISHELL-3 \
zh/zh_CN/cn_aishell3/medium/zh_CN-cn_aishell3-medium.onnx \
zh/zh_CN/cn_aishell3/medium/zh_CN-cn_aishell3-medium.onnx.json \
--local-dir cn_aishell3
python -m piper \
--model cn_aishell3/zh_CN-cn_aishell3-medium.onnx \
--speaker SSB0033 \
-f out.wav \
-i "这是一本书。"
import wave
from pathlib import Path
import numpy as np
from piper import PiperVoice
from piper.config import SynthesisConfig
MODEL_DIR = Path("cn_aishell3")
voice = PiperVoice.load(
MODEL_DIR / "zh_CN-cn_aishell3-medium.onnx",
download_dir=MODEL_DIR, # where g2pW is cached/downloaded
)
# multi-speaker: pick a speaker (0..173, or the name in speaker_id_map)
syn = SynthesisConfig(speaker_id=0) # 0 == "SSB0033"
chunks = list(voice.synthesize("这是一本书。", syn_config=syn))
audio = np.concatenate([c.audio_float_array for c in chunks])
sr = chunks[0].sample_rate
with wave.open("out.wav", "wb") as w:
w.setnchannels(1)
w.setsampwidth(2)
w.setframerate(sr)
w.writeframes((np.clip(audio, -1, 1) * 32767).astype(np.int16).tobytes())
print("wrote out.wav", audio.shape, sr)
zh_CN-cn_aishell3-medium.onnx.json → speaker_id_map maps the original
AISHELL-3 speaker codes (e.g. SSB0033) to ids 0..173.
en_US/libritts_r (medium) and fine-tuned on AISHELL-3.@inproceedings{AISHELL-3_2020,
title={AISHELL-3: A Multi-speaker Mandarin TTS Corpus and the Baselines},
author={Yao Shi, Hui Bu, Xin Xu, Shaoji Zhang, Ming Li},
year={2015},
url={https://arxiv.org/abs/2010.11567}
}