Use video-to-text-python to upload media, create transcription tasks, and poll for results.
The Python client wraps the public upload and task APIs with typed sync and async clients.
Install
Section titled “Install”pip install video-to-text-pythonInitialize
Section titled “Initialize”import os
from video_to_text import VideoToTextClient
client = VideoToTextClient( api_key=os.environ["VTT_API_KEY"],)Transcribe a file
Section titled “Transcribe a file”from pathlib import Path
task = client.transcriptions.transcribe_file( Path("meeting.mp4"), language="Auto", timestamp_mode="CHUNK", transcription_mode="balanced", timeout=600,)
print(task.full_text)Use precision when accuracy is more important than credit cost.
Upload and create manually
Section titled “Upload and create manually”upload = client.uploads.create({ "filename": "meeting.mp4", "mimetype": "video/mp4",})
content = Path("meeting.mp4").read_bytes()client.uploads.put(upload.upload_url, content, mimetype="video/mp4")
asset = client.uploads.complete(upload.upload_id, { "fileKey": upload.file_key, "fileUrl": upload.file_url, "filename": "meeting.mp4", "mimetype": "video/mp4", "fileSize": len(content),})
created = client.tasks.create({ "assetId": asset.asset_id, "language": "Auto", "timestampMode": "CHUNK", "transcriptionMode": "balanced",})
result = client.tasks.wait(created.transcript_id)print(result.full_text)Async client
Section titled “Async client”from video_to_text import AsyncVideoToTextClient
async with AsyncVideoToTextClient( api_key=os.environ["VTT_API_KEY"],) as client: task = await client.transcriptions.transcribe_file( Path("meeting.mp4"), transcription_mode="balanced", ) print(task.full_text)Task results
Section titled “Task results”tasks.wait() returns when the task reaches SUCCEEDED. If the task reaches FAILED or CANCELED, the client raises APIError and uses show_error as the error detail when available.
Task details include full_text, chunks, words, source_duration_ms, result_language, transcription_mode, and billed_credits.
Errors
Section titled “Errors”from video_to_text import APIError, RateLimitError, UploadError
try: task = client.transcriptions.transcribe_file( Path("meeting.mp4"), transcription_mode="balanced", )except RateLimitError: print("Please retry later.")except UploadError: print("The media upload did not complete.")except APIError as error: print(error.error_code, error.problem.detail)Resources
Section titled “Resources”For source code, issues, and contributions, visit the video-to-text-python GitHub repository. Install the latest video-to-text-python package from PyPI.