🚀 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 detailed results about a specific translated story using the provided run_id and target_language parameters.
curl --request GET \
--url https://client.camb.ai/apis/translated-story-result/{run_id}/{target_language} \
--header 'x-api-key: <api-key>'{
"audio_url": "<string>",
"dialogue_url": "<string>",
"transcript": [
{
"start": 123,
"end": 123,
"text": "<string>",
"speaker": "<string>"
}
]
}Access the complete results of your story translation process with our comprehensive retrieval endpoint. This powerful interface delivers everything you need to utilize your newly translated content, including professionally synthesized audio, formatted dialogue text, and optional transcription data. The system provides these assets in a well-structured format that makes integration into your applications or content management systems straightforward and efficient.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.
import requests
import json
# Your API authentication
headers = {
"x-api-key": "your-api-key", # Replace with your actual API key
"Content-Type": "application/json"
}
def get_translation_result(run_id, target_language, include_transcript=False):
"""
Retrieves the complete results of a translated story including audio and text assets.
Parameters:
- run_id: The ID of the original story that was translated
- target_language: The language code of the target language used for translation
- include_transcript: Boolean indicating whether to include the detailed transcript (default: False)
Returns:
- A dictionary containing all available translation assets
"""
try:
# Build the request URL with optional query parameter
base_url = f"https://client.camb.ai/apis/translated-story-result/{run_id}/{target_language}"
if include_transcript:
url = f"{base_url}?include_transcript=true"
else:
url = base_url
# Request the translation results
response = requests.get(
url,
headers=headers
)
# Verify the request was successful
response.raise_for_status()
# Parse the result information
result_data = response.json()
# Display information about the retrieved assets
print("Translation assets successfully retrieved!")
print(f"Complete Story Audio: {result_data.get('audio_url')}")
print(f"Dialogue Audio: {result_data.get('dialogue_url')}")
# Check if transcript was requested and is available
if include_transcript and 'transcript' in result_data:
print(f"Transcript entries: {len(result_data.get('transcript'))} dialogue items")
return result_data
except requests.exceptions.RequestException as e:
print(f"Error retrieving translation results: {e}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response content: {e.response.text}")
return None
# Example usage
run_id = 12345 # Replace with your actual `run_id`
target_language = 76 # Example: French language code
translation_result = get_translation_result(run_id, target_language, include_transcript=True)
def process_translation_assets(result_data, run_id):
"""
Demonstrates common ways to process and utilize the translation assets.
Parameters:
- result_data: The dictionary returned from get_translation_result()
- run_id: The ID of the translation run for file naming
"""
if not result_data:
print("No translation data available to process.")
return
# Download the complete story audio file
if 'audio_url' in result_data:
audio_response = requests.get(result_data['audio_url'])
if audio_response.status_code == 200:
# Save the audio file locally
with open(f"translated_story_{run_id}.flac", 'wb') as f:
f.write(audio_response.content)
print("Complete story audio file downloaded successfully.")
# Download the dialogue audio file
if 'dialogue_url' in result_data:
dialogue_response = requests.get(result_data['dialogue_url'])
if dialogue_response.status_code == 200:
# Save the dialogue audio file locally
with open(f"dialogue_audio_{run_id}.flac", 'wb') as f:
f.write(dialogue_response.content)
print("Dialogue audio file downloaded successfully.")
# Process the transcript if available
if 'transcript' in result_data and result_data['transcript']:
# Example: Export the transcript as a formatted text file
with open(f"transcript_{run_id}.txt", 'w', encoding='utf-8') as f:
for dialogue_item in result_data['transcript']:
speaker = dialogue_item.get('speaker', 'Narrator')
text = dialogue_item.get('text', '')
f.write(f"{speaker}: {text}\n\n")
print("Transcript exported successfully.")
# Example: Count dialogue entries by speaker
speaker_counts = {}
for dialogue_item in result_data['transcript']:
speaker = dialogue_item.get('speaker', 'Narrator')
speaker_counts[speaker] = speaker_counts.get(speaker, 0) + 1
print("Dialogue distribution by speaker:")
for speaker, count in speaker_counts.items():
print(f" - {speaker}: {count} lines")
# Process the retrieved translation assets
run_id = 12345 # Use the same run_id from earlier
if translation_result:
process_translation_assets(translation_result, run_id)
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 creation process and returned upon task completion.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150 The optional include_transcript query parameter determines whether the detailed transcript data should be included in the response.
Successful Response
The URL pointing to the generated audio file for the story.
The URL pointing to the audio file that contains the story's dialogue.
A collection of dialogue items representing the textual transcript of the story.
Hide child attributes
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/translated-story-result/{run_id}/{target_language} \
--header 'x-api-key: <api-key>'{
"audio_url": "<string>",
"dialogue_url": "<string>",
"transcript": [
{
"start": 123,
"end": 123,
"text": "<string>",
"speaker": "<string>"
}
]
}