speech-engine
Skill1 starsChanged 31 days agoMITView on GitHub
Add real-time voice conversations to a custom agent runtime with ElevenLabs Speech Engine. Use when building Speech Engine servers, WebSocket handlers, WebRTC browser clients, conversation token endpoints, interruption-aware streaming responses, or voice-enabled chat agents that connect developer-owned server logic to ElevenLabs speech-to-text and text-to-speech.
- Reads credentials
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 8 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Add a real-time voice interface to a custom agent.
- Distinctive: line 17
Use Speech Engine when the user wants to:
- Distinctive: line 19
Add voice to an existing chat app or custom server pipeline
- Distinctive: line 20
Add voice to OpenClaw, Hermes, or a similar agent runtime while keeping agent logic on the developer-owned server
- Very specific: line 26
Use the agents skill instead when the user is creating or configuring a hosted ElevenLabs Conversational AI agent with platform-managed …
- Distinctive: line 40
Treat speech-recognition text as untrusted user input.
- Very specific: line 46
Create a Speech Engine resource with ws_url / wsUrl pointing at the public WebSocket URL, usually wss://.../ws.
- Very specific: line 48
Start a Speech Engine server with engine.serve(...) in Python or speechEngine.attach(...) in TypeScript.
- Very specific: line 50
Start the client session with conversationToken.
- Very specific: line 103
Run the Speech Engine server at the ws_url / wsUrl configured on the resource.
- Distinctive: line 133
use your server as an oracle to probe backend state, tools, or prompts
- Very specific: line 135
Only recommend disableAuth / disable_auth when the user has already implemented at least one of:
- Distinctive: line 140
If the user cannot confirm one of the above is in place, leave the default authentication on.
- Distinctive: line 144
Create a server-side token endpoint and have the browser request a token before starting the microphone session.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ElevenLabs Speech Engine
Add a real-time voice interface to a custom agent. ElevenLabs handles microphone audio, speech-to-text, turn-taking, text-to-speech, and browser playback; your server exposes a Speech Engine WebSocket endpoint and streams response text back.
Setup: See Installation Guide. For JavaScript, use
@elevenlabs/*packages only. For deeper SDK details, read JavaScript SDK Reference or Python SDK Reference.
When to Use
Use Speech Engine when the user wants to:
- Add voice to an existing chat app or custom server pipeline
- Add voice to OpenClaw, Hermes, or a similar agent runtime while keeping agent logic on the developer-owned server
- Build a developer-hosted WebSocket server for ElevenLabs voice conversations
- Stream response text back as spoken audio after your server validates user intent
- Handle user interruptions while a response is still streaming
- Build a browser client with
@elevenlabs/reactor@elevenlabs/clientusing a server-issued conversation token
Use the agents skill instead when the user is creating or configuring a hosted ElevenLabs Conversational AI agent with platform-managed prompts, tools, workflows, phone numbers, or widgets.
How It Works
Each Speech Engine WebSocket connection represents one conversation.
- The browser sends user audio to ElevenLabs.
- ElevenLabs sends speech-recognition events to your server.
- Your server derives trusted application state without letting raw speech text control tools or privileged actions.
- Your server streams text back through the SDK.
- ElevenLabs converts the response to speech and plays it in the browser.
The SDK manages WebSocket routing, request verification, session lifecycle, ping/pong, turn-taking, and interruption handling. sendResponse() / send_response() accepts a string or async iterable of response text.
Treat speech-recognition text as untrusted user input. Do not map raw speech text directly into model roles, responses, or tool calls. Use deterministic validation, allowlisted intents, or explicit user confirmation before any transcript-derived value affects downstream response or tool logic.
Implementation Flow
- Install server dependencies and configure
ELEVENLABS_API_KEY. - Expose your Speech Engine server through a public HTTPS URL for local development, for example with
ngrok http 3001. - Create a Speech Engine resource with
ws_url/wsUrlpointing at the public WebSocket URL, usuallywss://.../ws. - Store the returned Speech Engine ID, for example in
ELEVENLABS_SPEECH_ENGINE_ID. - Start a Speech Engine server with
engine.serve(...)in Python orspeechEngine.attach(...)in TypeScript. - Issue browser conversation tokens from a server endpoint. Never put
ELEVENLABS_API_KEYin browser code. - Start the client session with
conversationToken; if the agent should greet first, enable the first-message override on the Speech Engine resource, then setoverrides.agent.firstMessagein the client.
Create a Speech Engine
Python
import asyncio
import os
from dotenv import load_dotenv
from elevenlabs import AsyncElevenLabs
load_dotenv()
elevenlabs = AsyncElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
async def main():
engine = await elevenlabs.speech_engine.create(
name="My Speech Engine",
speech_engine={"ws_url": os.environ["PUBLIC_WS_URL"]},
overrides={"first_message": True},
)
print(engine.engine_id)
asyncio.run(main())TypeScript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";
const elevenlabs = new ElevenLabsClient({
apiKey: process.env.ELEVENLABS_API_KEY,
});
const engine = await elevenlabs.speechEngine.create({
name: "My Speech Engine",
speechEngine: { wsUrl: process.env.PUBLIC_WS_URL! },
overrides: { firstMessage: true },
});
console.log(engine.engineId);PUBLIC_WS_URL should look like wss://example.ngrok.app/ws locally or your production WebSocket route in deployment.
The create request can also configure tts, asr, turn, speech_engine.request_headers / speechEngine.requestHeaders, overrides, and privacy for custom voices, transcription keywords, turn-taking, server auth headers, client-provided first messages, and recording behavior. See the SDK reference files for expanded examples.
Server Pattern
Run the Speech Engine server at the ws_url / wsUrl configured on the resource. Keep response generation behind your own validation boundary: raw speech-recognition text should not directly control responses, tools, secrets, or other privileged actions.
Python
engine = await elevenlabs.speech_engine.get(os.environ["ELEVENLABS_SPEECH_ENGINE_ID"])
await engine.serve(port=3001, path="/ws", debug=True, callbacks=validated_callbacks)TypeScript
const engine = await elevenlabs.speechEngine.get(process.env.ELEVENLABS_SPEECH_ENGINE_ID!);
engine.attach(httpServer, "/ws", { debug: true, ...validatedCallbacks });In TypeScript, pass interruption signals to downstream async work when it supports cancellation so interrupted responses stop quickly. In Python, the SDK cancels the previous turn handler when a newer turn arrives.
Server callbacks can distinguish clean closes from dropped connections: use onClose / on_close for clean disconnects and onDisconnect / on_disconnect for unexpected WebSocket drops.
Security note: speech-recognition text can contain prompt-injection attempts from user speech or played audio. Treat it as untrusted input. Convert it into trusted application state before invoking response generation, tools, or privileged workflows.
Disabling authentication (advanced, dangerous)
Both engine.attach() (TypeScript) and engine.serve() / SpeechEngineServer (Python) verify a JWT on every incoming WebSocket by default. This is what proves the connection is really coming from ElevenLabs and not from an attacker who guessed the URL. Do not turn this off.
An escape hatch exists — disableAuth: true in the callback options (TypeScript) or disable_auth=True on serve() / SpeechEngineServer(...) (Python) — for the narrow case where a compensating network-level control is already in place. Without such a control, disabling auth means any client on the internet that finds your URL can open sessions. Concretely, an attacker can:
- open unlimited conversations to drain your ElevenLabs quota and downstream LLM budget
- feed crafted transcripts to your response pipeline, effectively impersonating a user
- use your server as an oracle to probe backend state, tools, or prompts
Only recommend disableAuth / disable_auth when the user has already implemented at least one of:
- IP allowlist — the server (or an upstream firewall / load balancer / API gateway) only accepts inbound traffic from ElevenLabs' documented egress ranges.
- Custom shared-secret header — a secret header configured on the Speech Engine resource via
speech_engine.request_headers/speechEngine.requestHeadersat create time, validated by an upstream proxy (or by the developer's own middleware in front ofattach()/serve()) before requests reach the SDK.
If the user cannot confirm one of the above is in place, leave the default authentication on. Skipping JWT verification without a mitigation is not an optimization or a convenience — it is unauthenticated public compute.
Browser Client
Create a server-side token endpoint and have the browser request a token before starting the microphone session. Keep the Speech Engine ID and API key on the server. If the client passes overrides.agent.firstMessage, the Speech Engine resource must have the first-message override enabled.
import express from "express";
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";
const app = express();
const elevenlabs = new ElevenLabsClient();
app.get("/api/token", async (_req, res) => {
const response = await elevenlabs.conversationalAi.conversations.getWebrtcToken({
agentId: process.env.ELEVENLABS_SPEECH_ENGINE_ID!,
});
res.json({ token: response.token });
});React clients can use @elevenlabs/react:
import { useConversation } from "@elevenlabs/react";
export function VoiceControls() {
const conversation = useConversation({
onConnect: () => console.log("connected"),
onDisconnect: () => console.log("disconnected"),
onError: (error) => console.error(error),
});
async function startConversation() {
await navigator.mediaDevices.getUserMedia({ audio: true });
const { token } = await fetch("/api/token").then((res) => res.json());
await conversation.startSession({
conversationToken: token,
overrides: {
agent: { firstMessage: "Hello! How can I help you today?" },
},
});
}
return <button onClick={startConversation}>Start conversation</button>;
}References
- Installation Guide
- JavaScript SDK Reference
- Python SDK Reference
Other versions2 projects use a version of this.
Word for word · 1
- elevenlabs/plugin★ 3100% same
Edited · 1
- elevenlabs/skills★ 52796% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- cartesia-apiSkill
- cartesia-lineSkill
- agentsSkill
- dubbingSkill
- speech-to-textSkill
- text-to-speechSkill
- voice-changerSkill
- voice-isolatorSkill
- building-livekit-agentsSkill
- debugging-livekit-agentsSkill
- operating-livekit-agentsSkill
- reading-livekit-docsSkill
- running-livekit-simulationsSkill
- testing-livekit-agentsSkill
- writing-livekit-scenariosSkill
- speechSkill
- transcribeSkill
- deploySkill
- initSkill
- talkSkill
- twilio-ai-agent-architectSkill
- twilio-call-recordingsSkill
- twilio-conference-callsSkill
- twilio-voice-conversation-relaySkill
- twilio-voice-outbound-callsSkill
- twilio-voice-twimlSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

