360 Secure SkillHub
360 安全技能中心

Elevenlabs Tts

该 Skill 用于调用 ElevenLabs 文本转语音服务:查询并选择音色、通过 HTTP 流式接口生成语音文件、选择模型与输出格式、调整流式延迟,并记录首字节时间等基准数据。API Key 由环境变量注入,文档另含 WebSocket 流式说明与故障排查指引。

jerryxn
jerryxn
热度 22.45
最近更新 2026-05-26 09:03:27
分类:创作依赖:代码执行 / 读写文件 / 第三方 API应用场景:API 集成 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add xiaog-elevenlabs-tts
Metadata
name
elevenlabs-tts
description
Set up, test, benchmark, and use ElevenLabs text-to-speech as an independent TTS skill, including HTTP streaming, WebSocket streaming guidance, voice listing, model/output-format selection, latency tuning, and safe ELEVENLABS_API_KEY handling.

ElevenLabs TTS

Use this skill for ELE / ElevenLabs voice generation, low-latency streaming TTS, voice IDs, voice listing, output formats, or TTS benchmark work.

Non-negotiables

  • Keep this skill independent from Xiaomi MiMo TTS. Do not mix API keys, endpoint shapes, voice IDs, or scripts.
  • Treat ELEVENLABS_API_KEY as a secret. Never echo it, write it into skill files, commit it, or expose it in logs/screenshots.
  • Prefer environment variable injection for tests: ELEVENLABS_API_KEY=... python3 ....
  • If the key is missing, verify scripts and docs locally, then report that live API synthesis is blocked by missing credentials.

Standard workflow

  1. Verify API key availability without printing it.
  2. List voices with scripts/list_voices.py; choose a requested voice by ID/name or use the first available voice for smoke tests.
  3. Generate a short HTTP streaming sample with scripts/tts_stream_http.py.
  4. Capture evidence: output path, bytes, chunks, ttfb_seconds, elapsed time, model, output format.
  5. If audio validation tools exist (ffprobe, afinfo, or file), inspect the generated file before claiming success.

Recommended defaults

  • Model: eleven_flash_v2_5 for lowest latency; eleven_turbo_v2_5 for higher quality with low latency; eleven_multilingual_v2 for broad multilingual quality.
  • Endpoint: POST /v1/text-to-speech/{voice_id}/stream when the full text is available.
  • Output: mp3_44100_128 for shareable files; pcm_16000/pcm_24000 for realtime playback pipelines.
  • Latency: optimize_streaming_latency=2 or 3; avoid 4 unless the user accepts possible number/date mispronunciation.
  • Voice settings: keep use_speaker_boost=false for low latency.

Quick commands

List voices:

ELEVENLABS_API_KEY="$ELEVENLABS_API_KEY" python3 skills/elevenlabs-tts/scripts/list_voices.py

HTTP streaming TTS benchmark:

ELEVENLABS_API_KEY="$ELEVENLABS_API_KEY" python3 skills/elevenlabs-tts/scripts/tts_stream_http.py \
  --text '野哥,ElevenLabs 流式语音测试成功。' \
  --voice-name Rachel \
  --model eleven_flash_v2_5 \
  --output-format mp3_44100_128 \
  --optimize-streaming-latency 2 \
  --out /tmp/elevenlabs-skill-test.mp3

If --voice-name is omitted, the script uses the first voice returned by /v1/voices.

When to read more

  • API contract, request/response details, WebSocket notes, and troubleshooting: references/elevenlabs-api.md.
  • Deterministic scripts:
    • scripts/list_voices.py
    • scripts/tts_stream_http.py