Platform · Model families
TTS
Implement Text-to-Speech — batch synthesis + optional realtime streaming.
Batch mode synthesises an audio buffer in one shot; realtime streams chunks bidirectionally.
Define the capability
typescript
import { defineModels } from "@scrydon/sdk-authoring/extensions/define";
import type { TTSCapabilityConfig } from "@scrydon/sdk-authoring/extensions/capabilities/tts";
const ttsCapability: TTSCapabilityConfig = {
models: [
{ id: "tts-standard", name: "Standard TTS", voices: 6, benchmarks: [{ name: "MOS", score: 3.5, source: "Internal" }] },
{ id: "tts-hd", name: "HD TTS", voices: 6, benchmarks: [{ name: "MOS", score: 4.2, source: "Internal" }] },
],
defaultModel: "tts-standard",
// Batch mode — send text, get audio back
async synthesize(request) {
const response = await fetch("https://api.example.com/v1/synthesize", {
method: "POST",
headers: {
Authorization: `Bearer ${request.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
text: request.text,
voice: request.voice,
model: request.model,
speed: request.speed,
}),
});
return {
audioBuffer: await response.arrayBuffer(),
format: "mp3",
mimeType: "audio/mpeg",
};
},
// Realtime streaming (optional)
realtime: {
protocol: "websocket",
async createSession(config) {
// The wire protocol is your vendor's; return a RealtimeSession.
const socket = new WebSocket("wss://api.example.com/v1/realtime-tts");
await new Promise((resolve, reject) => {
socket.addEventListener("open", resolve, { once: true });
socket.addEventListener("error", reject, { once: true });
});
socket.send(JSON.stringify({ type: "start", apiKey: config.apiKey, voice: config.voice, model: config.model }));
return {
sessionId: crypto.randomUUID(),
send: (chunk) => socket.send(chunk),
onMessage: (handler) =>
socket.addEventListener("message", (event) =>
handler({ type: "audio", data: event.data, timestamp: Date.now() })
),
close: async () => socket.close(),
};
},
features: { streamingInput: true, streamingOutput: true },
},
};
// One model family per runtime; list it under defineExtension()'s provides.models.
export const ttsModels = defineModels({
id: "my-service-tts",
name: "My Service Text-to-Speech",
family: "tts",
runtime: ttsCapability,
});Model metadata
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique model identifier (e.g. "tts-hd") |
name | string | yes | Display name in the UI |
voices | number | no | Number of available voice presets |
benchmarks | BenchmarkScore[] | no | MOS scores — higher is better |
Standard TTS benchmark is MOS (Mean Opinion Score, 1–5) — higher is better. voices tells the UI how many voice presets to surface.