翻译转写稿
curl --request POST \
--url https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"taskId": "2047316590123456789",
"targetLanguage": "en-US"
}
'import requests
url = "https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate"
payload = {
"taskId": "2047316590123456789",
"targetLanguage": "en-US"
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({taskId: '2047316590123456789', targetLanguage: 'en-US'})
};
fetch('https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate', 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.vmeg.ai/openapi/v1/app/tasks/transcription/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'taskId' => '2047316590123456789',
'targetLanguage' => 'en-US'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate"
payload := strings.NewReader("{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "",
"data": {
"taskId": "<string>",
"translation": {
"status": "running",
"targetLanguage": "en-US"
}
}
}转写
翻译转写稿
把已完成转写任务的整篇转写稿翻译成 targetLanguage,与网站转写编辑器里的翻译按钮是同一套翻译。混合语言录音也适用:创建任务时传多个 language.source,再把整段对话翻译成英文。
翻译异步进行。轮询查询任务状态:result.translation.status 从 running 变为 finished 后,用下载转写稿加 content=translation 下载译文。原文转写稿不变,仍可用 content=source 下载。
- 与网站一致,每个任务只有一种目标语言。任务已有译文时再请求其他语言返回
409;请求同一语言会重新翻译整篇并覆盖之前的译文(包括在网站上的修改)。 - 与网站相同的积分余额检查,余额不足返回
402。 - 须
X-Idempotency-Key。
出错时返回 JSON 结构,HTTP 状态为 200,错误码在 body 的 code 中:400 参数不合法;402 积分不足;404 不是你账号下的转写任务;409 任务未完成、已有翻译在进行中、任务已有其他目标语言的译文,或转写稿正在被更新(稍后重试)。
POST
/
openapi
/
v1
/
app
/
tasks
/
transcription
/
translate
翻译转写稿
curl --request POST \
--url https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"taskId": "2047316590123456789",
"targetLanguage": "en-US"
}
'import requests
url = "https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate"
payload = {
"taskId": "2047316590123456789",
"targetLanguage": "en-US"
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({taskId: '2047316590123456789', targetLanguage: 'en-US'})
};
fetch('https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate', 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.vmeg.ai/openapi/v1/app/tasks/transcription/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'taskId' => '2047316590123456789',
'targetLanguage' => 'en-US'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate"
payload := strings.NewReader("{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vmeg.ai/openapi/v1/app/tasks/transcription/translate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"taskId\": \"2047316590123456789\",\n \"targetLanguage\": \"en-US\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "",
"data": {
"taskId": "<string>",
"translation": {
"status": "running",
"targetLanguage": "en-US"
}
}
}请求体
application/json

