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

# Get Translated Text-to-Speech Status

> Monitors the progress of a Translated Text-to-Speech task using the provided `task_id`.

This endpoint enables you to track the status of your Translated Text-to-Speech requests. When you submit content for translation and audio generation, our system processes both operations as a unified background task. This endpoint provides detailed visibility into this combined process, allowing you to determine when your translated audio will be ready for use.

## Understanding This Endpoint

To monitor your Translated Text-to-Speech task progression, send a `GET` request to this endpoint with the `task_id` you received during your initial submission. The system will return comprehensive information about the current stage of processing for both the translation and audio generation components.

## Response Structure

When querying this endpoint, you'll receive a detailed status response containing several vital pieces of information:

* **Current Status**: Indicates the overall state of your combined translation and audio generation task.
* **Completion Details**: For successfully completed tasks, includes `run_id` necessary to access your translated text and generated audio file.

### Understanding Status Codes

Your translated text-to-speech request will move through various states during processing. Each status code represents a distinct situation that your application should be prepared to handle:

| Status             | Meaning                                                           | Recommended Action                                                                      |
| :----------------- | :---------------------------------------------------------------- | :-------------------------------------------------------------------------------------- |
| `SUCCESS`          | Both translation and audio generation have completed successfully | Retrieve your translated text and audio using the provided IDs                          |
| `PENDING`          | Your request is actively being processed                          | Continue monitoring at reasonable intervals                                             |
| `TIMEOUT`          | Processing exceeded the maximum allowed duration                  | Consider breaking your content into smaller segments                                    |
| `ERROR`            | A system-level issue occurred during processing                   | Check error details for specific information about what went wrong                      |
| `PAYMENT_REQUIRED` | Your account has insufficient credits for this operation          | Visit your account's [billing page](https://studio.camb.ai/billing) to add more credits |

## Implementation Guidelines

For optimal integration of this endpoint into your applications, consider the following practices:

1. **Implement Progressive Polling**: Start with longer intervals between status checks, then decrease the interval as the task progresses through different states.

2. **Set Reasonable Timeouts**: Most translation and synthesis tasks complete within 2-5 minutes, depending on content length and complexity.

## Example Implementation in JavaScript

```javascript [expandable] theme={null}
// Monitoring a Translated Text-to-Speech task with progressive polling
async function monitorTranslatedTTSTask(taskId, apiKey) {
  console.log("Beginning task monitoring...");

  // Initial configuration
  let pollInterval = 10000; // Start with 10-second intervals
  let attempts = 0;
  const maxAttempts = 30;

  while (attempts < maxAttempts) {
    attempts++;

    try {
      // Request current task status
      const response = await fetch(`https://client.camb.ai/apis/translated-tts/${taskId}`, {
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': apiKey
        }
      });

      if (!response.ok) {
        throw new Error(`HTTP error ${response.status}`);
      }

      const statusData = await response.json();
      console.log(`Status check #${attempts}: ${statusData.status}`);

      // Adjust polling interval based on current stage
      if (statusData.status === 'PENDING') {
        console.log("Task is in progress...");


      // Handle different status types
      switch (statusData.status) {
        case 'SUCCESS':
          console.log("Task completed successfully!");
          console.log(`Run ID: ${statusData.run_id}`);
          return statusData; // Return the complete status object

        case 'PENDING':
          // Still processing, continue to next poll iteration
          break;


        case 'TIMEOUT':
          console.error("Processing time exceeded. Consider shorter content segments.");
          return null;

        case 'ERROR':
          console.error(`Processing error: ${statusData.error_message}`);
          return null;

        case 'PAYMENT_REQUIRED':
          console.error("Insufficient credits. Please add more credits to your account.");
          return null;

        default:
          console.error(`Unexpected status: ${statusData.status}`);
          return null;
      }

      // Wait before next check
      console.log(`Checking again in ${pollInterval/1000} seconds...`);
      await new Promise(resolve => setTimeout(resolve, pollInterval));

    } catch (error) {
      console.error(`Error checking status: ${error.message}`);
      return null;
    }
  }

  console.error("Maximum monitoring attempts reached. Task may still be processing.");
  return null;
}
```

## Performance Considerations

When integrating this status-monitoring endpoint into your applications, keep these performance factors in mind:

* **Request Frequency**: Avoid polling more frequently than every 3-5 seconds to prevent unnecessary load on both client and server.
* **Timeout Handling**: For longer texts, processing may take several minutes. Set appropriate client-side timeout expectations.
* **Error Resilience**: Network interruptions shouldn't affect your task processing; the task continues running server-side regardless of status checks.

## Next Steps

Once your task reaches the `SUCCESS` status, you'll receive a `run_id` for accessing both:

1. The generated audio file through the [`/tts-result/{run_id}`](get-tts-run-info) endpoint.
2. The translated text via the [`/translation-result/{run_id}`](get-translation-run-result) endpoint.

Armed with this identifier, you can integrate both the translation and audio components into your application's workflow, creating a seamless multilingual audio experience for your users.


## OpenAPI

````yaml get /translated-tts/{task_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://client.camb.ai/apis
security: []
paths:
  /translated-tts/{task_id}:
    get:
      tags:
        - Apis
      summary: Create Translated Tts Task Status
      operationId: translated-tts_task_status_translated-tts__task_id__get
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/TaskIDParam'
            description: >-
              A unique identifier for the task. This is used to query the status
              of the translated text to speech task that is running. It is
              returned when a create request is made for translated text to
              speech.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrchestratorPipelineResult'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    TaskIDParam:
      type: string
      title: Task ID
      description: >-
        This parameter represents a unique identifier for a task. It is used in
        various API endpoints to query the status or result of a specific task.
        The `task_id` is typically returned when a task is created.
    OrchestratorPipelineResult:
      properties:
        status:
          $ref: '#/components/schemas/TaskStatus'
        run_id:
          type:
            - integer
            - 'null'
          title: Run ID
      type: object
      title: OrchestratorPipelineResult
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskStatus:
      type: string
      enum:
        - SUCCESS
        - PENDING
        - TIMEOUT
        - ERROR
        - PAYMENT_REQUIRED
      title: TaskStatus
    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
  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.

````