ElevenLabs Speech-to-Text
Official ElevenLabs skill for speech-to-text transcription.
Convert audio to text with state-of-the-art accuracy. Supports 90+ languages, speaker diarization, and realtime streaming.
Prerequisites
- - ffmpeg installed (
brew install ffmpeg on macOS) - ELEVENLABSAPIKEY environment variable set
- Python 3.8+ (dependencies auto-install on first run)
Usage
CODEBLOCK0
Examples
Batch Transcription
Transcribe a local audio file:
CODEBLOCK1
With speaker identification:
CODEBLOCK2
Get full JSON response with timestamps:
CODEBLOCK3
Realtime Streaming
Stream from a URL (e.g., live radio, podcast):
CODEBLOCK4
Transcribe from microphone:
CODEBLOCK5
Stream a local file in realtime (useful for testing):
CODEBLOCK6
Quiet Mode for Agents
Suppress status messages on stderr:
CODEBLOCK7
Options
| Option | Description |
|---|
| INLINECODE1 | Identify different speakers in the audio |
| INLINECODE2 |
ISO language hint (e.g.,
en,
pt,
es,
fr) |
|
--json | Output full JSON with timestamps and metadata |
|
--events | Tag audio events (laughter, music, applause) |
|
--realtime | Stream local file instead of batch processing |
|
--partials | Show interim transcripts during realtime mode |
|
-q, --quiet | Suppress status messages (recommended for agents) |
Output Format
Text Mode (default)
Plain text transcription:
CODEBLOCK8
JSON Mode (--json)
CODEBLOCK9
Realtime Mode
Final transcripts print as they're committed. With --partials:
CODEBLOCK10
Supported Formats
Audio: MP3, WAV, M4A, FLAC, OGG, WebM, AAC, AIFF, Opus
Video: MP4, AVI, MKV, MOV, WMV, FLV, WebM, MPEG, 3GPP
Limits: Up to 3GB file size, 10 hours duration
Error Handling
The script exits with non-zero status on errors:
- - Missing API key: Set
ELEVENLABS_API_KEY environment variable - File not found: Check the file path exists
- Missing ffmpeg: Install with your package manager
- API errors: Check API key validity and rate limits
When to Use Each Mode
| Scenario | Command |
|---|
| Transcribe a recording | INLINECODE15 |
| Meeting with multiple speakers |
./transcribe.sh meeting.mp3 --diarize |
| Live radio/podcast stream |
./transcribe.sh --url <url> |
| Voice input from user |
./transcribe.sh --mic --quiet |
| Need word timestamps |
./transcribe.sh file.mp3 --json |
ElevenLabs 语音转文本
ElevenLabs官方语音转文本技能。
以业界领先的准确度将音频转换为文本。支持90多种语言、说话人分离和实时流式传输。
前置条件
- - 已安装 ffmpeg(macOS上使用 brew install ffmpeg)
- 已设置 ELEVENLABSAPIKEY 环境变量
- Python 3.8+(首次运行时自动安装依赖)
使用方法
bash
{baseDir}/scripts/transcribe.sh <音频文件> [选项]
{baseDir}/scripts/transcribe.sh --url <流地址> [选项]
{baseDir}/scripts/transcribe.sh --mic [选项]
示例
批量转录
转录本地音频文件:
bash
{baseDir}/scripts/transcribe.sh recording.mp3
带说话人识别:
bash
{baseDir}/scripts/transcribe.sh meeting.mp3 --diarize
获取带时间戳的完整JSON响应:
bash
{baseDir}/scripts/transcribe.sh interview.wav --diarize --json
实时流式传输
从URL流式传输(例如:直播电台、播客):
bash
{baseDir}/scripts/transcribe.sh --url https://npr-ice.streamguys1.com/live.mp3
从麦克风转录:
bash
{baseDir}/scripts/transcribe.sh --mic
实时流式传输本地文件(适用于测试):
bash
{baseDir}/scripts/transcribe.sh audio.mp3 --realtime
静默模式(适用于代理)
抑制stderr上的状态消息:
bash
{baseDir}/scripts/transcribe.sh --mic --quiet
选项
| 选项 | 描述 |
|---|
| --diarize | 识别音频中的不同说话人 |
| --lang CODE |
ISO语言提示(例如:en、pt、es、fr) |
| --json | 输出带时间戳和元数据的完整JSON |
| --events | 标记音频事件(笑声、音乐、掌声) |
| --realtime | 流式传输本地文件而非批量处理 |
| --partials | 在实时模式下显示中间转录结果 |
| -q, --quiet | 抑制状态消息(推荐用于代理) |
输出格式
文本模式(默认)
纯文本转录:
敏捷的棕色狐狸跳过了懒狗。
JSON模式(--json)
json
{
text: 敏捷的棕色狐狸跳过了懒狗。,
language_code: eng,
language_probability: 0.98,
words: [
{text: The, start: 0.0, end: 0.15, type: word, speakerid: speaker0}
]
}
实时模式
最终转录结果在提交时打印。使用--partials:
[partial] 敏捷的棕色
[partial] 敏捷的棕色狐狸
敏捷的棕色狐狸跳过了懒狗。
支持的格式
音频: MP3、WAV、M4A、FLAC、OGG、WebM、AAC、AIFF、Opus
视频: MP4、AVI、MKV、MOV、WMV、FLV、WebM、MPEG、3GPP
限制: 最大文件大小3GB,最长时长10小时
错误处理
脚本在出错时以非零状态退出:
- - 缺少API密钥: 设置 ELEVENLABSAPIKEY 环境变量
- 文件未找到: 检查文件路径是否存在
- 缺少ffmpeg: 使用包管理器安装
- API错误: 检查API密钥有效性和速率限制
何时使用每种模式
| 场景 | 命令 |
|---|
| 转录录音 | ./transcribe.sh file.mp3 |
| 多人会议 |
./transcribe.sh meeting.mp3 --diarize |
| 直播电台/播客流 | ./transcribe.sh --url
|
| 用户语音输入 | ./transcribe.sh --mic --quiet |
| 需要单词时间戳 | ./transcribe.sh file.mp3 --json |