JavaScript SDK
SDK Download
Setup
Download the JavaScript SDK archive from SDK Overview, extract it, then install it into your project.
Configure the shared environment variables from Getting Started, and point KOLDAN_FILE_PATH to the audio file you want to transcribe.
Upload And Transcribe With uploadAndTranscribe
The example below keeps the request intentionally minimal: upload one file, start transcription with the general model alias, poll until the job finishes, and print either the transcript or the error details.
const fs = require("fs");
const KoldanSdk = require("koldan-sdk");
const client = KoldanSdk.ApiClient.instance;
client.basePath = process.env.KOLDAN_BASE_URL;
client.authentications["apiKey"].apiKey = process.env.KOLDAN_API_KEY;
const api = new KoldanSdk.SpeechTranscriptionsApi(client);
(async () => {
const response = await api.uploadAndTranscribe(
"meeting-recording",
JSON.stringify({
model: "general",
punctuation: false,
capitalization: false,
}),
{
file: fs.createReadStream(process.env.KOLDAN_FILE_PATH),
diarization: JSON.stringify({ enabled: false }),
}
);
let job = response.job;
while (true) {
job = await api.getJob(job.id);
console.log(`Job status: ${job.status}`);
if (["COMPLETED", "FAILED", "CANCELLED"].includes(job.status)) {
break;
}
await new Promise((resolve) => setTimeout(resolve, 2000));
}
console.log(job.status === "COMPLETED" ? job.result.text : job.errors);
})().catch(console.error);
Run
Expected Result
A successful run prints Job status: ... updates and then the transcription text from your uploaded audio.
If the job fails, the example prints the error array returned by the API.