it will help you to send voice messages to your AI Assistant and also can make it talk技能使用说明
2026-03-30
新闻来源:网淘吧
围观:8
电脑广告
手机广告
ElevenLabs 语音
完整的语音解决方案——通过单一API实现TTS和STT:
- TTS:文本转语音(高品质语音)
- STT:通过Scribe实现语音转文本(精准转录)
快速入门
环境设置
设置您的API密钥:

export ELEVENLABS_API_KEY="sk_..."
或在工作区根目录创建.env文件。
文本转语音 (TTS)
将文本转换为自然语音:
python scripts/elevenlabs_speech.py tts -t "Hello world" -o greeting.mp3
使用自定义语音:
python scripts/elevenlabs_speech.py tts -t "Hello" -v "voice_id_here" -o output.mp3
列出可用语音
python scripts/elevenlabs_speech.py voices
在代码中使用
from scripts.elevenlabs_speech import ElevenLabsClient
client = ElevenLabsClient(api_key="sk_...")
# Basic TTS
result = client.text_to_speech(
text="Hello from zerox",
output_path="greeting.mp3"
)
# With custom settings
result = client.text_to_speech(
text="Your text here",
voice_id="21m00Tcm4TlvDq8ikWAM", # Rachel
stability=0.5,
similarity_boost=0.75,
output_path="output.mp3"
)
# Get available voices
voices = client.get_voices()
for voice in voices['voices']:
print(f"{voice['name']}: {voice['voice_id']}")
热门语音
| 语音ID | 名称 | 描述 |
|---|---|---|
21m00Tcm4TlvDq8ikWAM | Rachel | 自然、多用途(默认) |
AZnzlk1XvdvUeBnXmlld | 多咪 | 强劲有力,充满活力 |
EXAVITQu4vr4xnSDxMaL | 贝拉 | 柔和舒缓 |
ErXwobaYiN019PkySvjV | 安东尼 | 全面均衡 |
MF3mGyEYCl7XYWbV9V6O | 艾莉 | 温暖友善 |
TxGEqnHWrfWFTfGW9XjX | 乔什 | 深沉平静 |
VR6AewLTigWG4xSOukaG | 阿诺德 | 权威感强 |
语音设置
- 稳定性(0-1):数值越低越富有情感,数值越高越稳定
- 相似度增强(0-1):数值越高越接近原始声音
默认值:稳定性=0.5,相似度增强=0.75
模型
eleven_turbo_v2_5- 快速,高质量(默认)eleven_multilingual_v2- 最适合非英语内容eleven_monolingual_v1- 仅限英语
与 Telegram 集成
当用户发送文本并希望得到语音回复时:
# Generate speech
result = client.text_to_speech(text=user_text, output_path="reply.mp3")
# Send via Telegram message tool with media path
message(action="send", media="path/to/reply.mp3", as_voice=True)
定价
请查看https://elevenlabs.io/pricing了解当前费率。提供免费套餐!
使用 ElevenLabs Scribe 进行语音转文本 (STT)
使用 ElevenLabs Scribe 转录语音消息:
转录音频
python scripts/elevenlabs_scribe.py voice_message.ogg
指定语言:
python scripts/elevenlabs_scribe.py voice_message.ogg --language ara
使用说话人分离(多说话人):
python scripts/elevenlabs_scribe.py voice_message.ogg --speakers 2
代码中使用
from scripts.elevenlabs_scribe import ElevenLabsScribe
client = ElevenLabsScribe(api_key="sk-...")
# Basic transcription
result = client.transcribe("voice_message.ogg")
print(result['text'])
# With language hint (improves accuracy)
result = client.transcribe("voice_message.ogg", language_code="ara")
# With speaker detection
result = client.transcribe("voice_message.ogg", num_speakers=2)
支持格式
- mp3, mp4, mpeg, mpga, m4a, wav, webm
- 最大文件大小:100 MB
- 与 Telegram 语音消息配合使用效果极佳
.ogg)
语言支持
Scribe 支持 99 种语言,包括:
- 阿拉伯语 (
ara) - 英语 (
eng) - 西班牙语 (
spa) - 法语 (
fra) - 以及更多...
若无语言提示,则自动检测。
完整工作流程示例
用户发送语音消息 → 您用语音回复:
from scripts.elevenlabs_scribe import ElevenLabsScribe
from scripts.elevenlabs_speech import ElevenLabsClient
# 1. Transcribe user's voice message
stt = ElevenLabsScribe()
transcription = stt.transcribe("user_voice.ogg")
user_text = transcription['text']
# 2. Process/understand the text
# ... your logic here ...
# 3. Generate response text
response_text = "Your response here"
# 4. Convert to speech
tts = ElevenLabsClient()
tts.text_to_speech(response_text, output_path="reply.mp3")
# 5. Send voice reply
message(action="send", media="reply.mp3", as_voice=True)
定价
请访问https://elevenlabs.io/pricing查看当前费率:
TTS(文本转语音):
- 免费套餐:每月10,000字符
- 提供付费方案
STT(语音转文字)- 听写功能:
- 提供免费套餐
- 具体价格请查阅官网
文章底部电脑广告
手机广告位-内容正文底部
上一篇:每日热榜
下一篇:生铁的分类 | 钢铁材料的分类 | 机械工程材料(金属)


微信扫一扫,打赏作者吧~