> ## 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.

# Fetch Dubbing Results in Bulk

> Retrieves the results of multiple dubbing runs simultaneously using an array of `run_id` values

Efficiently retrieve the results of multiple dubbing tasks in a single API call. This bulk endpoint allows you to fetch completed dubbing results for multiple runs at once, making it ideal for applications that need to process large volumes of content or manage multiple dubbing projects simultaneously.

## Understanding Bulk Dubbing Results

When you request the results of multiple completed dubbing tasks, our system returns a comprehensive collection of results, with each entry containing:

* **Dubbed Video**: A complete video file with the original visuals and newly generated voiceover in your target language.
* **Dubbed Audio**: An isolated audio track containing only the synthesized speech in your target language.
* **Complete Transcript**: A detailed, time-coded transcript of the dubbed content with speaker identification.

This bulk approach significantly reduces the number of API calls needed when working with multiple dubbing projects, improving efficiency and reducing latency in your applications.

## Accessing Multiple Dubbed Results

To retrieve results for multiple dubbing tasks, you'll need to provide an array of `run_id` values in the request payload. Each `run_id` uniquely identifies a specific dubbing task that was created through our dubbing pipeline.

### Request Payload Structure

The request body should contain an array of run IDs:

```json theme={null}
{
  "run_ids": [12345, 67890, 24680, 13579]
}
```

## Example Request with Python

Here's how to fetch multiple dubbing results using Python:

```python [expandable] theme={null}
import requests

# Your API authentication
headers = {
    "x-api-key": "your-api-key",  # Replace with your actual API key
    "Content-Type": "application/json",
}


def get_bulk_dubbing_results(run_ids):
    """
    Retrieves the results of multiple dubbing tasks in a single request.
    Returns a collection of dubbing results with media URLs and transcripts.
    """
    payload = {"run_ids": run_ids}

    try:
        response = requests.post(
            "https://client.camb.ai/apis/dubbing-results",
            headers=headers,
            json=payload,
        )

        # Verify the request was successful
        response.raise_for_status()

        # Extract the bulk dubbing results
        results_data = response.json()

        print(f"Successfully retrieved results for {len(results_data)} dubbing runs")

        # Process each result
        for key in results_data:
            print(f"Run ID: {key}")
            print(f"\nVideo URL: {results_data.get(key, {}).get('video_url')}")
            print(f"\nAudio URL: {results_data.get(key, {}).get('audio_url')}")
            print(f"\nTranscript entries: {len(results_data.get(key, {}).get('transcript', []))}")

        return results_data

    except requests.exceptions.RequestException as e:
        print(f"Error retrieving bulk dubbing results: {e}")
        if hasattr(e, "response") and e.response is not None:
            print(f"Response content: {e.response.text}")
        return None


# Example usage with multiple run IDs
run_ids = [41707, 40413]  # Replace with your actual run IDs
bulk_results = get_bulk_dubbing_results(run_ids)

# Process successful results
if bulk_results:
    print(f"\n{len(bulk_results)} runs completed successfully:")

    for result in bulk_results:
        run_id = result
        transcript = bulk_results.get(run_id, {}).get("transcript", [])

        if transcript:
            print(f"\nRun ID {run_id} - Transcript Preview:")
            for i, dialogue in enumerate(transcript[:2]):  # Show first 2 entries
                speaker = dialogue.get("speaker", "Unknown")
                text = dialogue.get("text", "")
                start = dialogue.get("start", "")
                end = dialogue.get("end", "")
                print(f"  Speaker {speaker}: {text} [{start} - {end}]")

            if len(transcript) > 2:
                print(f"  ... and {len(transcript) - 2} more dialogue entries")
```

## Response Handling

The bulk endpoint returns results for all requested run IDs, including those that may still be processing or have failed. Each result in the response includes:

* `video_url`: URL to the dubbed video (if completed)
* `audio_url`: URL to the dubbed audio (if completed)
* `transcript`: Complete transcript with timing information (if completed)

## Best Practices

When using the bulk dubbing results endpoint:

* **Batch Size**: Limit your requests to reasonable batch sizes (recommended: 50-100 run IDs per request) to ensure optimal performance
* **Status Checking**: Always check the status of each result before attempting to access media URLs or transcripts
* **Error Handling**: Implement proper error handling for individual failed runs within the bulk response

This bulk approach streamlines your workflow when managing multiple dubbing projects, reducing API overhead and improving the efficiency of your content localization pipeline.


## OpenAPI

````yaml post /dubbing-results
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://client.camb.ai/apis
security: []
paths:
  /dubbing-results:
    post:
      tags:
        - Dub
      summary: Get Dubbing Results in Bulk
      operationId: get_dubbing_results_in_bulk_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunIDsRequestPayload'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkDubbingRunsResults'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    RunIDsRequestPayload:
      properties:
        run_ids:
          items:
            type: integer
            exclusiveMinimum: 0
          type: array
          maxItems: 5
          minItems: 2
          uniqueItems: true
          title: Run IDs
          description: >-
            An array of unique positive integers, each representing the ID of a
            specific run. You must provide between 2 and 5 IDs, and all IDs must
            correspond to the same run type (e.g., all text-to-speech or all
            dubbing runs).
          example:
            - 12345
            - 6789
      type: object
      required:
        - run_ids
      title: RunIDsRequestPayload
    BulkDubbingRunsResults:
      type: object
      title: BulkDubbingRunsResults
      additionalProperties:
        $ref: '#/components/schemas/RunInfoResponse'
      minProperties: 1
      maxProperties: 5
      description: >-
        An object containing the results of one to five dubbing runs. Each key
        in the object is a unique identifier for a run, and the corresponding
        value is the result of the dubbing run.
      example:
        '1344':
          video_url: https://example.com/video/processed_123.mp4
          audio_url: https://example.com/audio/processed_123.mp3
          transcript:
            - start: 0
              end: 5000
              text: Hello, this is a sample transcript.
              speaker: Speaker 1
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RunInfoResponse:
      properties:
        video_url:
          type: string
          title: Output Video URL
          description: Direct link to download the complete dubbed video file.
        audio_url:
          type: string
          title: Output Audio URL
          description: Direct link to download the isolated dubbed audio track.
        transcript:
          type: array
          items:
            $ref: '#/components/schemas/DialogueItem'
          title: Transcript
          description: >-
            Array of dialogue items containing speaker identification, timing
            information and textual transcript for each dialogue item.
      type: object
      title: RunInfoResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    DialogueItem:
      type: object
      description: >-
        A JSON that represents a single piece of dialogue or speech within a
        given time range. It includes details about the timing (start and end),
        the content of the dialogue (text), and the speaker who delivers the
        dialogue
      properties:
        start:
          type: number
          format: float
          title: Start Time
          description: The start time (in seconds) of the dialogue.
        end:
          type: number
          format: float
          title: End Time
          description: The end time (in seconds) of the dialogue.
        text:
          type: string
          title: Dialogue Text
          description: The actual text content of the dialogue spoken by the speaker.
        speaker:
          type: string
          title: Speaker Name
          description: The name or identifier of the speaker delivering the dialogue.
      required:
        - start
        - end
        - text
        - speaker
      title: DialogueItem
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        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.

````