From 316bad7971852f2e3aeb573d05b663ed46912e8b Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Wed, 20 May 2026 04:35:35 +0530 Subject: [PATCH 1/2] docs(tts): switch core recipes to unified /waves/v1/tts + Lightning v3.1 Pro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TTS API has a new unified route — POST /waves/v1/tts (sync) and /waves/v1/tts/live (SSE + WebSocket, protocol-dispatched). The legacy model-named routes (/waves/v1/lightning-v3.1/get_speech etc.) still work but are deprecated. New code should pick the model via the `model` body field: "lightning_v3.1" (default, standard pool, more voices + voice cloning) or "lightning_v3.1_pro" (premium pool, curated voice catalog). Migrated to the unified route + Pro-by-default in these recipes: - text-to-speech/README.md - text-to-speech/quickstart-{curl.sh,python.py,javascript.js} - text-to-speech/quickstart/{quickstart.py,quickstart.js,README.md} - text-to-speech/getting-started/{python,javascript}/synthesize.{py,js} - text-to-speech/getting-started/README.md - text-to-speech/streaming-python.py - text-to-speech/streaming/{python,javascript}/stream_{ws,sse}.{py,js} - text-to-speech/streaming/README.md Each updated recipe carries a comment explaining how to switch back to the standard pool (drop the `model` field or set it to "lightning_v3.1"). Voice ID defaults to "meher" (top-ranked Indian female Pro voice). Verified live: quickstart-python.py returned 138 KB WAV; stream_sse.py TTFB 716ms, 19 chunks, 138 KB WAV. Recipes that depend on Pro-incompatible features are intentionally left on the standard pool and will be migrated in a follow-up PR if/when needed: - voice-cloning/ — Pro doesn't offer voice cloning - multilingual-translator/, language-translation-app/ — need non-en/hi languages that Pro voices aren't trained on - pronunciation-dicts/ — pronunciation_dicts param is standard-pool only Lower-priority recipes (audiobook-generator, podcast-generator, news-voice-app, voice-gallery-app, voice-explorer, voices/, sdk-usage) to be migrated in a follow-up; they would each benefit but were out of scope for this batch. --- text-to-speech/README.md | 18 +++++---- text-to-speech/getting-started/README.md | 10 +++-- .../getting-started/javascript/synthesize.js | 12 ++++-- .../getting-started/python/synthesize.py | 12 ++++-- text-to-speech/quickstart-curl.sh | 8 ++-- text-to-speech/quickstart-javascript.js | 10 +++-- text-to-speech/quickstart-python.py | 10 +++-- text-to-speech/quickstart/README.md | 6 ++- text-to-speech/quickstart/quickstart.js | 4 +- text-to-speech/quickstart/quickstart.py | 5 ++- text-to-speech/streaming-python.py | 40 +++++++++++++++---- text-to-speech/streaming/README.md | 10 +++-- .../streaming/javascript/stream_sse.js | 9 +++-- .../streaming/javascript/stream_ws.js | 9 +++-- text-to-speech/streaming/python/stream_sse.py | 9 +++-- text-to-speech/streaming/python/stream_ws.py | 9 +++-- 16 files changed, 124 insertions(+), 57 deletions(-) diff --git a/text-to-speech/README.md b/text-to-speech/README.md index 4729dc9..73a7db9 100644 --- a/text-to-speech/README.md +++ b/text-to-speech/README.md @@ -1,19 +1,21 @@ # Text-to-Speech -> **Powered by [Lightning TTS v3.1](https://waves-docs.smallest.ai/v4.0.0/content/api-references/lightning-v3.1)** +> **Powered by [Lightning TTS v3.1](https://docs.smallest.ai/waves/model-cards/text-to-speech/lightning-v-3-1) and the new [Lightning v3.1 Pro](https://docs.smallest.ai/waves/model-cards/text-to-speech/lightning-v-3-1-pro) pool.** -Generate natural-sounding speech from text using Smallest AI's Lightning TTS API. 80+ voices, 44.1 kHz native sample rate, ~200ms latency. +Generate natural-sounding speech from text using Smallest AI's Lightning TTS API. 80+ voices on standard Lightning v3.1, plus a curated Pro voice catalog across American, British, and Indian accents. 44.1 kHz native sample rate, ~200ms latency. ## Try It Now (Zero Install) ```bash -curl -X POST https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech \ +curl -X POST https://api.smallest.ai/waves/v1/tts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ - -d '{"text": "Hello from Smallest AI!", "voice_id": "sophia", "sample_rate": 24000, "output_format": "wav"}' \ + -d '{"text": "Hello from Smallest AI!", "voice_id": "meher", "model": "lightning_v3.1_pro", "sample_rate": 24000, "output_format": "wav"}' \ --output hello.wav ``` +Drop the `model` field (or set it to `"lightning_v3.1"`) to use the standard pool — that pool has more voices, the full 12-language catalog, plus voice cloning. The unified `/waves/v1/tts` route serves both. + Get your API key at [app.smallest.ai](https://app.smallest.ai/dashboard/settings/apikeys). ## Quickstart @@ -75,7 +77,9 @@ uv run text-to-speech/getting-started/python/synthesize.py "Hello from Smallest ## Supported Languages -`en` English · `hi` Hindi · `es` Spanish · `ta` Tamil +Standard Lightning v3.1: `en` English · `hi` Hindi · `mr` Marathi · `kn` Kannada · `ta` Tamil · `bn` Bengali · `gu` Gujarati · `te` Telugu · `ml` Malayalam · `pa` Punjabi · `or` Odia · `es` Spanish · `auto` + +Lightning v3.1 Pro: depends on the voice — Indian Pro voices speak `en` + `hi`; British and American Pro voices speak `en`. Query `GET /waves/v1/lightning-v3.1/get_voices` and read `tags.language` for the source of truth. ## Output Formats @@ -83,8 +87,8 @@ uv run text-to-speech/getting-started/python/synthesize.py "Hello from Smallest ## Documentation -- [Lightning v3.1 REST](https://waves-docs.smallest.ai/v4.0.0/content/api-references/lightning-v3.1) -- [Lightning v3.1 WebSocket](https://waves-docs.smallest.ai/v4.0.0/content/api-references/lightning-v3.1-ws) +- [Lightning v3.1 REST](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/synthesize-speech) +- [Lightning v3.1 WebSocket](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/synthesize-speech-ws) - [Voices API](https://waves-docs.smallest.ai/v4.0.0/content/api-references/get-voices-api) - [Voice Cloning](https://waves-docs.smallest.ai/v4.0.0/content/api-references/voice-cloning-api) - [Pronunciation Dicts](https://waves-docs.smallest.ai/v4.0.0/content/api-references/pronunciation-dicts-api) diff --git a/text-to-speech/getting-started/README.md b/text-to-speech/getting-started/README.md index 52afd13..83580e1 100644 --- a/text-to-speech/getting-started/README.md +++ b/text-to-speech/getting-started/README.md @@ -7,7 +7,7 @@ The simplest way to generate speech from text using Smallest AI's Lightning TTS - Generate speech from text with a single API call - Save output as WAV file - Choose voice, speed, and language -- Uses Lightning v3.1 for highest quality output +- Uses the unified `/waves/v1/tts` route — defaults to Lightning v3.1 Pro pool, pass `MODEL="lightning_v3.1"` to use the standard pool instead ## Requirements @@ -40,8 +40,8 @@ Output is saved to `output.wav` in the current directory. | Parameter | Description | Default | |-----------|-------------|---------| -| `MODEL` | TTS model | `lightning-v3.1` | -| `VOICE_ID` | Voice to use (see [Voices](../voices/)) | `sophia` | +| `MODEL` | TTS pool (`lightning_v3.1_pro` or `lightning_v3.1`) | `lightning_v3.1_pro` | +| `VOICE_ID` | Voice to use (see [Voices](../voices/)) | `meher` | | `SPEED` | Playback speed (0.5 to 2.0) | `1.0` | | `SAMPLE_RATE` | Audio sample rate in Hz | `24000` | | `LANGUAGE` | Language code (`en`, `hi`, `es`, `ta`) | `en` | @@ -49,7 +49,9 @@ Output is saved to `output.wav` in the current directory. ## API Reference -- [Lightning v3.1 API](https://waves-docs.smallest.ai/v4.0.0/content/api-references/lightning-v3.1) +- [Synthesize speech (unified `/waves/v1/tts`)](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/synthesize-speech) +- [Lightning v3.1 model card](https://docs.smallest.ai/waves/model-cards/text-to-speech/lightning-v-3-1) +- [Lightning v3.1 Pro model card](https://docs.smallest.ai/waves/model-cards/text-to-speech/lightning-v-3-1-pro) ## Next Steps diff --git a/text-to-speech/getting-started/javascript/synthesize.js b/text-to-speech/getting-started/javascript/synthesize.js index 2f39722..857ba30 100644 --- a/text-to-speech/getting-started/javascript/synthesize.js +++ b/text-to-speech/getting-started/javascript/synthesize.js @@ -13,17 +13,20 @@ const fs = require("fs"); // Configuration -const MODEL = "lightning-v3.1"; -const VOICE_ID = "sophia"; +// Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices, en + hi +// on Indian voices, en on British/American voices). Set to "lightning_v3.1" +// for the standard pool (more voices, full 12-language catalog, voice cloning). +const MODEL = "lightning_v3.1_pro"; +const VOICE_ID = "meher"; const SPEED = 1.0; const SAMPLE_RATE = 24000; -const LANGUAGE = "en"; // en, hi, es, ta +const LANGUAGE = "en"; // en, hi, es, ta (per voice; see voice tags via /get_voices) const OUTPUT_FORMAT = "wav"; const API_BASE = "https://api.smallest.ai/waves/v1"; async function synthesize(text, apiKey) { - const response = await fetch(`${API_BASE}/${MODEL}/get_speech`, { + const response = await fetch(`${API_BASE}/tts`, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, @@ -32,6 +35,7 @@ async function synthesize(text, apiKey) { body: JSON.stringify({ text, voice_id: VOICE_ID, + model: MODEL, speed: SPEED, sample_rate: SAMPLE_RATE, language: LANGUAGE, diff --git a/text-to-speech/getting-started/python/synthesize.py b/text-to-speech/getting-started/python/synthesize.py index bb0c6fb..5c96ff0 100644 --- a/text-to-speech/getting-started/python/synthesize.py +++ b/text-to-speech/getting-started/python/synthesize.py @@ -18,11 +18,14 @@ load_dotenv() # Configuration -MODEL = "lightning-v3.1" -VOICE_ID = "sophia" +# Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices, en + hi +# on Indian voices, en on British/American voices). Set to "lightning_v3.1" +# for the standard pool (more voices, full 12-language catalog, voice cloning). +MODEL = "lightning_v3.1_pro" +VOICE_ID = "meher" SPEED = 1.0 SAMPLE_RATE = 24000 -LANGUAGE = "en" # en, hi, es, ta +LANGUAGE = "en" # en, hi, es, ta (per voice; see voice tags via /get_voices) OUTPUT_FORMAT = "wav" API_BASE = "https://api.smallest.ai/waves/v1" @@ -30,7 +33,7 @@ def synthesize(text: str, api_key: str) -> bytes: response = requests.post( - f"{API_BASE}/{MODEL}/get_speech", + f"{API_BASE}/tts", headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", @@ -38,6 +41,7 @@ def synthesize(text: str, api_key: str) -> bytes: json={ "text": text, "voice_id": VOICE_ID, + "model": MODEL, "speed": SPEED, "sample_rate": SAMPLE_RATE, "language": LANGUAGE, diff --git a/text-to-speech/quickstart-curl.sh b/text-to-speech/quickstart-curl.sh index 26eb575..8532e56 100644 --- a/text-to-speech/quickstart-curl.sh +++ b/text-to-speech/quickstart-curl.sh @@ -1,6 +1,8 @@ #!/bin/bash # Text-to-Speech Quickstart — cURL -# Generate speech from text using Lightning v3.1. +# Generate speech from text using the unified Lightning TTS route. +# Targets the Lightning v3.1 Pro pool — drop the `model` field to use the +# standard Lightning v3.1 pool instead. # # Usage: # export SMALLEST_API_KEY="your-api-key" @@ -8,10 +10,10 @@ # # Docs: https://docs.smallest.ai/waves/documentation/text-to-speech-lightning/quickstart -curl -X POST "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech" \ +curl -X POST "https://api.smallest.ai/waves/v1/tts" \ -H "Authorization: Bearer $SMALLEST_API_KEY" \ -H "Content-Type: application/json" \ - -d '{"text":"Modern problems require modern solutions.","voice_id":"magnus","sample_rate":24000,"speed":1.0,"language":"en","output_format":"wav"}' \ + -d '{"text":"Modern problems require modern solutions.","voice_id":"meher","model":"lightning_v3.1_pro","sample_rate":24000,"speed":1.0,"language":"en","output_format":"wav"}' \ --output output.wav echo "Saved output.wav ($(wc -c < output.wav) bytes)" diff --git a/text-to-speech/quickstart-javascript.js b/text-to-speech/quickstart-javascript.js index 21dfc8b..7de79a0 100644 --- a/text-to-speech/quickstart-javascript.js +++ b/text-to-speech/quickstart-javascript.js @@ -1,6 +1,9 @@ /** * Text-to-Speech Quickstart — JavaScript - * Generate speech from text using Lightning v3.1. + * Generate speech using the unified Lightning TTS route. + * + * Targets the Lightning v3.1 Pro pool — drop the `model` field (or set it to + * `"lightning_v3.1"`) to use the standard Lightning v3.1 pool instead. * * Usage: * export SMALLEST_API_KEY="your-api-key" @@ -14,7 +17,7 @@ const fs = require("fs"); const API_KEY = process.env.SMALLEST_API_KEY; const response = await fetch( - "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech", + "https://api.smallest.ai/waves/v1/tts", { method: "POST", headers: { @@ -23,7 +26,8 @@ const response = await fetch( }, body: JSON.stringify({ text: "Modern problems require modern solutions.", - voice_id: "magnus", + voice_id: "meher", + model: "lightning_v3.1_pro", sample_rate: 24000, speed: 1.0, language: "en", diff --git a/text-to-speech/quickstart-python.py b/text-to-speech/quickstart-python.py index f51d6d2..18ee41c 100644 --- a/text-to-speech/quickstart-python.py +++ b/text-to-speech/quickstart-python.py @@ -1,6 +1,9 @@ """ Text-to-Speech Quickstart — Python -Generate speech from text using Lightning v3.1. +Generate speech using the unified Lightning TTS route. + +Targets the Lightning v3.1 Pro pool — drop the `model` field (or set it to +`"lightning_v3.1"`) to use the standard Lightning v3.1 pool instead. Usage: export SMALLEST_API_KEY="your-api-key" @@ -15,14 +18,15 @@ API_KEY = os.environ["SMALLEST_API_KEY"] response = requests.post( - "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech", + "https://api.smallest.ai/waves/v1/tts", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", }, json={ "text": "Modern problems require modern solutions.", - "voice_id": "magnus", + "voice_id": "meher", + "model": "lightning_v3.1_pro", "sample_rate": 24000, "speed": 1.0, "language": "en", diff --git a/text-to-speech/quickstart/README.md b/text-to-speech/quickstart/README.md index 6dd03f1..ff15e26 100644 --- a/text-to-speech/quickstart/README.md +++ b/text-to-speech/quickstart/README.md @@ -7,15 +7,17 @@ Get your API key at [app.smallest.ai](https://app.smallest.ai/dashboard/settings ## curl (Fastest — zero install) ```bash -curl -X POST https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech \ +curl -X POST https://api.smallest.ai/waves/v1/tts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ - -d '{"text": "Hello from Smallest AI!", "voice_id": "sophia", "sample_rate": 24000, "output_format": "wav"}' \ + -d '{"text": "Hello from Smallest AI!", "voice_id": "meher", "model": "lightning_v3.1_pro", "sample_rate": 24000, "output_format": "wav"}' \ --output hello.wav && echo "Done! Play hello.wav" ``` Replace `YOUR_API_KEY` with your key. That's it — you'll have a WAV file in 2 seconds. +> The example above uses the Lightning v3.1 Pro pool. Omit `"model"` (or set it to `"lightning_v3.1"`) to use the standard pool — that one has more voices, the full 12-language catalog, plus voice cloning. + ## Python ```bash diff --git a/text-to-speech/quickstart/quickstart.js b/text-to-speech/quickstart/quickstart.js index eafb828..a397598 100644 --- a/text-to-speech/quickstart/quickstart.js +++ b/text-to-speech/quickstart/quickstart.js @@ -7,10 +7,10 @@ if (!apiKey) { process.exit(1); } -fetch("https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech", { +fetch("https://api.smallest.ai/waves/v1/tts", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" }, - body: JSON.stringify({ text: "Hello! Welcome to Smallest AI. This is your first text-to-speech generation.", voice_id: "sophia", sample_rate: 24000, output_format: "wav" }), + body: JSON.stringify({ text: "Hello! Welcome to Smallest AI. This is your first text-to-speech generation.", voice_id: "meher", model: "lightning_v3.1_pro", sample_rate: 24000, output_format: "wav" }), }) .then((r) => { if (!r.ok) return r.text().then((t) => { throw new Error(`API error (${r.status}): ${t}`); }); diff --git a/text-to-speech/quickstart/quickstart.py b/text-to-speech/quickstart/quickstart.py index 01551ce..5f1f977 100644 --- a/text-to-speech/quickstart/quickstart.py +++ b/text-to-speech/quickstart/quickstart.py @@ -10,14 +10,15 @@ sys.exit(1) response = requests.post( - "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech", + "https://api.smallest.ai/waves/v1/tts", headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", }, json={ "text": "Hello! Welcome to Smallest AI. This is your first text-to-speech generation.", - "voice_id": "sophia", + "voice_id": "meher", + "model": "lightning_v3.1_pro", "sample_rate": 24000, "output_format": "wav", }, diff --git a/text-to-speech/streaming-python.py b/text-to-speech/streaming-python.py index adea671..1995901 100644 --- a/text-to-speech/streaming-python.py +++ b/text-to-speech/streaming-python.py @@ -2,6 +2,10 @@ TTS Streaming — Python Stream speech via SSE (Server-Sent Events) for real-time playback. +Targets the Lightning v3.1 Pro pool on the unified /waves/v1/tts/live +endpoint. Drop the `model` field (or set it to "lightning_v3.1") to use the +standard Lightning v3.1 pool instead. + Usage: export SMALLEST_API_KEY="your-api-key" pip install requests @@ -10,21 +14,25 @@ Docs: https://docs.smallest.ai/waves/documentation/text-to-speech-lightning/streaming """ +import base64 +import json import os import wave + import requests API_KEY = os.environ["SMALLEST_API_KEY"] response = requests.post( - "https://api.smallest.ai/waves/v1/lightning-v3.1/stream", + "https://api.smallest.ai/waves/v1/tts/live", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", }, json={ "text": "Modern problems require modern solutions.", - "voice_id": "magnus", + "voice_id": "meher", + "model": "lightning_v3.1_pro", "sample_rate": 24000, }, stream=True, @@ -32,13 +40,31 @@ response.raise_for_status() +# SSE frames look like: +# event: audio +# data: {"audio": ""} +# +# data: {"done": true} +# We collect base64 PCM payloads then write them with a WAV header. +chunks: list[bytes] = [] +for line in response.iter_lines(): + if not line: + continue + decoded = line.decode("utf-8", "replace") + if not decoded.startswith("data:"): + continue + payload = json.loads(decoded[5:].strip()) + if payload.get("done"): + break + audio_b64 = payload.get("audio") + if audio_b64: + chunks.append(base64.b64decode(audio_b64)) + +pcm = b"".join(chunks) with wave.open("streamed.wav", "wb") as wf: wf.setnchannels(1) wf.setsampwidth(2) wf.setframerate(24000) - total = 0 - for chunk in response.iter_content(chunk_size=4096): - wf.writeframes(chunk) - total += len(chunk) + wf.writeframes(pcm) -print(f"Saved streamed.wav ({total:,} bytes)") +print(f"Saved streamed.wav ({len(pcm):,} PCM bytes from {len(chunks)} chunks)") diff --git a/text-to-speech/streaming/README.md b/text-to-speech/streaming/README.md index 2e9ffc1..f51018c 100644 --- a/text-to-speech/streaming/README.md +++ b/text-to-speech/streaming/README.md @@ -60,15 +60,17 @@ node stream_ws.js "This text will be streamed via WebSocket." | Parameter | Description | Default | |-----------|-------------|---------| -| `MODEL` | TTS model | `lightning-v3.1` | -| `VOICE_ID` | Voice to use | `sophia` | +| `MODEL` | TTS pool (`lightning_v3.1_pro` or `lightning_v3.1`) | `lightning_v3.1_pro` | +| `VOICE_ID` | Voice to use | `meher` | | `SAMPLE_RATE` | Audio sample rate in Hz | `24000` | | `SPEED` | Playback speed (0.5–2.0) | `1.0` | ## API Reference -- [Lightning v3.1 SSE Streaming](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/stream-lightning-v-31-speech) -- [Lightning v3.1 WebSocket](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/text-to-speech-v-3-1) +- [Synthesize speech (REST sync)](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/synthesize-speech) +- [Stream speech (SSE)](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/synthesize-speech-sse) +- [Live TTS WebSocket](https://docs.smallest.ai/waves/api-reference/api-reference/text-to-speech/live-tts-web-socket) +- [Lightning v3.1 Pro model card](https://docs.smallest.ai/waves/model-cards/text-to-speech/lightning-v-3-1-pro) ## Next Steps diff --git a/text-to-speech/streaming/javascript/stream_sse.js b/text-to-speech/streaming/javascript/stream_sse.js index ee813a8..531695a 100644 --- a/text-to-speech/streaming/javascript/stream_sse.js +++ b/text-to-speech/streaming/javascript/stream_sse.js @@ -14,8 +14,10 @@ const fs = require("fs"); -const MODEL = "lightning-v3.1"; -const VOICE_ID = "sophia"; +// Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices) +// or "lightning_v3.1" for the standard pool (more voices + voice cloning). +const MODEL = "lightning_v3.1_pro"; +const VOICE_ID = "meher"; const SAMPLE_RATE = 24000; const SPEED = 1.0; @@ -50,7 +52,7 @@ async function streamSpeech(text, apiKey) { const chunks = []; let chunkCount = 0; - const response = await fetch(`${API_BASE}/${MODEL}/stream`, { + const response = await fetch(`${API_BASE}/tts/live`, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, @@ -59,6 +61,7 @@ async function streamSpeech(text, apiKey) { body: JSON.stringify({ text, voice_id: VOICE_ID, + model: MODEL, sample_rate: SAMPLE_RATE, speed: SPEED, }), diff --git a/text-to-speech/streaming/javascript/stream_ws.js b/text-to-speech/streaming/javascript/stream_ws.js index e985c31..c768989 100644 --- a/text-to-speech/streaming/javascript/stream_ws.js +++ b/text-to-speech/streaming/javascript/stream_ws.js @@ -17,12 +17,14 @@ const fs = require("fs"); const WebSocket = require("ws"); -const MODEL = "lightning-v3.1"; -const VOICE_ID = "sophia"; +// Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices) +// or "lightning_v3.1" for the standard pool (more voices + voice cloning). +const MODEL = "lightning_v3.1_pro"; +const VOICE_ID = "meher"; const SAMPLE_RATE = 24000; const SPEED = 1.0; -const WS_URL = `wss://api.smallest.ai/waves/v1/${MODEL}/get_speech/stream`; +const WS_URL = "wss://api.smallest.ai/waves/v1/tts/live"; function addWavHeader(pcmData, sampleRate, channels = 1, bitsPerSample = 16) { const dataSize = pcmData.length; @@ -63,6 +65,7 @@ function streamSpeech(text, apiKey) { JSON.stringify({ text, voice_id: VOICE_ID, + model: MODEL, sample_rate: SAMPLE_RATE, speed: SPEED, }) diff --git a/text-to-speech/streaming/python/stream_sse.py b/text-to-speech/streaming/python/stream_sse.py index 2061f76..2582749 100644 --- a/text-to-speech/streaming/python/stream_sse.py +++ b/text-to-speech/streaming/python/stream_sse.py @@ -23,8 +23,10 @@ load_dotenv() -MODEL = "lightning-v3.1" -VOICE_ID = "sophia" +# Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices) +# or "lightning_v3.1" for the standard pool (more voices + voice cloning). +MODEL = "lightning_v3.1_pro" +VOICE_ID = "meher" SAMPLE_RATE = 24000 SPEED = 1.0 @@ -62,7 +64,7 @@ def stream_speech(text: str, api_key: str) -> bytes: chunk_count = 0 response = requests.post( - f"{API_BASE}/{MODEL}/stream", + f"{API_BASE}/tts/live", headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", @@ -70,6 +72,7 @@ def stream_speech(text: str, api_key: str) -> bytes: json={ "text": text, "voice_id": VOICE_ID, + "model": MODEL, "sample_rate": SAMPLE_RATE, "speed": SPEED, }, diff --git a/text-to-speech/streaming/python/stream_ws.py b/text-to-speech/streaming/python/stream_ws.py index b2a3d30..d84b7a6 100644 --- a/text-to-speech/streaming/python/stream_ws.py +++ b/text-to-speech/streaming/python/stream_ws.py @@ -24,12 +24,14 @@ load_dotenv() -MODEL = "lightning-v3.1" -VOICE_ID = "sophia" +# Set MODEL to "lightning_v3.1_pro" for the Pro pool (curated voices) +# or "lightning_v3.1" for the standard pool (more voices + voice cloning). +MODEL = "lightning_v3.1_pro" +VOICE_ID = "meher" SAMPLE_RATE = 24000 SPEED = 1.0 -WS_URL = f"wss://api.smallest.ai/waves/v1/{MODEL}/get_speech/stream" +WS_URL = "wss://api.smallest.ai/waves/v1/tts/live" def add_wav_header(pcm_data: bytes, sample_rate: int, channels: int = 1, bits_per_sample: int = 16) -> bytes: @@ -68,6 +70,7 @@ async def stream_speech(text: str, api_key: str) -> bytes: await ws.send(json.dumps({ "text": text, "voice_id": VOICE_ID, + "model": MODEL, "sample_rate": SAMPLE_RATE, "speed": SPEED, })) From 7dd9e671907ccd2826ddc5e9dbc5a0620ce8b84b Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Thu, 21 May 2026 00:38:18 +0530 Subject: [PATCH 2/2] fix(readme): clarify LANGUAGE column on the Pro default Bot MAJOR (CORRECTNESS) on PR #44: with MODEL defaulting to lightning_v3.1_pro, the LANGUAGE table previously listed `es` and `ta` as valid options. Pro voices only support `en` (all accents) and `hi` (Indian voices). Sending `es`/`ta` to Pro returns an API error. Replace the misleading parenthetical with a Pro-vs-Standard-aware description that points users to MODEL=lightning_v3.1 when they need the wider 12-language catalog. --- text-to-speech/getting-started/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text-to-speech/getting-started/README.md b/text-to-speech/getting-started/README.md index 83580e1..40645fe 100644 --- a/text-to-speech/getting-started/README.md +++ b/text-to-speech/getting-started/README.md @@ -44,7 +44,7 @@ Output is saved to `output.wav` in the current directory. | `VOICE_ID` | Voice to use (see [Voices](../voices/)) | `meher` | | `SPEED` | Playback speed (0.5 to 2.0) | `1.0` | | `SAMPLE_RATE` | Audio sample rate in Hz | `24000` | -| `LANGUAGE` | Language code (`en`, `hi`, `es`, `ta`) | `en` | +| `LANGUAGE` | Language code — Pro pool: `en` (all voices) or `hi` (Indian voices); switch `MODEL` to `lightning_v3.1` to use `es`, `ta`, and 9 more | `en` | | `OUTPUT_FORMAT` | Output format (`wav`, `pcm`, `mp3`, `mulaw`) | `wav` | ## API Reference