网淘吧来吧,欢迎您!

it will help you to send voice messages to your AI Assistant and also can make it talk技能使用说明

2026-03-30 新闻来源:网淘吧 围观:6
电脑广告
手机广告

ElevenLabs 语音

完整的语音解决方案——通过单一API实现TTS和STT:

  • TTS:文本转语音(高品质语音)
  • STT:通过Scribe实现语音转文本(精准转录)

快速入门

环境设置

设置您的API密钥:

it will help you to send voice messages to your AI Assistant and also can make it talk

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名称描述
21m00Tcm4TlvDq8ikWAMRachel自然、多用途(默认)
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(语音转文字)- 听写功能:

  • 提供免费套餐
  • 具体价格请查阅官网

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第349225名访客 今日有175篇新文章/评论