文本轉語音
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
