> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.voicecheap.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取翻译状态

> 检查翻译项目的状态并检索结果

# 获取翻译状态

检索翻译项目的当前状态。使用此端点轮询进度，并在处理完成后获取翻译后的视频 URL。

## 请求

### 标头

**x-api-key** `string` *required*

您的 VoiceCheap API 密钥。请从 [app.voicecheap.ai/page-api](https://app.voicecheap.ai/page-api) 获取。

### 路径参数

**projectId** `string` *required*

从 [Start Translation](https://api-docs.voicecheap.ai/docs/zh/api-reference/translate.md) 端点返回的翻译项目的唯一标识符。

> [!NOTE]
>
> 用[创建项目](https://api-docs.voicecheap.ai/docs/zh/api-reference/create-project.md)创建的项目，一旦调用[项目配音](https://api-docs.voicecheap.ai/docs/zh/api-reference/dub-project.md)，就会切换到 `translation` 流程：此接口随后跟踪最新的配音运行。

## 响应

响应结构根据翻译状态而变化。

### 通用字段

**projectId** `string` *required*

项目的唯一标识符

**projectName** `string` *required*

项目名称

**originalVideoUrl** `string` *required*

原始上传视频/音频文件的 URL

**originalLanguage** `string` *required*

检测到或指定的原始语言

**targetLanguage** `string` *required*

翻译的目标语言

**duration** `number` *required*

内容时长（秒）

**createdAt** `number` *required*

项目创建时的 Unix 时间戳

**workflow** `string` *required*

创建该项目的 API 工作流：`translation` 或 `transcription`。

**transcriptionStatus** `string` *required*

源转录状态：`processing`、`success` 或 `failed`。此信号与配音完成情况无关。

**transcripts** `object` *required*

可用的标准化转录。

**transcripts 属性**

**transcripts.original** `object | null`

原始语言转录（如果可用），包括时间戳和发言人。

**transcripts.translations** `array`

可用的目标语言转录及其语言和工作标识。翻译片段在生成语音后带有 `finalSpeedFactor`（参见[导出项目转录](https://api-docs.voicecheap.ai/docs/zh/api-reference/project-transcript.md)）。

**workId** `string`

当前报告的翻译版本的翻译工作标识符。

**translatedVersionId** `string`

当前报告的翻译版本的翻译版本标识符。

**actualProgressStep** `string`

当前项目步骤。在创建或转录期间，这反映了活跃的创建步骤。
示例包括 `downloading_content`、`content_validation` 和 `transcription_processing`。
一旦配音开始，它可能会切换到活跃的配音步骤，例如 `smart_sync` 或 `audio_assembling`。
后续步骤（例如口型同步）仍在运行时，`status: processing` 可能与 `actualProgressStep: done` 同时出现。

**translationAndTranscriptionProgress** `number`

项目创建/转录的近似进度百分比 (0-100)

**dubbingStep** `string`

目标语言的当前配音步骤（例如 `smart_sync`、`audio_enhancement`、`video_upload`）

**dubbingProgress** `number`

配音的近似进度百分比 (0-100)

**status** `string` *required*

翻译的当前状态：`processing`、`success` 或 `failed`

### Lip Sync 字段

当请求口型同步时，响应包含一个额外的 `lipSync` 对象：

**lipSync** `object`

口型同步状态和输出详情（仅在请求口型同步时出现）

**lipSync 属性**

**lipSync.jobId** `string`

口型同步作业标识符

**lipSync.status** `string`

口型同步状态：`PENDING`、`PROCESSING`、`COMPLETED`、`FAILED`、`REJECTED` 或 `CANCELED`

**lipSync.videoUrl** `string`

口型同步视频的 URL。当 `lipSync.status` 为 `COMPLETED` 时，请使用此 URL 获取最终的口型同步输出。

**lipSync.errorMessage** `string | null`

固定的 VoiceCheap 失败消息；未记录失败时为 null。

**lipSync.type** `string`

口型同步模式：`standard`、`pro` 或 `studio`。

**lipSync.createdAt** `string`

创建口型同步尝试时的 ISO 时间戳。

**lipSync.requestedAt** `string`

请求口型同步尝试时的 ISO 时间戳（如果可用）。

**lipSync.completedAt** `string`

口型同步完成时的 ISO 时间戳（如果可用）。

**lipSync.failedAt** `string`

口型同步失败时的 ISO 时间戳（如果可用）。

**lipSync.timedOutAt** `string`

口型同步超时时的 ISO 时间戳（如有）。

**lipSync.activeSpeakerDetectionEnabled** `boolean`

此口型同步尝试是否启用了主动说话者检测。

> [!NOTE]
>
> 当请求口型同步时，翻译将保留在 `processing` 中，直到 `lipSync.status` 被 `COMPLETED`。如果口型同步失败，状态将变为
> `failed` 且 `error.code` 为 `LIPSYNC_FAILED`。当口型同步成功时，从 `lipSync.videoUrl` 读取口型同步后的资产；`translatedVideoUrl`
> 是口型同步叠加之前的翻译视频输出。

> [!TIP]
>
> 当您需要完整的翻译版本历史记录或完整的口型同步历史记录时，请使用 `GET /v1/projects/{projectId}`。

### 成功响应字段

对于翻译工作流，当 `status` 为 `success` 时，会包含以下字段。仅转录工作流会达到 `success`，且不包含翻译后的媒体字段。

**translatedVideoUrl** `string`

下载翻译视频文件的 URL

**translatedAudioUrl** `string`

单独下载翻译音频文件的 URL

### 失败响应字段

当 `status` 为 `failed` 时，会包含以下附加字段：

**error** `object`

错误详情

**错误属性**

**error.code** `string`

机器可读的错误代码

**error.message** `string`

人类可读的错误描述

## 示例

```bash cURL theme={null}
curl -X GET "https://api.voicecheap.ai/v1/translate/abc123-def456-ghi789/status" \
  -H "x-api-key: vc_your-api-key"
```

```typescript TypeScript theme={null}
type TranslationStatus = 'processing' | 'success' | 'failed';

interface Transcript {
  source: 'original' | 'translated';
  language: string;
  text: string;
  segments: Array<{
    index: number;
    text: string;
    begin: number;
    end: number;
    speaker: number;
  }>;
}

interface TranslationStatusBase {
  projectId: string;
  projectName: string;
  originalVideoUrl: string;
  originalLanguage: string;
  targetLanguage: string;
  duration: number;
  createdAt: number;
  workflow: 'translation' | 'transcription';
  transcriptionStatus: TranslationStatus;
  transcripts: {
    original: Transcript | null;
    translations: Transcript[];
  };
  workId?: string;
  translatedVersionId?: string;
  actualProgressStep?: string;
  translationAndTranscriptionProgress?: number;
  dubbingStep?: string;
  dubbingProgress?: number;
  lipSync?: {
    jobId: string;
    status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'REJECTED' | 'CANCELED';
    videoUrl: string;
    errorMessage: string | null;
    type: 'standard' | 'pro' | 'studio';
    createdAt?: string;
    requestedAt?: string;
    completedAt?: string;
    failedAt?: string;
    timedOutAt?: string;
    activeSpeakerDetectionEnabled?: boolean;
  };
}

interface TranslationStatusProcessing extends TranslationStatusBase {
  status: 'processing';
}

interface TranslationStatusSuccess extends TranslationStatusBase {
  status: 'success';
  translatedVideoUrl?: string;
  translatedAudioUrl?: string;
}

interface TranslationStatusFailed extends TranslationStatusBase {
  status: 'failed';
  error: {
    code: string;
    message: string;
  };
}

type TranslationStatusResponse = TranslationStatusProcessing | TranslationStatusSuccess | TranslationStatusFailed;

async function getTranslationStatus(projectId: string): Promise<TranslationStatusResponse> {
  const response = await fetch(`https://api.voicecheap.ai/v1/translate/${projectId}/status`, {
    method: 'GET',
    headers: {
      'x-api-key': 'vc_your-api-key',
    },
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message || 'Failed to get status');
  }

  return response.json();
}

// Polling function with typed response handling
async function pollUntilComplete(projectId: string, intervalMs: number = 10000): Promise<TranslationStatusSuccess> {
  while (true) {
    const status = await getTranslationStatus(projectId);

    if (status.status === 'success') {
      return status;
    }

    if (status.status === 'failed') {
      throw new Error(`Translation failed: ${status.error.message}`);
    }

    console.log('Still processing...');
    await new Promise((resolve) => setTimeout(resolve, intervalMs));
  }
}

// Usage
try {
  const result = await pollUntilComplete('abc123-def456-ghi789');
  console.log('Translated video:', result.translatedVideoUrl);
  console.log('Translated audio:', result.translatedAudioUrl);
} catch (error) {
  console.error('Error:', error);
}
```

```javascript JavaScript theme={null}
const response = await fetch('https://api.voicecheap.ai/v1/translate/abc123-def456-ghi789/status', {
  method: 'GET',
  headers: {
    'x-api-key': 'vc_your-api-key',
  },
});

const status = await response.json();

if (status.status === 'success') {
  console.log('Translated video:', status.translatedVideoUrl);
} else if (status.status === 'processing') {
  console.log('Still processing...');
} else if (status.status === 'failed') {
  console.error('Translation failed:', status.error.message);
}
```

```python Python theme={null}
import requests
import time

headers = {'x-api-key': 'vc_your-api-key'}
project_id = 'abc123-def456-ghi789'

# Poll until complete
while True:
    response = requests.get(
        f'https://api.voicecheap.ai/v1/translate/{project_id}/status',
        headers=headers
    )
    status = response.json()

    if status['status'] == 'success':
        print(f"Translated video: {status['translatedVideoUrl']}")
        print(f"Translated audio: {status['translatedAudioUrl']}")
        break
    elif status['status'] == 'failed':
        print(f"Translation failed: {status['error']['message']}")
        break
    else:
        print("Still processing...")
        time.sleep(10)  # Wait 10 seconds before polling again
```

```php PHP theme={null}
<?php
$apiKey = 'vc_your-api-key';
$projectId = 'abc123-def456-ghi789';

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.voicecheap.ai/v1/translate/{$projectId}/status",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "x-api-key: {$apiKey}"
    ]
]);

