文本转语音
const audioBuffer = await theo.tts({
text: "Welcome to Theo. How can I help you today?",
voice: "theo-voice-warm", // Optional — see table below
speed: 1.0, // Optional speed multiplier
});
// audioBuffer is an ArrayBuffer — write to file or stream to client
import { writeFileSync } from "fs";
writeFileSync("output.mp3", Buffer.from(audioBuffer));
语音
| 语音 | 特点 |
|---|---|
theo-voice-classic | 中性、通用——默认选项 |
theo-voice-bright | 明亮、清晰、活泼 |
theo-voice-storyteller | 叙事感强、富有表现力 |
theo-voice-deep | 低沉、权威 |
theo-voice-warm | 温暖、专业 |
theo-voice-soft | 柔和、沉稳 |
voice 或传入未知值时,将回退为 theo-voice-classic。
语音转文本
const file = new Blob([audioBytes], { type: "audio/mp3" });
const result = await theo.stt(file, "en");
console.log(result.text); // Transcribed text
console.log(result.language); // Detected language
console.log(result.duration_seconds); // Audio duration
console.log(result.usage.cost_cents); // Cost
