Documentation Index
Fetch the complete documentation index at: https://dokulabs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Create Speech
- Python
- NodeJS
from pathlib import Path
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
model= "tts-1",
voice= "alloy",
input= "The quick brown fox jumped over the lazy dog."
)
response.stream_to_file(speech_file_path)
import fs from "fs";
import path from "path";
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
const speechFile = path.resolve("./speech.mp3");
async function main() {
const mp3 = await openai.audio.speech.create({
model: "tts-1",
voice: "alloy",
input: "Today is a wonderful day to build something people love!",
});
console.log(speechFile);
const buffer = Buffer.from(await mp3.arrayBuffer());
await fs.promises.writeFile(speechFile, buffer);
}
main();

