iFlytek 超拟人语音合成 — 使用 iFlytek 超拟人语音合成 API,将文本合成自然、富有表现力的语音。支持 50+ 种音色。
Synthesize natural, expressive speech from text using iFlytek's Ultra-Realistic Voice Synthesis (超拟人语音合成) WebSocket API. Features human-like breathing, pauses, and emotional expression across 50+ voices.
Create an app at 讯飞控制台 with 超拟人语音合成 service enabled
Enable the desired voice(s) in the console (default: x5_lingyuzhao_flow / 聆玉昭)
Set environment variables: bash
export XFYUN_APP_ID="your_app_id"
export XFYUN_API_KEY="your_api_key"
export XFYUN_API_SECRET="your_api_secret"
bash
python3 scripts/tts.py "你好,欢迎使用科大讯飞语音合成。"
# → saves to output.mp3
bash
python3 scripts/tts.py "Hello, this is a test." --output hello.mp3
bash
python3 scripts/tts.py "大家好" --voice x6_lingfeiyi_pro --output greeting.mp3
bash
python3 scripts/tts.py --file article.txt --output article.mp3
bash
echo "流式文本输入测试" | python3 scripts/tts.py --output speech.mp3
bash
python3 scripts/tts.py "语速快一点" --speed 70 --volume 80 --pitch 60
bash
python3 scripts/tts.py "测试" --format pcm --sample-rate 16000 --output test.pcm
bash
python3 scripts/tts.py --list-voices
FlagShortDefaultDescriptiontextText to synthesize (positional)--file``-fRead text from a file--output``-o``output.mp3Output audio file path--voice``-v``x5_lingyuzhao_flowVoice name (vcn)--format``mp3Audio format: mp3, pcm, speex, opus--sample-rate``24000Sample rate: 8000, 16000, 24000--speed``50Speed 0–100 (50=normal, 100=2x)--volume``50Volume 0–100 (50=normal)--pitch``50Pitch 0–100 (50=normal)--bgs``0Background sound: 0=none, 1=bg1, 2=bg2--reg``0English pronunciation: 0=auto, 1=spell, 2=letter--rdn``0Number reading: 0=auto, 1=value, 2=string, 3=string-prefer--list-voicesPrint voice list and exit
VCNNameGenderLanguageScenex5_lingyuzhao_flow聆玉昭Female中文交互聊天x5_lingxiaotang_flow聆小糖Female中文语音助手x6_lingfeiyi_pro聆飞逸Male中文交互聊天x6_lingxiaoli_pro聆小璃Female中文交互聊天x6_pangbainan1_pro旁白男声Male中文旁白配音x6_pangbainv1_pro旁白女声Female中文旁白配音x6_lingfeihan_pro聆飞瀚Male中文纪录片x5_EnUs_Grant_flowGrantFemaleEnglish交互聊天x5_EnUs_Lila_flowLilaFemaleEnglish交互聊天x4_zijin_oral子津Male天津话交互聊天x4_ziyang_oral子阳Male东北话交互聊天
Run --list-voices for the complete list (50+ voices).
Insert [p500] in text for a 500ms pause:
text
你好[p500]科大讯飞
Use [=pinyin] after a character to force pronunciation:
text
着[=zhuo2]手
wss://cbm01.cn-huabei-1.xf-yun.com/v1/private/mcd9m97e6XFYUN_APP_ID, XFYUN_API_KEY, XFYUN_API_SECRETx4_*_oral) support oral configuration parameters (口语化), x5/x6 do not