GET
/
translated-tts
/
{task_id}
curl --request GET \
  --url https://client.camb.ai/apis/translated-tts/{task_id} \
  --header 'x-api-key: <api-key>'
{
  "status": "SUCCESS",
  "run_id": 123
}

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:

StatusMeaningRecommended Action
SUCCESSBoth translation and audio generation have completed successfullyRetrieve your translated text and audio using the provided IDs
PENDINGYour request is actively being processedContinue monitoring at reasonable intervals
TIMEOUTProcessing exceeded the maximum allowed durationConsider breaking your content into smaller segments
ERRORA system-level issue occurred during processingCheck error details for specific information about what went wrong
PAYMENT_REQUIREDYour account has insufficient credits for this operationVisit your account’s billing page 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

// 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} endpoint.
  2. The translated text via the /translation-result/{run_id} 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.

Authorizations

x-api-key
string
header
required

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.

Path Parameters

task_id
string
required

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.

Response

200
application/json

Successful Response

The response is of type object.