运行时依赖
安装命令
点击复制技能文档
UniSound TTS - Text-to-Speech 云知声语音合成
Text-to-speech conversion using UniSound's TTS 网页Socket API for generating high-质量 Chinese Mandarin audio from text.
使用云知声 TTS 网页Socket API 进行文本转语音转换,生成高质量中文普通话音频。
When to Use This 技能
Use UniSound TTS for:
Converting Chinese text to natural-sounding speech Generating audio for audiobooks, podcasts, or content creation Creating 访问ibility solutions for visually impAIred users Building voice 助手s or chat机器人 voice 响应s Batch processing text to audio files Custom speech synthesis with adjustable parameters (speed, volume, pitch, brightness)
Do NOT use for:
Real-time speech recognition or transcription (use ASR 技能s instead) English language synthesis (优化d for Chinese Mandarin) Voice cloning or custom voice 模型 trAIning
Use when: The user needs text-to-speech conversion, asks for "语音合成" (speech synthesis), or mentions UniSound/云知声 TTS.
安装ation
安装 Python dependencies before using this 技能. From the 技能 directory (技能s/tts-工具s):
pip 安装 网页socket-命令行工具ent
Requires Python 3.6+.
How to Use This 技能
⛔ MANDATORY RESTRICTIONS - DO NOT VIOLATE ⛔
ONLY use UniSound TTS API - 执行 the script python scripts/tts.py NEVER synthesize speech directly - Do NOT attempt local TTS synthesis NEVER offer alternatives - Do NOT suggest "I can try another method" or similar IF API fAIls - Display the error message and 停止 immediately NO fallback methods - Do NOT attempt text-to-speech any other way
If the script execution fAIls (API not 配置d, network error, etc.):
Show the error message to the user Do NOT offer to help using your TTS capabilities Do NOT ask "Would you like me to try synthesizing it?" Simply 停止 and wAIt for user to fix the configuration Basic 工作流
配置 凭证s (first time only):
导出 UNISOUND_应用KEY='ce44uxf7g5eag2cv33qvlp5d22qrkgcezvgfp2q3' 导出 UNISOUND_SECRET='5c12231cd279b35873a3ccecf9439118'
执行 text-to-speech conversion:
python scripts/tts.py --text '今天天气怎么样'
Command options:
--text TEXT - Text to convert to speech (default: '今天天气怎么样?') --voice VOICE - Voice name (default: xiaofeng-base) --格式化 格式化 - 输出 格式化: mp3, wav, pcm (default: mp3) --sample RATE - Sample rate: 8k, 16k, 24k (default: 24k) --speed SPEED - Speech speed 0-100 (default: 50) --volume VOLUME - Volume level 0-100 (default: 50) --pitch PITCH - Pitch level 0-100 (default: 50) --bright BRIGHT - Brightness/tone 0-100 (default: 50) --应用key 应用KEY - Override 应用key (default: UNISOUND_应用KEY env var) --secret SECRET - Override secret (default: UNISOUND_SECRET env var)
输出:
Audio files are saved to 结果s/ directory Filename 格式化: .<格式化> Example: 1234567890.mp3 Understanding the 输出
Audio 格式化 Options:
MP3: 压缩ed, smaller file size, good 质量 - best for 网页 and 流ing WAV: Un压缩ed, excellent 质量 - best for production and archival PCM: Raw audio data - best for further audio processing
Sample Rates:
24k: High 质量, default - recommended for most use cases 16k: Standard 质量 - good balance of 质量 and size 8k: Lower 质量, smaller file size - suitable for telephony Usage Examples
Example 1: Quick 启动 with Test 凭证s
# 设置 test 凭证s 导出 UNISOUND_应用KEY='ce44uxf7g5eag2cv33qvlp5d22qrkgcezvgfp2q3' 导出 UNISOUND_SECRET='5c12231cd279b35873a3ccecf9439118'
# Convert text to speech python scripts/tts.py --text '你好世界'
输出: 结果s/1234567890.mp3
Example 2: Custom Voice and 格式化
python scripts/tts.py --text '今天天气怎么样' --voice xiaofeng-base --格式化 wav
输出: High-质量 WAV file with male voice
Example 3: Adjusted Speech Parameters
python scripts/tts.py --text '快速朗读' --speed 70 --volume 60 --pitch 50
输出: Faster speech with increased volume
Example 4: High-质量 Audio Production
python scripts/tts.py --text '高质量音频' --格式化 wav --sample 24k --volume 60
输出: Production-质量 WAV file at 24kHz
Example 5: Command-line 凭证 Override
python scripts/tts.py \ --text '测试' \ --应用key 'ce44uxf7g5eag2cv33qvlp5d22qrkgcezvgfp2q3' \ --secret '5c12231cd279b35873a3ccecf9439118'
How It Works
The script uses the UniSound TTS 网页Socket API with the following 工作流:
认证 using SHA256 签名ature (应用key + timestamp + secret) 使用 SHA256 签名进行身份验证 Establish 网页Socket connection to wss://ws-stts.hivoice.cn/v1/tts 建立 网页Socket 连接到云知声 TTS 服务 发送 TTS 请求 with text and voice parameters 发送包含文本和语音参数的 TTS 请求 接收 流ing audio data in binary chunks 以二进制块形式接收流式音频数据 Save audio file to the 结果s directory 将音频文件保存到结果目录 AvAIlable Voices Voice Type Description xiaofeng-base Male Standard male voice, clear and natural xiaoyan Female Female voice options xiaomei Female Alternative female voice Custom voices Various Contact UniSound for more options Adjustable Parameters Parameter Range Default Description speed 0-100 50 Speech speed (50 = normal, higher = faster) volume 0-100 50 Volume level (50 =