TTS
Implémenter la synthèse vocale — synthèse par lots et streaming temps réel optionnel.
Le mode par lots synthétise un buffer audio en une seule fois ; le mode temps réel diffuse des fragments de manière bidirectionnelle.
Définir la capacité
import { defineCapabilityTTS } from "@scrydon/sdk-authoring/integrations/define";
const ttsCapability = defineCapabilityTTS({
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) {
// Mirror the STT realtime pattern
},
features: { streamingInput: true, streamingOutput: true },
},
});Métadonnées du modèle
| Champ | Type | Obligatoire | Description |
|---|---|---|---|
id | string | oui | Identifiant unique du modèle (ex. "tts-hd") |
name | string | oui | Nom d'affichage dans l'interface |
voices | number | non | Nombre de préréglages de voix disponibles |
benchmarks | BenchmarkScore[] | non | Scores MOS — plus élevé est mieux |
Le benchmark TTS standard est le MOS (Mean Opinion Score, 1–5) — plus élevé est mieux. voices indique à l'interface combien de préréglages de voix afficher.