Azure Speech TTS
Use Azure Speech to turn text or SSML into a local audio file under download/.
What this skill does
- - Synthesize plain text into speech
- Synthesize full SSML payloads directly
- Choose voice, output format, rate, pitch, style, and role
- Save the result as a local audio file and print a JSON summary
Configuration
This skill uses a small default config file plus environment variables.
Default config file
File:
Default values:
- -
default_voice: INLINECODE3 - INLINECODE4 : INLINECODE5
- INLINECODE6 : INLINECODE7
- INLINECODE8 : INLINECODE9
Secret values
Set these in the local shell environment:
- - INLINECODE10
- INLINECODE11
Optional environment overrides
- - INLINECODE12
- INLINECODE13
Precedence
Use this order:
- 1. CLI flag
- Environment variable
- INLINECODE14
- Built-in fallback
Quick start
CODEBLOCK0
For SSML:
CODEBLOCK1
Workflow
- 1. Decide whether the input is plain text or full SSML.
- Use
--text / --text-file for normal narration. - Use
--ssml / --ssml-file only when the payload already contains a complete <speak> document. - Pick the voice and output format, or let
config.json supply the defaults. - Run
scripts/azure_tts.py. - Return the generated audio path to the user.
Rules
- - Prefer plain text unless the user needs pauses, emphasis, multi-voice content, or expressive styling.
- INLINECODE22 input must include a full
<speak> root element. - Default voice is
zh-CN-Yunqi:DragonHDOmniLatestNeural if nothing else is set. - Default output folder is
download/. - If the user does not specify format, use the default MP3 output.
- Do not put secrets in
config.json.
Common formats
See references/azure-speech-cheatsheet.md for the format map and examples.
Short aliases supported by the script:
- - INLINECODE28
- INLINECODE29
- INLINECODE30
- INLINECODE31
Useful options
- -
--voice: Azure voice name, for example INLINECODE33 - INLINECODE34 : SSML
xml:lang for plain-text mode - INLINECODE36 : speaking rate, for example INLINECODE37
- INLINECODE38 : pitch adjustment, for example INLINECODE39
- INLINECODE40 : expressive style such as
cheerful, sad, INLINECODE43 - INLINECODE44 : strength of the expressive style
- INLINECODE45 : voice role when supported
- INLINECODE46 : write the generated SSML to a file for inspection
- INLINECODE47 : print the generated SSML without calling Azure
Output
The helper script writes the audio file and prints JSON like:
CODEBLOCK2
Use the printed output_path as the deliverable path.
Azure Speech TTS
使用 Azure Speech 将文本或 SSML 转换为 download/ 目录下的本地音频文件。
技能功能
- - 将纯文本合成为语音
- 直接合成完整的 SSML 负载
- 选择语音、输出格式、语速、音调、风格和角色
- 将结果保存为本地音频文件并输出 JSON 摘要
配置
本技能使用一个小型默认配置文件加环境变量。
默认配置文件
文件:
默认值:
- - defaultvoice:zh-CN-Yunqi:DragonHDOmniLatestNeural
- defaultformat:mp3
- defaultoutputdir:download
- defaulttimeoutseconds:60
密钥值
在本地 shell 环境中设置:
- - AZURESPEECHKEY
- AZURESPEECHREGION
可选环境变量覆盖
- - AZURESPEECHVOICE
- AZURESPEECHFORMAT
优先级
按以下顺序使用:
- 1. CLI 标志
- 环境变量
- config.json
- 内置默认值
快速开始
bash
python3 scripts/azure_tts.py \
--text 你好,这是一段测试语音。 \
--voice zh-CN-Yunqi:DragonHDOmniLatestNeural \
--format mp3 \
--output download/test.mp3
对于 SSML:
bash
python3 scripts/azure_tts.py \
--ssml-file temp/input.ssml \
--format wav \
--output download/test.wav
工作流程
- 1. 判断输入是纯文本还是完整 SSML。
- 使用 --text / --text-file 进行普通叙述。
- 仅在负载已包含完整 文档时使用 --ssml / --ssml-file。
- 选择语音和输出格式,或让 config.json 提供默认值。
- 运行 scripts/azure_tts.py。
- 将生成的音频路径返回给用户。
规则
- - 除非用户需要停顿、强调、多语音内容或表现力风格,否则优先使用纯文本。
- --ssml 输入必须包含完整的 根元素。
- 如果未设置其他值,默认语音为 zh-CN-Yunqi:DragonHDOmniLatestNeural。
- 默认输出文件夹为 download/。
- 如果用户未指定格式,则使用默认的 MP3 输出。
- 不要将密钥放在 config.json 中。
常见格式
格式映射和示例请参见 references/azure-speech-cheatsheet.md。
脚本支持的短别名:
实用选项
- - --voice:Azure 语音名称,例如 en-US-AriaNeural
- --language:纯文本模式的 SSML xml:lang
- --rate:语速,例如 +10%
- --pitch:音调调整,例如 +2st
- --style:表现力风格,如 cheerful、sad、chat
- --style-degree:表现力风格的强度
- --role:支持的语音角色
- --save-ssml:将生成的 SSML 写入文件以供检查
- --dry-run:打印生成的 SSML 而不调用 Azure
输出
辅助脚本会写入音频文件并输出类似以下的 JSON:
json
{
ok: true,
output_path: download/test.mp3,
format: audio-24khz-48kbitrate-mono-mp3,
voice: zh-CN-Yunqi:DragonHDOmniLatestNeural,
language: zh-CN,
bytes: 123456
}
使用输出的 output_path 作为交付路径。