Translate videos with AI-powered dubbing using iFlytek's Video Translation service.
Base URL: https://spark-api-test.xf-yun.com/api/v1/video-translate
EndpointMethodDescription/tasksPOSTCreate video translation task/tasksGETList all tasks/tasks/:taskIdGETGet task details
Submit a video for translation.
Use this when: User provides a video URL and wants to translate it.
bash
# Create task - translate English video to Chinese
python3 scripts/xfei_video_translate.py --action create_task \
--file_url "https://example.com/video.mp4" \
--src_lang en --dest_lang zh
# Translate Chinese to English
python3 scripts/xfei_video_translate.py --action create_task \
--file_url "https://example.com/video.mp4" \
--src_lang zh --dest_lang en
# Translate Japanese to Chinese
python3 scripts/xfei_video_translate.py --action create_task \
--file_url "https://example.com/video.mp4" \
--src_lang ja --dest_lang zh
View all video translation tasks.
Use this when: User wants to see all translation tasks.
bash
# List all tasks
python3 scripts/xfei_video_translate.py --action list_tasks
View detailed information about a specific task.
Use this when: User wants to check the status and details of a specific task.
bash
# Get task details
python3 scripts/xfei_video_translate.py --action get_task \
--task_id "xxx-xxx-xxx"
bash
pip install requests>=2.31.0
bash
export XFYUN_API_KEY="your_api_key"
export XFYUN_API_SECRET="your_api_secret"
ParameterTypeRequiredDescription--file_url / -ustringYesVideo file OSS URL (视频文件 OSS 地址)--src_lang / -fstringYesSource language code (e.g., en, zh, ja, ko)--dest_lang / -tstringYesTarget language code
No parameters required.
ParameterTypeRequiredDescription--task_id / -istringYesTask ID
Standard response: {"code": 0, "message": "success", "request_id": "xxx", "data": {}}
json
{
"task_id": "xxx-xxx-xxx",
"status": "waiting_parsing",
"created_at": "2025-01-17T10:30:45Z"
}
json
[
{
"task_id": "xxx-xxx-xxx",
"task_name": "我的翻译任务",
"status": "completed",
"src_lang": "en",
"dest_lang": "zh",
"created_at": "2025-01-17T10:30:45Z",
"updated_at": "2025-01-17T11:30:45Z"
}
]
json
{
"task_id": "xxx-xxx-xxx",
"task_name": "我的翻译任务",
"status": "completed",
"created_at": "2025-01-17T10:30:45Z",
"updated_at": "2025-01-17T11:30:45Z",
"task_params": {
"file_url": "https://example.com/video.mp4",
"src_lang": "en",
"dest_lang": "zh"
},
"output": {
"subtitle_url": "https://example.com/output.srt",
"output_video_url": "https://example.com/output.mp4"
}
}
StatusDescriptionrunningTask in progresscompletedTask completed successfullyfailedTask failedcancelledTask cancelledwaiting_manual_intervention_segmentWaiting for transcript editingwaiting_manual_intervention_refineWaiting for translation editing
CodeLanguagezhChinese (中文)enEnglish (英文)jaJapanese (日文)koKorean (韩文)ruRussian (俄文)frFrench (法文)arArabic (阿拉伯语)esSpanish (西班牙语)yueCantonese (粤语)
ErrorCauseSolutionXFYUN_API_KEY and XFYUN_API_SECRET are requiredNo credentials configuredSet environment variables--file_url is requiredNo video URL providedProvide valid OSS video URL--task_id is requiredNo task ID providedProvide valid task IDAPI error XXXXRequest failedCheck message in response
哎呀呀~遇到鉴权错误啦! (⊙_⊙) 快来看看是哪里出问题了吧~
HTTP Code错误描述原因处理建议401{"message":"Unauthorized"}缺少 authorization 参数哎呀~检查一下有没有正确带上传入的 authorization 参数哦~401{"message":"HMAC signature cannot be verified"}签名参数解析失败嗯嗯~ (°∀°)ノ 检查一下各签名参数是否完整,确认 APIKey 是不是正确呀~401{"message":"HMAC signature does not match"}签名校验失败嘿呀~ (。•́︿•̀。) 检查一下 APIKey/APISecret 是否正确呢~还要看看 host、date、request-line 拼接对不对哦~signature 的 Base64 长度正常应该是 44 字节呢~403{"message":"HMAC signature cannot be verified, a valid date or x-date header is required"}时钟偏移校验失败嗯嗯? (⊙_⊙) 服务器时钟可能有偏差哦~偏差超过 300 秒就会被拒绝啦!快去校准一下时间吧~
小贴士 💡: