Preface¶
When developing content tools, accessibility readers, or voice broadcasts, a common practice is to integrate cloud vendor TTS APIs yourself: checking documentation, writing signatures, processing returned audio bytes, and saving them to disk. If you wish to delegate “Text-to-Speech” to a Coding Agent within a conversation, you need a Skill package that outlines prerequisites, key configuration, and calling conventions, rather than assembling HTTP requests from scratch every time.
Below is an introduction to TencentCloud TTS (@tencent-adm/tencentcloud-tts) on SkillHub: an enterprise-sourced skill published by the Tencent Cloud Voice team. It encapsulates Tencent Cloud’s speech synthesis capabilities into an Agent-readable SKILL.md and executable scripts, suitable for installation and use in environments supporting Skills, such as Cursor and Codex.
What is this¶
TencentCloud TTS is a skill package for Tencent Cloud Text-to-Speech (TTS) services. When a user needs to convert text to audio files, or mentions speech synthesis, text-to-speech, TTS, or audio file generation, the Agent should prioritize enabling this skill.
- Coordinate:
@tencent-adm/tencentcloud-tts - Version: 1.0.0
- Category: design-media (SkillHub)
- Tags:
requires_api_key=true(Tencent Cloud API keys required) - SkillHub Page: https://www.skillhub.cn/skills/tencent-adm/tencentcloud-tts
The skill package provides a TextToSpeech wrapper that calls the TextToVoice interface of tts.tencentcloudapi.com via Tencent Cloud API Signature v3. It focuses on single basic synthesis and does not rely on additional Python SDKs (the implementation primarily uses the standard library and HTTPS).
Core Functions¶
The following capabilities are derived from the SKILL.md and scripts/tencent_tts.py included in the skill package:
- Text-to-Speech: Synthesizes text content into a local audio file.
- Multi-format Output:
codecsupportsmp3,wav(defaultmp3). - Voice Type:
voice_typeis an integer; documentation indicates the range 101001–101015 (default101001). - Key Management: Reads keys via environment variables
TENCENTCLOUD_SECRET_IDandTENCENTCLOUD_SECRET_KEYto avoid hardcoding in the code. - Synthesis Result:
synthesizereturns a dictionary containing fields such assuccess,output_file,file_size,voice_type,codec, andrequest_id; containserrorupon failure.
The documentation also suggests: single synthesis text should not be too long (recommended not to exceed ~300 characters), and attention should be paid to call frequency and Tencent Cloud service limits.
Installation and Activation¶
Prerequisites¶
- Possess a valid Tencent Cloud account.
- Have activated the Tencent Cloud Text-to-Speech (TTS) service and obtained the API’s SecretId and SecretKey.
- The local machine or Agent runtime environment can access
tts.tencentcloudapi.com.
Installation via SkillHub¶
First, install the skillhub CLI according to the SkillHub Installation Guide (if not already installed). When installing the skill, you must use --dir to point to the current Agent’s skills directory; otherwise, installing to the default ./skills/ may not be recognized.
skillhub install @tencent-adm/tencentcloud-tts --dir <your Agent skills directory>
Common path examples (subject to the official installation documentation):
- Cursor:
~/.cursor/skills/ - Codex:
~/.codex/skills/or.agents/skills/under the project - Claude Code:
~/.claude/skills/
You can also send the following prompt to an AI to complete the installation based on the installation documentation:
Please install `@tencent-adm/tencentcloud-tts` according to https://skillhub.cn/install/skillhub.md.
Configure API Keys¶
Before running the synthesis script or examples, set the environment variables:
export TENCENTCLOUD_SECRET_ID="your-secret-id"
export TENCENTCLOUD_SECRET_KEY="your-secret-key"
The skill parameters and synthesize defaults are as follows (excerpt from SKILL.md):
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| text | string | Yes | - | Text to be synthesized |
| voice_type | int | No | 101001 | Voice type (101001–101015) |
| codec | string | No | mp3 | Audio encoding (mp3 / wav) |
| output_file | string | No | output.mp3 | Output filename |
Typical Usage¶
Invocation in Python (Consistent with Repo Examples)¶
After entering the skill package directory, you can add scripts to the path and call it. The official examples/basic_usage.py is written as follows:
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "scripts"))
from tencent_tts import TextToSpeech
tts = TextToSpeech()
result = tts.synthesize(
text="Welcome to Tencent Cloud Text-to-Speech service. This is a basic usage example.",
voice_type=101001,
codec="mp3",
output_file="basic_example.mp3",
)
if result["success"]:
print(result["output_file"], result["file_size"])
else:
print(result["error"])
TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY must be exported before running. You can also execute directly:
python examples/basic_usage.py
Custom Voice and Format¶
Example of custom parameters in SKILL.md:
from tencent_tts import TextToSpeech
tts = TextToSpeech()
result = tts.synthesize(
text="这是一个自定义语音合成的示例",
voice_type=101002,
codec="wav",
output_file="custom_voice.wav",
)
The constructor supports optional passing of secret_id and secret_key; if not passed, they are read from environment variables.
How to use on the Agent side¶
After installation and key configuration, when a user proposes requirements in the conversation such as “synthesize this copy to MP3” or “generate WAV broadcast”, the Agent reads the SKILL.md in the skill directory, calls TextToSpeech.synthesize in scripts/tencent_tts.py according to the parameter table, and returns the generated file path to the user.
Use Cases and Notes¶
Suitable for:
- Requiring a quick single text-to-speech conversion within an IDE / CLI Agent workflow, where Tencent Cloud TTS is already used or planned to be used.
- Hoping to centralize trigger words, environment variables, and script entries via a Skill to reduce repetitive API documentation checks.
Notes:
- Tencent Cloud TTS must be activated and keys configured correctly; if authentication fails, first verify the keys and whether the service is activated.
- The skill is marked
requires_api_key=true; do not commit keys to repositories or write them in plain text in Skill conversations. - Single text length and QPS are subject to Tencent Cloud product limits; the skill documentation suggests controlling single text length and avoiding high-frequency calls.
- For more complex streaming synthesis, long text chunking, batch tasks, etc., which exceed the scope of this package’s “basic single synthesis,” please refer directly to the Tencent Cloud Speech Synthesis Documentation to extend it yourself.
This skill on SkillHub is an enterprise-sourced release; as of the page and API metadata, the version is 1.0.0. Download and installation data can be viewed on the SkillHub skill page (statistics within the site update over time).
Conclusion¶
TencentCloud TTS encapsulates Tencent Cloud speech synthesis into an Agent Skill: install @tencent-adm/tencentcloud-tts, configure TENCENTCLOUD_SECRET_ID / TENCENTCLOUD_SECRET_KEY, and you can use TextToSpeech.synthesize or the official example to generate MP3/WAV. For details and installation entries, see SkillHub: https://www.skillhub.cn/skills/tencent-adm/tencentcloud-tts , API index page: https://api.skillhub.cn/tencent-adm/tencentcloud-tts .