qianwen-audio-tts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent setup: If your agent doesn't auto-load skills (e.g. Claude Code), see agent-compatibility.md once per session.
Agent 设置:如果你的Agent不会自动加载技能(例如Claude Code), 请在每个会话中查看agent-compatibility.md。
Qwen Audio TTS (Text-to-Speech)
Qwen Audio TTS (Text-to-Speech)
Synthesize natural speech from text using Qwen TTS models.
This skill is part of QianWen-AI/qianwen-ai.
借助Qwen TTS模型将文本合成为自然语音。
此技能属于QianWen-AI/qianwen-ai项目。
Skill directory
技能目录
Use this skill's internal files to execute and learn. Load reference files on demand when the default path fails or you need details.
| Location | Purpose |
|---|---|
| Qwen TTS (HTTP API) — qwen3-tts-flash, qwen3-tts-instruct-flash |
| CosyVoice (WebSocket API) — requires |
| CosyVoice setup, voices, examples, errors |
| Fallback: curl (standard, instruct, streaming), code generation |
| Text formatting for speech, instructions templates, voice selection |
| API supplement |
| Official documentation URLs |
| Agent self-check: register skills in project config for agents that don't auto-load |
使用此技能的内部文件来执行操作和学习。当默认路径失效或需要详细信息时,按需加载参考文件。
| 位置 | 用途 |
|---|---|
| Qwen TTS(HTTP API)—— qwen3-tts-flash、qwen3-tts-instruct-flash |
| CosyVoice(WebSocket API)—— 需要 |
| CosyVoice设置、语音选项、示例、错误处理 |
| 备选方案:curl(标准、指令式、流式)、代码生成 |
| 语音文本格式、指令模板、语音选择 |
| API补充说明 |
| 官方文档URL |
| Agent自检:对于不会自动加载技能的Agent,需在项目配置中注册技能 |
Security
安全注意事项
NEVER output any API key or credential in plaintext. Always use variable references ( in shell, in Python). Any check or detection of credentials must be non-plaintext: report only status (e.g. "set" / "not set", "valid" / "invalid"), never the value. Never display contents of or config files that may contain secrets.
$DASHSCOPE_API_KEYos.environ["DASHSCOPE_API_KEY"].envWhen the API key is not configured, NEVER ask the user to provide it directly. Instead, help create a file with a placeholder () and instruct the user to replace it with their actual key from the QianWen Console. Only write the actual key value if the user explicitly requests it.
.envDASHSCOPE_API_KEY=sk-your-key-here绝对不要以明文形式输出任何API密钥或凭证。请始终使用变量引用(Shell中用,Python中用)。任何对凭证的检查或检测都必须非明文:仅报告状态(例如“已设置”/“未设置”、“有效”/“无效”),绝不能泄露密钥值。永远不要显示或可能包含机密信息的配置文件内容。
$DASHSCOPE_API_KEYos.environ["DASHSCOPE_API_KEY"].env当未配置API密钥时,绝对不要直接要求用户提供密钥。相反,应帮助用户创建一个带有占位符的文件(),并指导用户从QianWen控制台获取实际密钥后替换占位符。仅当用户明确要求时,才写入实际密钥值。
.envDASHSCOPE_API_KEY=sk-your-key-hereKey Compatibility
密钥兼容性
Scripts require a standard QianWen API key (). Token Plan 团队版 keys () target a different endpoint () and do not include TTS models. Standard key required for TTS. The script detects keys at startup and prints a warning. If qianwen-ops-auth is installed, see its for full details.
sk-...sk-sp-...token-plan.cn-beijing.maas.aliyuncs.comsk-sk-sp-references/tokenplan.md脚本需要标准QianWen API密钥(格式)。Token Plan团队版密钥(格式)针对不同的端点(),且不包含TTS模型。使用TTS必须使用标准的格式密钥。脚本在启动时会检测格式的密钥并打印警告。如果已安装qianwen-ops-auth,请查看其获取详细信息。
sk-...sk-sp-...token-plan.cn-beijing.maas.aliyuncs.comsk-sk-sp-references/tokenplan.mdModel Selection
模型选择
Qwen TTS (HTTP API) — use scripts/tts.py
scripts/tts.pyQwen TTS(HTTP API)—— 使用scripts/tts.py
scripts/tts.py| Model | Use Case | Notes |
|---|---|---|
| Recommended (standard) — fast, multi-language | Cost-effective, widely available |
| Instruction-guided style control | Tone/emotion via instructions |
| 模型 | 使用场景 | 说明 |
|---|---|---|
| 推荐(标准款)——快速、多语言 | 性价比高、广泛可用 |
| 指令引导的风格控制 | 通过指令调整语气/情感 |
CosyVoice (WebSocket API) — use scripts/tts_cosyvoice.py
scripts/tts_cosyvoice.pyCosyVoice(WebSocket API)—— 使用scripts/tts_cosyvoice.py
scripts/tts_cosyvoice.py| Model | Use Case |
|---|---|
| High quality, fast |
| Highest quality |
Note: CosyVoice requiresSDK and uses different voices. See cosyvoice-guide.md.dashscope
- User specified a model → use the appropriate script:
- →
qwen3-tts-*scripts/tts.py - →
cosyvoice-*scripts/tts_cosyvoice.py
- Consult the qianwen-model-selector skill when model choice depends on capability, scenario, or pricing.
- No signal, clear task → via
qwen3-tts-flash(default for standard tasks).tts.py
⚠️ Important: The model list above is a point-in-time snapshot and may be outdated. Model availability changes frequently. Always check the official model list for the authoritative, up-to-date catalog before making model decisions.
Model details: For more information about a specific model, direct the user to its detail page:(replacehttps://www.qianwenai.com/models/<model-name>with the exact model ID, e.g.<model-name>→ https://www.qianwenai.com/models/qwen3-tts-flash). NEVER modify or guess the model name in the URL.qwen3-tts-flash
Dynamic model queries: If the qianwen-model-selector skill or QianWen CLI () is available, use it for real-time model data. CLI requires authentication — see the qianwen-usage skill for login flow.qianwen models info <model>
| 模型 | 使用场景 |
|---|---|
| 高质量、快速 |
| 最高质量 |
注意:CosyVoice需要SDK,且使用不同的语音选项。请查看cosyvoice-guide.md。dashscope
- 用户指定模型 → 使用对应的脚本:
- →
qwen3-tts-*scripts/tts.py - →
cosyvoice-*scripts/tts_cosyvoice.py
- 当模型选择取决于能力、场景或定价时,请咨询qianwen-model-selector技能。
- 无指定模型但任务明确 → 通过使用
tts.py(标准任务的默认选择)。qwen3-tts-flash
⚠️ 重要提示:上述模型列表是当前时间点的快照,可能已过时。模型可用性会频繁变化。在做出模型选择前,请务必查看官方模型列表获取权威的最新目录。
模型详情:如需了解特定模型的更多信息,请引导用户访问其详情页面:(将https://www.qianwenai.com/models/<model-name>替换为确切的模型ID,例如<model-name>→ https://www.qianwenai.com/models/qwen3-tts-flash)。绝对不要修改或猜测URL中的模型名称。qwen3-tts-flash
动态模型查询:如果qianwen-model-selector技能或QianWen CLI()可用,请使用它们获取实时模型数据。CLI需要身份验证——请查看qianwen-usage技能了解登录流程。qianwen models info <model>
Available Voices
可用语音
| Voice | Description | Script |
|---|---|---|
| Cherry, Ethan, Serena | Qwen TTS system voices | |
| longanyang, longanhuan, longhuhu_v3 | CosyVoice verified voices | |
Full lists: api-guide.md (Qwen TTS) · cosyvoice-guide.md (CosyVoice)
| 语音 | 描述 | 脚本 |
|---|---|---|
| Cherry, Ethan, Serena | Qwen TTS系统语音 | |
| longanyang, longanhuan, longhuhu_v3 | CosyVoice认证语音 | |
完整列表:api-guide.md(Qwen TTS)· cosyvoice-guide.md(CosyVoice)
Execution
执行说明
⚠️ Multiple artifacts: When generating multiple files in a single session, you MUST append a numeric suffix to each filename (e.g.,out_1.wav) to prevent overwrites.out_2.wav
⚠️ 多文件生成:当在单个会话中生成多个文件时,必须为每个文件名添加数字后缀(例如、out_1.wav)以防止覆盖。out_2.wav
Qwen TTS (HTTP API) — tts.py
tts.pyQwen TTS(HTTP API)—— tts.py
tts.pyPrerequisites
前置条件
- API Key: Check that (or
DASHSCOPE_API_KEY) is set using a non-plaintext check only (e.g. in shell:QIANWEN_API_KEY; report only "set" or "not set", never the key value). If not set: run the qianwen-ops-auth skill if available; otherwise guide the user to obtain a key from QianWen Console and set it via[ -n "$DASHSCOPE_API_KEY" ]file (.envin project root or current directory) or environment variable. The script searches forecho 'DASHSCOPE_API_KEY=sk-your-key-here' >> .envin the current working directory and the project root. Skills may be installed independently — do not assume qianwen-ops-auth is present..env - Python 3.9+ (stdlib only, no pip install needed)
- API密钥:仅通过非明文方式检查(或
DASHSCOPE_API_KEY)是否已设置(例如在Shell中:QIANWEN_API_KEY;仅报告“已设置”或“未设置”,绝不能泄露密钥值)。如果未设置:如果qianwen-ops-auth技能可用,则运行该技能;否则引导用户从QianWen控制台获取密钥,并通过[ -n "$DASHSCOPE_API_KEY" ]文件(在项目根目录或当前目录执行.env)或环境变量进行设置。脚本会在当前工作目录和项目根目录中查找echo 'DASHSCOPE_API_KEY=sk-your-key-here' >> .env文件。技能可能独立安装——不要假设qianwen-ops-auth已存在。.env - Python 3.9+(仅需标准库,无需pip安装)
Environment Check
环境检查
Before first execution, verify Python is available:
bash
python3 --version # must be 3.9+If is not found, try or . If Python is unavailable or below 3.9, skip to Path 2 (curl) in execution-guide.md.
python3python --versionpy -3 --version首次执行前,验证Python是否可用:
bash
python3 --version # 必须为3.9+如果找不到,尝试或。如果Python不可用或版本低于3.9,请跳转到execution-guide.md中的路径2(curl)。
python3python --versionpy -3 --versionDefault: Run Script
默认方式:运行脚本
Script path: Scripts are in the subdirectory of this skill's directory (the directory containing this SKILL.md). You MUST first locate this skill's installation directory, then ALWAYS use the full absolute path to execute scripts. Do NOT assume scripts are in the current working directory. Do NOT use to switch directories before execution.
scripts/cdExecution note: Run all scripts in the foreground — wait for stdout; do not background.
Discovery: Run first to see all available arguments.
python3 <this-skill-dir>/scripts/tts.py --helpbash
python3 <this-skill-dir>/scripts/tts.py \
--request '{"text":"Hello, this is a test.","voice":"Cherry"}' \
--output output/qianwen-audio-tts/ \
--print-response| Argument | Description |
|---|---|
| JSON request body |
| Load request from file |
| Save audio and response JSON to directory |
| Print response to stdout |
| Override model |
| Override voice |
脚本路径:脚本位于此技能目录(包含此SKILL.md的目录)的子目录中。必须先找到此技能的安装目录,然后始终使用完整绝对路径执行脚本。不要假设脚本在当前工作目录中。执行前不要使用切换目录。
scripts/cd执行注意:所有脚本都要在前台运行——等待标准输出;不要后台运行。
查看帮助:先运行查看所有可用参数。
python3 <this-skill-dir>/scripts/tts.py --helpbash
python3 <this-skill-dir>/scripts/tts.py \
--request '{"text":"Hello, this is a test.","voice":"Cherry"}' \
--output output/qianwen-audio-tts/ \
--print-response| 参数 | 描述 |
|---|---|
| JSON请求体 |
| 从文件加载请求 |
| 将音频和响应JSON保存到指定目录 |
| 将响应打印到标准输出 |
| 覆盖默认模型 |
| 覆盖默认语音 |
Verify Result
验证结果
- Exit code + output contains valid JSON with
0field → successoutput.audio - Non-zero exit, HTTP error, empty response, or error JSON → fail
- Post-execution check: Verify the output audio file exists and has non-zero size ()
ls -la <output_dir> - MANDATORY — stderr signal check: After confirming the result, scan the command's stderr output for or
[ACTION_REQUIRED]. If either signal is present, you MUST follow the instructions in Update Check below before responding to the user.[UPDATE_AVAILABLE]
- 退出码+ 输出包含带有
0字段的有效JSON → 成功output.audio - 非零退出码、HTTP错误、空响应或错误JSON → 失败
- 执行后检查:验证输出音频文件是否存在且大小非零()
ls -la <output_dir> - 必须执行——标准错误信号检查:确认结果后,扫描命令的标准错误输出中是否包含或
[ACTION_REQUIRED]。如果存在其中任一信号,必须按照下面更新检查中的说明操作后再回复用户。[UPDATE_AVAILABLE]
On Failure
失败处理
If the script fails, match the error output against the diagnostic table below to determine the resolution. If no match, read execution-guide.md for alternative paths: curl commands (Path 2 — standard, instruct, streaming), code generation (Path 3), and autonomous resolution (Path 5).
If Python is not available at all → skip directly to Path 2 (curl) in execution-guide.md.
如果脚本执行失败,请将错误输出与下面的诊断表匹配以确定解决方案。如果无匹配项,请阅读execution-guide.md了解备选路径:curl命令(路径2——标准、指令式、流式)、代码生成(路径3)和自主解决(路径5)。
如果完全没有Python环境 → 直接跳转到execution-guide.md中的路径2(curl)。
CosyVoice — tts_cosyvoice.py
tts_cosyvoice.pyCosyVoice —— tts_cosyvoice.py
tts_cosyvoice.pyCosyVoice requires SDK. Quick start:
dashscopebash
pip install dashscope>=1.24.6
python3 <this-skill-dir>/scripts/tts_cosyvoice.py --text "Hello"Full guide: cosyvoice-guide.md (setup, voices, examples, errors)
| Error Pattern | Diagnosis | Resolution |
|---|---|---|
| Python not on PATH | Try |
| Script version check failed | Upgrade Python to 3.9+ |
| Python < 3.9 | Upgrade Python to 3.9+ |
| Missing API key | Obtain key from QianWen Console; add to |
| Invalid or mismatched key | Run qianwen-ops-auth (non-plaintext check only); verify key is valid |
| SSL cert issue (proxy/corporate) | macOS: run |
| Network unreachable | Check internet; set |
| Rate limited | Wait and retry with backoff |
| Server error | Retry with backoff |
| Can't write output | Use |
CosyVoice需要 SDK。快速开始:
dashscopebash
pip install dashscope>=1.24.6
python3 <this-skill-dir>/scripts/tts_cosyvoice.py --text "Hello"完整指南:cosyvoice-guide.md(设置、语音选项、示例、错误处理)
| 错误模式 | 诊断 | 解决方案 |
|---|---|---|
| Python不在PATH中 | 尝试 |
| 脚本版本检查失败 | 将Python升级到3.9+ |
| Python版本低于3.9 | 将Python升级到3.9+ |
| 缺少API密钥 | 从QianWen控制台获取密钥;添加到 |
| 密钥无效或不匹配 | 如果可用则运行qianwen-ops-auth技能(仅非明文检查);验证密钥是否有效 |
| SSL证书问题(代理/企业环境) | macOS:运行 |
| 网络不可达 | 检查网络;如果在代理后设置 |
| 请求频率受限 | 等待后重试并使用退避策略 |
| 服务器错误 | 等待后重试并使用退避策略 |
| 无法写入输出 | 使用 |
Quick Reference
快速参考
Request Fields
请求字段
| Field | Type | Description |
|---|---|---|
| string | Required — text to synthesize (max 600 chars) |
| string | Required — voice ID (e.g. |
| string | Model ID (default: |
| string | |
| string | Tone/style instructions (instruct model only) |
| bool | Enable streaming (Base64 chunks) |
| 字段 | 类型 | 描述 |
|---|---|---|
| string | 必填——待合成的文本(最多600字符) |
| string | 必填——语音ID(例如 |
| string | 模型ID(默认: |
| string | |
| string | 语气/风格指令(仅适用于指令式模型) |
| bool | 启用流式传输(Base64分块) |
Response Fields
响应字段
| Field | Description |
|---|---|
| URL of generated audio (valid 24h) |
| Format (e.g. wav) |
| Sample rate (e.g. 24000) |
| Character usage |
| 字段 | 描述 |
|---|---|
| 生成的音频URL(有效期24小时) |
| 音频格式(例如wav) |
| 采样率(例如24000) |
| 字符使用量 |
Important Notes
重要说明
- text: Max 600 characters per request.
- instructions: Only works with .
qwen3-tts-instruct-flash - language_type: for mixed language; specify for better pronunciation.
Auto - audio_url: Valid for 24 hours — download promptly.
- Real-time/streaming TTS: For WebSocket-based real-time TTS (CosyVoice, qwen3-tts-flash-realtime), a WebSocket client is required. This skill covers the HTTP-based non-real-time API. For real-time streaming use cases, refer to the official docs in sources.md.
- text:每个请求最多600字符。
- instructions:仅适用于模型。
qwen3-tts-instruct-flash - language_type:混合语言使用;指定语言可获得更好的发音效果。
Auto - audio_url:有效期24小时——请及时下载。
- 实时/流式TTS:对于基于WebSocket的实时TTS(CosyVoice、qwen3-tts-flash-realtime),需要WebSocket客户端。此技能覆盖基于HTTP的非实时API。如需实时流式传输用例,请参考sources.md中的官方文档。
Cross-Skill Chaining
跨技能联动
When passing generated audio to another skill (e.g., video-gen audio overlay):
- Pass directly — scripts detect URL prefixes and pass through without re-upload
audio_url - Use only for local playback or non-API operations
audio_file
当将生成的音频传递给其他技能(例如视频生成的音频叠加)时:
- 直接传递——脚本会检测URL前缀并直接传递,无需重新上传
audio_url - 仅在本地播放或非API操作时使用
audio_file
Error Handling
错误处理
| Error | Cause | Action |
|---|---|---|
| Invalid or missing API key | Run qianwen-ops-auth if available; else prompt user to set key (non-plaintext check only) |
| Invalid parameters (missing text/voice) | Validate request body |
| Rate limit or server error | Retry with backoff |
Usage & billing: Use the qianwen-usage skill to check usage, free tier quota, and billing directly. Alternatively, the user can visit the QianWen console: Usage Analytics | Pay-as-you-go Billing | Token Plan 团队版 SubscriptionNEVER fabricate, guess, or construct usage/billing/console URLs. Only provide the exact links listed in this skill. If a URL is not listed here, do not invent one.
| 错误 | 原因 | 操作 |
|---|---|---|
| API密钥无效或缺失 | 如果可用则运行qianwen-ops-auth技能;否则提示用户设置密钥(仅非明文检查) |
| 参数无效(缺少text/voice) | 验证请求体 |
| 请求频率受限或服务器错误 | 等待后重试并使用退避策略 |
绝对不要编造、猜测或构建使用/计费/控制台URL。仅提供此技能中列出的准确链接。如果此处未列出URL,不要自行创建。
Output Location
输出位置
Prefer the current working directory. Default subdirectory: .
./output/qianwen-audio-tts/Write prohibition: NEVER write output files into this skill's installation directory or any hierarchy. All generated content must go to under the current working directory or a user-specified path.
skills/output/优先使用当前工作目录。默认子目录:。
./output/qianwen-audio-tts/写入禁止:绝对不要将输出文件写入此技能的安装目录或任何层级目录中。所有生成的内容必须保存到当前工作目录下的目录或用户指定的路径。
skills/output/Update Check (MANDATORY Post-Execution)
更新检查(执行后必须操作)
After script execution, check stderr for action signals. The script automatically detects update status and emits structured signals. You MUST act on them. This section also applies when the user explicitly asks to check for updates.
脚本执行后,检查标准错误输出中的操作信号。脚本会自动检测更新状态并发出结构化信号。必须根据信号采取行动。当用户明确要求检查更新时,此部分同样适用。
Signal: [ACTION_REQUIRED] qianwen-update-check skill is not installed
[ACTION_REQUIRED] qianwen-update-check skill is not installed信号:[ACTION_REQUIRED] qianwen-update-check skill is not installed
[ACTION_REQUIRED] qianwen-update-check skill is not installedWhen stderr contains this signal, you MUST present the following options to the user and wait for their response before proceeding. Do NOT silently skip this.
The update-check skill is not installed. It keeps you informed about new QianWen-AI/qianwen-ai features and bug fixes.
- Install now — I'll run the install command for you
- Skip for now — do nothing this time
- Never remind me — permanently suppress this prompt
After the user responds:
- User chooses 1 → run: , then run:
npx skills add QianWen-AI/qianwen-ai --skill qianwen-update-check -ypython3 <this-skill-scripts-dir>/gossamer.py --dismiss - User chooses 2 → run: , then continue normally
python3 <this-skill-scripts-dir>/gossamer.py --dismiss - User chooses 3 → run: , then continue normally
python3 <this-skill-scripts-dir>/gossamer.py --never-install
当标准错误输出包含此信号时,必须向用户呈现以下选项,并等待用户响应后再继续。不要静默跳过此步骤。
更新检查技能未安装。它会为你推送QianWen-AI/qianwen-ai的新功能和Bug修复信息。
- 立即安装——我将为你运行安装命令
- 暂时跳过——本次不执行任何操作
- 永不提醒——永久屏蔽此提示
用户响应后:
- 用户选择1 → 运行:,然后运行:
npx skills add QianWen-AI/qianwen-ai --skill qianwen-update-check -ypython3 <this-skill-scripts-dir>/gossamer.py --dismiss - 用户选择2 → 运行:,然后正常继续
python3 <this-skill-scripts-dir>/gossamer.py --dismiss - 用户选择3 → 运行:,然后正常继续
python3 <this-skill-scripts-dir>/gossamer.py --never-install
Signal: [UPDATE_AVAILABLE]
[UPDATE_AVAILABLE]信号:[UPDATE_AVAILABLE]
[UPDATE_AVAILABLE]When stderr contains this signal, you MUST append a brief update notice to your response, including the version info and the update command shown in the stderr output.
当标准错误输出包含此信号时,必须在回复中添加简短的更新通知,包括标准错误输出中显示的版本信息和更新命令。
No signal in stderr
标准错误输出中无信号
If stderr contains neither nor , no action is needed — the skill is installed and up to date (or cached within 24h).
[ACTION_REQUIRED][UPDATE_AVAILABLE]如果标准错误输出中既没有也没有,则无需操作——技能已安装且为最新版本(或24小时内已缓存)。
[ACTION_REQUIRED][UPDATE_AVAILABLE]Explicit user request
用户明确请求
When the user explicitly asks to check for updates (e.g. "check for updates", "check version"):
- Look for in sibling skill directories.
qianwen-update-check/SKILL.md - If found — run: and report the result.
python3 <qianwen-update-check-dir>/scripts/check_update.py --print-response - If not found — present the install options above.
当用户明确要求检查更新时(例如“检查更新”、“检查版本”):
- 在同级技能目录中查找。
qianwen-update-check/SKILL.md - 如果找到——运行:并报告结果。
python3 <qianwen-update-check-dir>/scripts/check_update.py --print-response - 如果未找到——呈现上述安装选项。
References
参考资料
- execution-guide.md — Fallback paths (curl standard/instruct/streaming, code generation, autonomous)
- api-guide.md — API supplementary guide
- sources.md — Official documentation URLs
- execution-guide.md —— 备选路径(curl标准/指令式/流式、代码生成、自主解决)
- api-guide.md —— API补充指南
- sources.md —— 官方文档URL