#Hi
1 messages · Page 1 of 1 (latest)
Hi! How can I help you with ElevenLabs products or API today? Tell me what you’re building or stuck on, and I’ll pull the exact steps from the official docs.
Oh sweeet. Guess I didn’t notice you replied. That’s on me. I’ve had a lot going on lately. My goal is super simple. I rub my ai locally on my own computer with Ollama. So. The logic part is a lot easier than it would be for most. I take care of the compute power and central location for all the big work to be done. I just want to give my discord bot that I have here an upgrade from gTTS without pretending I’m some rich developer. It’s like yeah my idea is cool but it’s not unique anymore so. Doubt it’s going to be a special that people pay me to talk to
Got it. If you want to replace gTTS in your Discord bot without big spend, here’s the lean, documented path:
-
Pick a low-cost TTS model
- Use Flash v2.5 (ultra‑low latency ~75 ms) or Turbo v2.5. These are billed at $0.05 per 1,000 characters on all plans, including Free/Pay‑as‑you‑go. (elevenlabs.io)
-
Get an API key and cap spend
- Create an API key and (optionally) restrict scopes and set a per‑key credit limit. Authenticate using the xi-api-key header. (elevenlabs.io)
- The API is included in all plans; you only pay for generation. (help.elevenlabs.io)
-
Choose a voice
- You can use default voices or your own; fetch voice_id via the List voices API or copy it from the UI. Note: Voice Library access via API is not available on the free tier. (elevenlabs.io)
-
Generate audio for Discord playback
- HTTP (single shot or streamed):
- Create speech (REST): POST /v1/text-to-speech/:voice_id with text, model_id, and optional output_format (e.g., mp3_44100_128). (elevenlabs.io)
- Stream speech (low‑latency chunked HTTP): POST /v1/text-to-speech/:voice_id/stream. Official SDKs show how to consume the stream. (elevenlabs.io)
- WebSocket (real‑time, word alignment available):
- wss://api.elevenlabs.io/v1/text-to-speech/:voice_id/stream-input supports sending partial text and receiving audio chunks in real time. (elevenlabs.io)
- Pick an output format that fits Discord’s voice pipeline:
- Supported API formats include MP3 (22.05–44.1 kHz), PCM (up to 48 kHz), Opus (48 kHz), and μ‑law/A‑law (8 kHz). Select an output_format accordingly (e.g., MP3 defaults, or a PCM/Opus 48 kHz option if your bot can play/forward it directly). (elevenlabs.io)
- HTTP (single shot or streamed):
-
Control delivery and speed
- You can adjust speaking speed via the Speed/voice settings parameter; recommended range is 0.7–1.2. (help.elevenlabs.io)
-
Know limits and error handling
- Character limits per request (useful if you buffer Discord messages): Flash v2.5/Turbo v2.5 support up to 40,000 input characters. (help.elevenlabs.io)
- Concurrency is plan‑based (parallel TTS requests). If you hit 429 too_many_concurrent_requests, reduce parallel calls or upgrade tier. (help.elevenlabs.io)
- There’s also a safety cap on “credits used at once” (2× your monthly quota) to prevent runaway usage. (help.elevenlabs.io)
Minimal example (documented patterns)
- REST streaming with SDKs (Python/Node) for immediate playback/forwarding is shown in the Streaming guide. Use your voice_id, model_id (e.g., eleven_flash_v2_5), and set output_format as needed. (elevenlabs.io)
If you want, tell me your bot’s language (Python/Node), and whether you can ingest Opus directly. I can provide a drop‑in snippet that calls Stream speech or the WebSocket API with Flash v2.5 and returns
This should help.
import os
import json
import asyncio
import random
import base64
import io
from gtts import gTTS
import discord
from discord.ext import commands
import requests
=========================
CONFIG
=========================
DISCORD_TOKEN = "YOUWISHFEDBOY"
MODEL_NAME = "llama3.2:3b"
CHANNEL_CONTEXT_WINDOW = 100