piper-voices-zh-AISHELL-3 (cn_aishell3, medium)
A standard Piper multi-speaker Mandarin (zh_CN) voice, trained on
AISHELL-3.
- Language:
zh_CN(Chinese, China) - Frontend:
pinyin(g2pW polyphone disambiguation) —phoneme_type=pinyin - Speakers: 174 (ids/names are the original AISHELL-3 speaker codes, e.g.
SSB0033) - Quality: medium (22,050 Hz)
- This is a standard Piper ONNX voice.
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.
Files
zh/zh_CN/cn_aishell3/medium/
zh_CN-cn_aishell3-medium.onnx
zh_CN-cn_aishell3-medium.onnx.json
Training checkpoint
Checkpoint + config: https://huggingface.co/datasets/writeAPoemForYou/piper-checkpoints-zh-AISHELL-3
Install
pip install piper-tts # provides `python -m piper`
Download this voice
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
Inference (CLI)
python -m piper \
--model cn_aishell3/zh_CN-cn_aishell3-medium.onnx \
--speaker SSB0033 \
-f out.wav \
-i "这是一本书。"
Inference (Python, verified)
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)
Speakers
zh_CN-cn_aishell3-medium.onnx.json → speaker_id_map maps the original
AISHELL-3 speaker codes (e.g. SSB0033) to ids 0..173.
Dataset / License
- Dataset: AISHELL-3 — https://www.openslr.org/93/
- License: Apache License v.2.0
- Warm-started from
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}
}