elevenlabs-tts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseElevenLabs Text-to-Speech
ElevenLabs 文本转语音
Overview
概述
Generate professional audio files from text using ElevenLabs' advanced text-to-speech API. The skill provides pre-configured voice presets with sensible defaults, voice parameter customization, and direct access to the script for programmatic control.
scripts/elevenlabs_tts.py借助ElevenLabs先进的文本转语音API,将文本生成为专业级音频文件。该技能提供了配置合理默认值的预设语音、可自定义的语音参数,还可直接访问脚本以实现程序化控制。
scripts/elevenlabs_tts.pyQuick Start
快速开始
To generate audio from text:
- Ensure the file contains a valid
.envELEVENLABS_API_KEY - Execute the script with text:
python scripts/elevenlabs_tts.py "Your text here" - Specify voice and output:
python scripts/elevenlabs_tts.py "Text" --voice adam --output audio/output.mp3
要将文本生成音频:
- 确保文件包含有效的
.envELEVENLABS_API_KEY - 使用文本执行脚本:
python scripts/elevenlabs_tts.py "Your text here" - 指定语音和输出路径:
python scripts/elevenlabs_tts.py "Text" --voice adam --output audio/output.mp3
Voice Presets
预设语音
Seven pre-configured voices are available. See for complete voice descriptions:
references/api_reference.md- (default) - Clear, professional female
rachel - - Deep, authoritative male
adam - - Warm, friendly female
bella - - Young, enthusiastic female
elli - - Friendly, conversational male
josh - - Deep, powerful male
arnold - - Expressive, dynamic female
ava
提供七种预配置的语音。完整的语音说明请查看:
references/api_reference.md- (默认)- 清晰、专业的女声
rachel - - 低沉、权威的男声
adam - - 温暖、友好的女声
bella - - 年轻、热情的女声
elli - - 亲切、口语化的男声
josh - - 低沉、有力量的男声
arnold - - 富有表现力、充满活力的女声
ava
Parameters
参数
Text
文本
The text to convert to speech. Any length is supported.
需要转换为语音的文本。支持任意长度。
Voice Selection
语音选择
Specify voice using preset name (e.g., , ) or direct ElevenLabs voice ID.
racheladam可通过预设名称(如、)或ElevenLabs语音ID指定语音。
racheladamVoice Parameters
语音参数
- stability (0.0-1.0, default 0.5): Lower values create expressive variation; higher values ensure consistency
- similarity_boost (0.0-1.0, default 0.75): Higher values maintain closer adherence to voice characteristics
- stability(0.0-1.0,默认值0.5):值越低,语音表现力变化越强;值越高,语音一致性越好
- similarity_boost(0.0-1.0,默认值0.75):值越高,越贴近原语音特征
Output
输出
Specify the output file path. Default is . Directories are created automatically.
output.mp3指定输出文件路径。默认路径为。目录不存在时会自动创建。
output.mp3Usage Examples
使用示例
Basic Python Usage
Python基础用法
python
from scripts.elevenlabs_tts import generate_speech
path = generate_speech(
text="Hello, this is a test message",
voice_id="rachel"
)python
from scripts.elevenlabs_tts import generate_speech
path = generate_speech(
text="Hello, this is a test message",
voice_id="rachel"
)Command Line
命令行
bash
undefinedbash
undefinedWith default voice
With default voice
python scripts/elevenlabs_tts.py "Generate this text"
python scripts/elevenlabs_tts.py "Generate this text"
With custom voice and stability
With custom voice and stability
python scripts/elevenlabs_tts.py "Different voice" --voice adam --stability 0.7
python scripts/elevenlabs_tts.py "Different voice" --voice adam --stability 0.7
To custom output path
To custom output path
python scripts/elevenlabs_tts.py "Save here" --output audio/narration.mp3
python scripts/elevenlabs_tts.py "Save here" --output audio/narration.mp3
List available voices
List available voices
python scripts/elevenlabs_tts.py "" --list-voices
undefinedpython scripts/elevenlabs_tts.py "" --list-voices
undefinedImplementation Notes
实现说明
- The script handles API communication with error reporting
- Output directories are created automatically if they don't exist
- Returns absolute path to generated audio file
- Uses model by default (can be overridden)
eleven_monolingual_v1
- 脚本处理API通信并提供错误报告
- 输出目录不存在时会自动创建
- 返回生成的音频文件的绝对路径
- 默认使用模型(可覆盖)
eleven_monolingual_v1
Resources
资源
- - Main Python script for text-to-speech generation. Can be imported as a module or executed from command line.
scripts/elevenlabs_tts.py - - Detailed API documentation including voice descriptions, parameter explanations, and usage examples.
references/api_reference.md - and
.env- Environment configuration for storing API credentials securely..env.example
- - 用于文本转语音生成的主Python脚本。可作为模块导入或从命令行执行。
scripts/elevenlabs_tts.py - - 详细的API文档,包括语音说明、参数解释和使用示例。
references/api_reference.md - 和
.env- 用于安全存储API凭证的环境配置文件。.env.example