Python SDK
SDK Download
Setup
Download the Python SDK archive from SDK Overview, extract it, then install it into a virtual environment.
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 upload_and_transcribe
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.
import os
import time
import koldan_sdk
from koldan_sdk.api.speech_transcriptions_api import SpeechTranscriptionsApi
from koldan_sdk.models.speech_service_diarization_options import SpeechServiceDiarizationOptions
from koldan_sdk.models.speech_service_transcription_language_options import SpeechServiceTranscriptionLanguageOptions
from koldan_sdk.models.speech_service_transcription_options import SpeechServiceTranscriptionOptions
from koldan_sdk.models.transcription_job_status import TranscriptionJobStatus
config = koldan_sdk.Configuration(host=os.environ["KOLDAN_BASE_URL"])
config.api_key["apiKey"] = os.environ["KOLDAN_API_KEY"]
with koldan_sdk.ApiClient(config) as client:
api = SpeechTranscriptionsApi(client)
with open(os.environ["KOLDAN_FILE_PATH"], "rb") as source:
transcription_options = SpeechServiceTranscriptionOptions(
model="general",
language=SpeechServiceTranscriptionLanguageOptions(),
punctuation=False,
capitalization=False
)
diarization_options = SpeechServiceDiarizationOptions(
enabled=False
)
response = api.upload_and_transcribe(
name="meeting-recording",
transcription=transcription_options.to_json(),
file=(os.path.basename(source.name), source.read()),
diarization=diarization_options.to_json(),
)
job = response.job
while True:
job = api.get_job(job.id)
print(f"Job status: {job.status}")
if job.status in {TranscriptionJobStatus.COMPLETED, TranscriptionJobStatus.FAILED, TranscriptionJobStatus.CANCELLED}:
break
time.sleep(2)
if job.status == TranscriptionJobStatus.COMPLETED:
print(job.result.text)
else:
print(job.errors)
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.