Skip to content

Speech to Text

CompactifAI’s speech-to-text capability delivers fast, reliable transcripts from common audio formats while staying fully compatible with the OpenAI Whisper API surface. The endpoint accepts multipart form uploads and returns JSON, plain text, or verbose JSON depending on response_format. It is ideal for meeting notes, support calls, or media captioning.

import requests
API_URL = "https://api.compactif.ai/v1/audio/transcriptions"
API_KEY = "your_api_key_here"
headers = {
"Authorization": f"Bearer {API_KEY}"
}
payload = {
"model": "whisper-large-v3",
"language": "en",
"temperature": 0,
"response_format": "json"
}
file_name = "meeting_minutes.mp3"
file_content_type = "audio/mpeg"
with open(file_name, "rb") as audio_file:
response = requests.post(API_URL, headers=headers, data=payload, files={"file": (file_name, audio_file, file_content_type)})
print(response.json()["text"])
FieldTypeDescription
filefile uploadSupported files types - .flac, .mp3, .mp4, .mpga, .m4a, .wav, .webm, .mpeg, and .ogg (Note - For .ogg and .mpeg, the system only supports audio files)
modelstringRequired model alias such as whisper-large-v3
promptstringOptional text primer to bias the transcription
temperaturenumberOptional float between 0 and 1 (defaults to provider setting)
languagestringOptional ISO language code hint (en by default)
response_formatstringOutput format: json (default), text, or verbose_json. json and verbose_json return JSON; text returns plain text (Content-Type: text/plain).
streambooleanWhether to stream back partial progress
{
"text": "Welcome to the quarterly planning meeting. Let's review the agenda.",
"logprobs": null,
"usage": {
"type": "duration",
"seconds": 12.6
}
}

With response_format=text, the response body is the transcript string only (Content-Type: text/plain). Use response_format=verbose_json when you need additional metadata such as duration, language, segments, and words.

  • Keep uploads under 25 MB for best performance; large files benefit from client-side compression.
  • Provide the language hint when you know the spoken language to reduce warm-up time.
  • Use the same headers and authentication flow as other CompactifAI endpoints; only the form payload differs.