SuperAPI AI Directory

tencent-tts

General & other

View repository

Updated 10-16 09:29

About this skill

Tencent Cloud Text-to-Speech (TTS) Skill Package

This skill package provides text-to-speech functionality based on the Tencent Cloud Text-to-Speech service, focusing on basic single synthesis needs.

Features

  • Text-to-Speech: Convert any text content into high-quality speech files
  • Multi-format Support: Supports common audio formats such as MP3 and WAV
  • Speech Parameter Configuration: Configurable parameters such as voice type and audio format
  • Secure Authentication: Securely manage Tencent Cloud API keys through environment variables

Prerequisites

Before using this skill, please ensure:

  1. Tencent Cloud Account: Have a valid Tencent Cloud account
  2. API Key: Obtain the SecretId and SecretKey for the Tencent Cloud API
  3. Service Activation: The Tencent Cloud Text-to-Speech (TTS) service has been activated

Configuration Instructions

Environment Variable Configuration

Configure the Tencent Cloud API key as an environment variable:

export TENCENTCLOUD_SECRET_ID="your-secret-id"
export TENCENTCLOUD_SECRET_KEY="your-secret-key"

Skill Parameter Description

Parameter Name Type Required Default Value Description
text string Yes - The text content to be converted into speech
voice_type int No 101001 Voice type (101001-101015)
codec string No mp3 Audio encoding format (mp3/wav)
output_file string No output.mp3 Output audio file name

Usage Examples

Basic Usage

# 使用默认参数合成语音
from tencent_tts import TextToSpeech

tts = TextToSpeech()
result = tts.synthesize("欢迎使用腾讯云语音合成服务")
print(f"音频文件已生成: {result['output_file']}")

Custom Parameters

# 使用自定义参数
from tencent_tts import TextToSpeech

tts = TextToSpeech()
result = tts.synthesize(
    text="这是一个自定义语音合成的示例",
    voice_type=101002,
    codec="wav",
    output_file="custom_voice.wav"
)
print(f"音频文件已生成: {result['output_file']}")

File Structure

tencent-tts/
├── SKILL.md (本文件)
├── scripts/
│   └── tencent_tts.py (主功能脚本)
└── examples/
    └── basic_usage.py (基础使用示例)

Best Practices

  1. Key Security: Do not hard-code API keys in code
  2. Text Length: It is recommended that a single synthesis text does not exceed 300 characters
  3. Frequency Control: Avoid high-frequency calls and comply with service limits
  4. File Management: Regularly clean up generated audio files

Technical Support

If you encounter problems, please refer to: