🚀 Introducing MARS8 Series — Four Powerful Variants | Available on All Major Clouds | Learn about the model here
🚀 Introducing MARS8 Series — Four Powerful Variants | Available on All Major Clouds | Learn about the model here
Retrieves the result of the transcription run using the provided run_id.
curl --request GET \
--url https://client.camb.ai/apis/transcription-result/{run_id} \
--header 'x-api-key: <api-key>'[
{
"start": 123,
"end": 123,
"text": "<string>",
"speaker": "<string>"
}
]Access the detailed transcription of your media content through this powerful endpoint. When your transcription process completes, this API provides a comprehensive text representation of your audio or video content with precise timing information and speaker identification. This transcription data serves as the foundation for numerous content enhancement workflows, including subtitling, content analysis, and accessibility improvements.Documentation Index
Fetch the complete documentation index at: https://docs.camb.ai/llms.txt
Use this file to discover all available pages before exploring further.
run_id that was assigned when you initially submitted your transcription request. This identifier allows our system to locate your specific transcription results within our processing infrastructure.
format_type): Choose how your transcription is structured
txt: Plain text format with speaker labels and timestamps (default)srt: SubRip Text format, ready for subtitle integration in most video playersvtt: WebVTT format, optimized for web-based video players and HTML5 applicationsdata_type): Determine how you’ll receive the transcription data
file: Receive a pre-signed URL to download the complete transcription file (default)json: Receive the raw transcription data directly in the API responseimport requests
import json
import pandas as pd
from datetime import timedelta
# Authentication details
headers = {
"x-api-key": "your-api-key", # Replace with your actual API key
"Content-Type": "application/json"
}
def get_transcription(run_id, format_type="txt", data_type="file"):
"""
Fetches the complete transcription for a processed media file.
Parameters:
run_id (int): The unique identifier for your transcription task
format_type (str): Output format - 'txt', 'srt' or 'vtt'
data_type (str): How to receive data - 'file' for URL or 'json' for raw data
Returns:
If data_type is 'file': A URL to download the transcription file
If data_type is 'json': An array of transcription segments with timing and speaker information
"""
try:
# Build query parameters based on user preferences
params = {
"format_type": format_type,
"data_type": data_type
}
# Request the transcription with specified format and type
response = requests.get(
f"https://client.camb.ai/apis/transcription-result/{run_id}",
headers=headers,
params=params # Include our format preferences in the request
)
# Ensure successful response
response.raise_for_status()
# Parse the response based on the requested data_type
result = response.json()
if data_type == "file":
# For file requests, we receive a URL to download the transcript
print(f"Successfully retrieved transcription file URL in {format_type} format")
print(f"Download URL: {result['file_url']}")
print(f"URL will expire in 24 hours - download your file soon")
return result['file_url']
else:
# For JSON requests, we receive the transcription data directly
transcription_data = result['segments']
print(f"Successfully retrieved transcription with {len(transcription_data)} segments")
return transcription_data
except requests.exceptions.RequestException as e:
print(f"Error retrieving transcription: {e}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response details: {e.response.text}")
return None
# Example 1: Get a downloadable SRT file for subtitle integration
run_id = 12345
srt_url = get_transcription(run_id, format_type="srt", data_type="file")
print(f"You can now download the SRT file and import it directly into your video editor")
# Example 2: Get raw JSON data for analysis
run_id = 12345
transcription = get_transcription(run_id, format_type="txt", data_type="json")
# Let's analyze the JSON data if we received it
if transcription and isinstance(transcription, list):
# Convert to DataFrame for easier manipulation
df = pd.DataFrame(transcription)
# Format timestamps as human-readable
df['duration'] = df.apply(lambda row: round(row['end'] - row['start'], 2), axis=1)
df['start_formatted'] = df['start'].apply(lambda x: str(timedelta(seconds=x)))
df['end_formatted'] = df['end'].apply(lambda x: str(timedelta(seconds=x)))
# Display a sample of the transcription
print("\nTranscription Preview:")
for i, row in df.head(5).iterrows():
print(f"[{row['start_formatted']} → {row['end_formatted']}] {row['speaker']}: {row['text']}")
# Generate some basic analytics
print("\nTranscription Statistics:")
print(f"Total duration: {str(timedelta(seconds=df['end'].max()))}")
print(f"Unique speakers: {df['speaker'].nunique()}")
print(f"Most frequent speaker: {df['speaker'].value_counts().idxmax()}")
# Export to various formats
df.to_csv("transcription.csv", index=False)
print("\nTranscription exported to CSV for further analysis")
data_type parameter you specify in your request. Let’s explore both options in detail:
data_type=json)| Field | Description |
|---|---|
start | The precise starting point of the speech segment (in seconds) |
end | The exact ending point of the speech segment (in seconds) |
text | The verbatim transcription of the spoken content in this segment |
speaker | Identifier for the person speaking during this segment |
data_type=file)data_type=file), the response provides a pre-signed URL that points to a file containing your transcription in the format you specified:
| Field | Description |
|---|---|
file_url | A temporary URL allowing you to download the transcription file |
expiry | Timestamp indicating when the download URL will expire |
format_type selection:
format_type=txt)[00:00:05 - 00:00:12] Speaker 1: Welcome to our discussion on artificial intelligence.
[00:00:13 - 00:00:18] Speaker 2: Thank you for having me. I'm excited to share insights.
format_type=srt)1
00:00:05,000 --> 00:00:12,000
Speaker 1: Welcome to our discussion on artificial intelligence.
2
00:00:13,000 --> 00:00:18,000
Speaker 2: Thank you for having me. I'm excited to share insights.
format_type=vtt)WEBVTT
00:00:05.000 --> 00:00:12.000
Speaker 1: Welcome to our discussion on artificial intelligence.
00:00:13.000 --> 00:00:18.000
Speaker 2: Thank you for having me. I'm excited to share insights.
format_type=txt) is ideal when you need:
format_type=srt) is your best choice when:
format_type=vtt) shines when:
The x-api-key is a custom header required for authenticating requests to our API. Include this header in your request with the appropriate API key value to securely access our endpoints. You can find your API key(s) in the 'API' section of our studio website.
The unique identifier for the run, which was generated during the transcription creation process and returned upon task completion. The unique identifier for the run, which was generated during the creation process and returned upon task completion.
When set to true, this parameter enables the generation of word-level timestamps in the response. These timestamps provide precise timing information for each word in the processed audio.
Successful Response
The start time (in seconds) of the dialogue.
The end time (in seconds) of the dialogue.
The actual text content of the dialogue spoken by the speaker.
The name or identifier of the speaker delivering the dialogue.
curl --request GET \
--url https://client.camb.ai/apis/transcription-result/{run_id} \
--header 'x-api-key: <api-key>'[
{
"start": 123,
"end": 123,
"text": "<string>",
"speaker": "<string>"
}
]