Java SDK
SDK Download
Setup
Download the Java SDK archive from SDK Overview, extract it, install it into your local Maven repository, and then add it to your application.
Install the generated SDK:
Add the dependency to your project:
<dependency>
<groupId>com.dixilang.koldan</groupId>
<artifactId>koldan-sdk</artifactId>
<version>YOUR_SDK_VERSION</version>
</dependency>
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.
package com.example;
import com.dixilang.koldan.sdk.ApiClient;
import com.dixilang.koldan.sdk.Configuration;
import com.dixilang.koldan.sdk.JSON;
import com.dixilang.koldan.sdk.api.SpeechTranscriptionsApi;
import com.dixilang.koldan.sdk.auth.ApiKeyAuth;
import com.dixilang.koldan.sdk.model.TranscriptionJobStatus;
import java.io.File;
import java.util.Set;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath(System.getenv("KOLDAN_BASE_URL"));
((ApiKeyAuth) client.getAuthentication("apiKey")).setApiKey(System.getenv("KOLDAN_API_KEY"));
SpeechTranscriptionsApi api = new SpeechTranscriptionsApi(client);
var response = api.uploadAndTranscribe(
"meeting-recording",
"{\"model\":\"general\",\"punctuation\":false,\"capitalization\":false}",
null,
new File(System.getenv("KOLDAN_FILE_PATH")),
null,
null,
null,
null,
"{\"enabled\":false}",
null,
null,
null
);
var job = response.getJob();
while (true) {
job = api.getJob(job.getId());
System.out.println("Job status: " + job.getStatus());
if (Set.of(TranscriptionJobStatus.COMPLETED, TranscriptionJobStatus.FAILED, TranscriptionJobStatus.CANCELLED).contains(job.getStatus())) {
break;
}
Thread.sleep(2000);
}
System.out.println(TranscriptionJobStatus.COMPLETED.equals(job.getStatus())
? job.getResult().getText()
: JSON.serialize(job.getErrors()));
}
}
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.