Ottieni lo stato della traduzione
curl --request GET \
--url https://api.voicecheap.ai/v1/translate/{projectId}/status \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.voicecheap.ai/v1/translate/{projectId}/status"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.voicecheap.ai/v1/translate/{projectId}/status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.voicecheap.ai/v1/translate/{projectId}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.voicecheap.ai/v1/translate/{projectId}/status"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.voicecheap.ai/v1/translate/{projectId}/status")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.voicecheap.ai/v1/translate/{projectId}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"projectId": "<string>",
"projectName": "<string>",
"originalVideoUrl": "<string>",
"originalLanguage": "<string>",
"targetLanguage": "<string>",
"duration": 123,
"createdAt": 123,
"workflow": "<string>",
"transcriptionStatus": "<string>",
"transcripts": {
"transcripts.original": {},
"transcripts.translations": [
{}
]
},
"workId": "<string>",
"translatedVersionId": "<string>",
"actualProgressStep": "<string>",
"translationAndTranscriptionProgress": 123,
"dubbingStep": "<string>",
"dubbingProgress": 123,
"status": "<string>",
"lipSync": {
"lipSync.jobId": "<string>",
"lipSync.status": "<string>",
"lipSync.videoUrl": "<string>",
"lipSync.errorMessage": "<string>",
"lipSync.type": "<string>",
"lipSync.createdAt": "<string>",
"lipSync.requestedAt": "<string>",
"lipSync.completedAt": "<string>",
"lipSync.failedAt": "<string>",
"lipSync.timedOutAt": "<string>",
"lipSync.activeSpeakerDetectionEnabled": true
},
"translatedVideoUrl": "<string>",
"translatedAudioUrl": "<string>",
"error": {
"error.code": "<string>",
"error.message": "<string>"
}
}Traduzione
Ottieni lo stato della traduzione
Controlla lo stato di un progetto di traduzione e recupera i risultati
Ottieni lo stato della traduzione
curl --request GET \
--url https://api.voicecheap.ai/v1/translate/{projectId}/status \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.voicecheap.ai/v1/translate/{projectId}/status"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.voicecheap.ai/v1/translate/{projectId}/status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.voicecheap.ai/v1/translate/{projectId}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.voicecheap.ai/v1/translate/{projectId}/status"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.voicecheap.ai/v1/translate/{projectId}/status")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.voicecheap.ai/v1/translate/{projectId}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"projectId": "<string>",
"projectName": "<string>",
"originalVideoUrl": "<string>",
"originalLanguage": "<string>",
"targetLanguage": "<string>",
"duration": 123,
"createdAt": 123,
"workflow": "<string>",
"transcriptionStatus": "<string>",
"transcripts": {
"transcripts.original": {},
"transcripts.translations": [
{}
]
},
"workId": "<string>",
"translatedVersionId": "<string>",
"actualProgressStep": "<string>",
"translationAndTranscriptionProgress": 123,
"dubbingStep": "<string>",
"dubbingProgress": 123,
"status": "<string>",
"lipSync": {
"lipSync.jobId": "<string>",
"lipSync.status": "<string>",
"lipSync.videoUrl": "<string>",
"lipSync.errorMessage": "<string>",
"lipSync.type": "<string>",
"lipSync.createdAt": "<string>",
"lipSync.requestedAt": "<string>",
"lipSync.completedAt": "<string>",
"lipSync.failedAt": "<string>",
"lipSync.timedOutAt": "<string>",
"lipSync.activeSpeakerDetectionEnabled": true
},
"translatedVideoUrl": "<string>",
"translatedAudioUrl": "<string>",
"error": {
"error.code": "<string>",
"error.message": "<string>"
}
}Ottieni lo stato della traduzione
Recupera lo stato attuale di un progetto di traduzione. Utilizza questo endpoint per verificare il progresso e ottenere l’URL del video tradotto una volta completata l’elaborazione.Richiesta
Intestazioni
string
obbligatorio
La tua chiave API VoiceCheap. Ottienine una da app.voicecheap.ai/page-api.
Parametri del percorso
string
obbligatorio
L’identificatore univoco del progetto di traduzione restituito dall’endpoint Start Translation.
Risposta
La struttura della risposta varia in base allo stato della traduzione.Campi comuni
string
obbligatorio
L’identificatore univoco del progetto
string
obbligatorio
Il nome del progetto
string
obbligatorio
URL del file video/audio originale caricato
string
obbligatorio
La lingua originale rilevata o specificata
string
obbligatorio
La lingua di destinazione per la traduzione
number
obbligatorio
Durata del contenuto in secondi
number
obbligatorio
Timestamp Unix di creazione del progetto
string
obbligatorio
Flusso di lavoro API che ha creato il progetto:
translation o transcription.string
obbligatorio
Stato della trascrizione sorgente:
processing, success o failed. Questo segnale è indipendente dal completamento del doppiaggio.object
obbligatorio
string
Identificatore del lavoro di traduzione per la versione tradotta attualmente riportata.
string
Identificatore della versione tradotta per la versione tradotta attualmente riportata.
string
Fase attuale del progetto. Durante la creazione o la trascrizione, riflette la fase di creazione attiva.
Esempi includono
downloading_content, content_validation e transcription_processing.
Una volta avviato il doppiaggio, può passare a una fase di doppiaggio attiva come smart_sync o audio_assembling.
status: processing non si abbina a actualProgressStep: done.number
Percentuale di progresso approssimativa per la creazione/trascrizione del progetto (0-100)
string
Fase di doppiaggio attuale per la lingua di destinazione (es.
smart_sync, audio_enhancement, video_upload)number
Percentuale di progresso approssimativa per il doppiaggio (0-100)
string
obbligatorio
Stato attuale della traduzione:
processing, success o failedCampi Lip Sync
Quando è stata richiesta la sincronizzazione labiale, la risposta include un oggettolipSync aggiuntivo:
object
Stato della sincronizzazione labiale e dettagli dell’output (presente solo quando è stata richiesta la sincronizzazione labiale)
Mostra proprietà lipSync
Mostra proprietà lipSync
string
Identificatore del lavoro di sincronizzazione labiale
string
Stato della sincronizzazione labiale:
PENDING, PROCESSING, COMPLETED, FAILED, REJECTED o CANCELEDstring
URL del video con sincronizzazione labiale. Utilizza questo URL per l’output finale con sincronizzazione labiale quando
lipSync.status è COMPLETED.string
Dettagli dell’errore se la sincronizzazione labiale non è riuscita
string
Modalità di sincronizzazione labiale:
standard, pro o studio.string
Timestamp ISO di creazione del tentativo di sincronizzazione labiale.
string
Timestamp ISO di richiesta del tentativo di sincronizzazione labiale, quando disponibile.
string
Timestamp ISO di completamento della sincronizzazione labiale, quando disponibile.
string
Timestamp ISO di fallimento della sincronizzazione labiale, quando disponibile.
string
Timestamp ISO di quando la sincronizzazione labiale è andata in timeout, se disponibile.
boolean
Indica se il rilevamento del parlante attivo era abilitato per questo tentativo di sincronizzazione labiale.
Quando viene richiesta la sincronizzazione labiale, la traduzione rimane in
processing finché lipSync.status non è COMPLETED. Se la sincronizzazione labiale fallisce, lo stato diventa
failed e error.code è LIPSYNC_FAILED. Quando la sincronizzazione labiale ha successo, leggi l’asset sincronizzato labialmente da lipSync.videoUrl; translatedVideoUrl
è il video tradotto in output prima della sovrapposizione della sincronizzazione labiale.Usa
GET /v1/projects/{projectId} quando hai bisogno della cronologia completa delle versioni tradotte o della cronologia completa della sincronizzazione labiale.Campi della risposta di successo
Per i flussi di lavoro di traduzione, i seguenti campi sono inclusi quandostatus è success. Un flusso di lavoro di sola trascrizione raggiunge success senza campi multimediali tradotti.
string
URL per scaricare il file video tradotto
string
URL per scaricare separatamente il file audio tradotto
Campi della risposta di errore
Quandostatus è failed, viene incluso il seguente campo aggiuntivo:
object
Esempi
curl -X GET "https://api.voicecheap.ai/v1/translate/abc123-def456-ghi789/status" \
-H "x-api-key: vc_your-api-key"
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);
}
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);
}
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
$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;
}
Esempi di risposta
Stato di elaborazione
{
"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"
}
Stato di elaborazione (Lip Sync Richiesto)
{
"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"
}
}
Stato di successo
{
"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/..."
}
Stato di successo (Lip Sync Completato)
{
"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"
}
}
Stato di fallimento
{
"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": "Could not transcribe the audio. Please ensure the audio quality is sufficient."
}
}
Best practice per il polling
Intervallo di polling consigliato: 10-30 secondiIl tempo di traduzione varia in base alla lunghezza e alla complessità del video. Per un tipico video di 2 minuti, prevedere 2-5 minuti di tempo di elaborazione.
Limite di frequenza: 30 richieste al minutoEvita di eseguire il polling più frequentemente di una volta ogni 2 secondi per rimanere entro i limiti di frequenza.
Errori
| Stato | Codice | Descrizione |
|---|---|---|
| 401 | INVALID_API_KEY | La chiave API fornita non è valida |
| 403 | FORBIDDEN | Non hai accesso a questo progetto |
| 404 | PROJECT_NOT_FOUND | Il progetto specificato non esiste |
| 429 | RATE_LIMIT_EXCEEDED | Troppe richieste (limite: 30 richieste al minuto) |
Questa pagina è stata utile?