$response = curl_exec($curl);
$status = json_decode($response, true);

switch ($status['status']) {
    case 'success':
        echo "Translated video: " . $status['translatedVideoUrl'] . "\n";
        echo "Translated audio: " . $status['translatedAudioUrl'];
        break;
    case 'processing':
        echo "Still processing...";
        break;
    case 'failed':
        echo "Failed: " . $status['error']['message'];
        break;
}
```

## 响应示例

### 处理状态

```json theme={null}
{
  "projectId": "abc123-def456-ghi789",
  "projectName": "My Spanish Translation",
  "originalVideoUrl": "https://storage.voicecheap.ai/...",
  "originalLanguage": "en",
  "targetLanguage": "spanish",
  "duration": 125.5,
  "createdAt": 1702234567890,
  "workflow": "translation",
  "transcriptionStatus": "processing",
  "transcripts": { "original": null, "translations": [] },
  "actualProgressStep": "downloading_content",
  "translationAndTranscriptionProgress": 11,
  "dubbingStep": "smart_sync",
  "dubbingProgress": 30,
  "status": "processing"
}
```

### 处理状态（已请求 Lip Sync）

```json theme={null}
{
  "projectId": "abc123-def456-ghi789",
  "projectName": "My Spanish Translation",
  "originalVideoUrl": "https://storage.voicecheap.ai/...",
  "originalLanguage": "en",
  "targetLanguage": "spanish",
  "duration": 125.5,
  "createdAt": 1702234567890,
  "workflow": "translation",
  "transcriptionStatus": "success",
  "transcripts": { "original": null, "translations": [] },
  "actualProgressStep": "finalizing",
  "translationAndTranscriptionProgress": 95,
  "dubbingStep": "video_upload",
  "dubbingProgress": 95,
  "status": "processing",
  "lipSync": {
    "jobId": "syncjob_123",
    "status": "PROCESSING",
    "videoUrl": "",
    "errorMessage": null,
    "type": "standard"
  }
}
```

### 成功状态

```json theme={null}
{
  "projectId": "abc123-def456-ghi789",
  "projectName": "My Spanish Translation",
  "originalVideoUrl": "https://storage.voicecheap.ai/...",
  "originalLanguage": "en",
  "targetLanguage": "spanish",
  "duration": 125.5,
  "createdAt": 1702234567890,
  "workflow": "translation",
  "transcriptionStatus": "success",
  "transcripts": { "original": null, "translations": [] },
  "status": "success",
  "translatedVideoUrl": "https://storage.voicecheap.ai/translated/...",
  "translatedAudioUrl": "https://storage.voicecheap.ai/audio/..."
}
```

### 成功状态（Lip Sync 已完成）

```json theme={null}
{
  "projectId": "abc123-def456-ghi789",
  "projectName": "My Spanish Translation",
  "originalVideoUrl": "https://storage.voicecheap.ai/...",
  "originalLanguage": "en",
  "targetLanguage": "spanish",
  "duration": 125.5,
  "createdAt": 1702234567890,
  "workflow": "translation",
  "transcriptionStatus": "success",
  "transcripts": { "original": null, "translations": [] },
  "actualProgressStep": "done",
  "dubbingStep": "done",
  "dubbingProgress": 100,
  "status": "success",
  "translatedVideoUrl": "https://storage.voicecheap.ai/translated/...",
  "translatedAudioUrl": "https://storage.voicecheap.ai/audio/...",
  "lipSync": {
    "jobId": "syncjob_123",
    "status": "COMPLETED",
    "videoUrl": "https://storage.voicecheap.ai/lipsync/...",
    "errorMessage": null,
    "type": "pro"
  }
}
```

### 失败状态

```json theme={null}
{
  "projectId": "abc123-def456-ghi789",
  "projectName": "My Spanish Translation",
  "originalVideoUrl": "https://storage.voicecheap.ai/...",
  "originalLanguage": "en",
  "targetLanguage": "spanish",
  "duration": 125.5,
  "createdAt": 1702234567890,
  "workflow": "translation",
  "transcriptionStatus": "failed",
  "transcripts": { "original": null, "translations": [] },
  "status": "failed",
  "error": {
    "code": "TRANSCRIPTION_FAILED",
    "message": "The transcription could not be completed. Please try again."
  }
}
```

## 轮询最佳实践

> [!NOTE]
>
> **建议轮询间隔：** 10-30 秒
>
> 翻译时间因视频长度和复杂程度而异。对于典型的 2 分钟视频，预计处理时间为 2-5 分钟。

> [!WARNING]
>
> **速率限制：** 每分钟 30 个请求
>
> 避免轮询频率高于每 2 秒一次，以保持在速率限制范围内。

## 错误

| 状态 | 代码 | 描述 |
| - | - | - |
| 401 | `INVALID_API_KEY` | 提供的 API 密钥无效 |
| 403 | `FORBIDDEN` | 您无权访问此项目 |
| 404 | `PROJECT_NOT_FOUND` | 指定的项目不存在 |
| 429 | `RATE_LIMIT_EXCEEDED` | 请求过多（限制：每分钟 30 个请求） |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.