转录媒体
curl --request POST \
--url https://api.voicecheap.ai/v1/transcribe \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"outputFormat": "<string>",
"originalLanguage": "<string>",
"numberOfSpeakers": "<string>",
"brandVocabulary": "<string>",
"removeFillerWords": true,
"includeSpeakerLabels": true
}
'import requests
url = "https://api.voicecheap.ai/v1/transcribe"
payload = {
"outputFormat": "<string>",
"originalLanguage": "<string>",
"numberOfSpeakers": "<string>",
"brandVocabulary": "<string>",
"removeFillerWords": True,
"includeSpeakerLabels": True
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
outputFormat: '<string>',
originalLanguage: '<string>',
numberOfSpeakers: '<string>',
brandVocabulary: '<string>',
removeFillerWords: true,
includeSpeakerLabels: true
})
};
fetch('https://api.voicecheap.ai/v1/transcribe', 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/transcribe",
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([
'outputFormat' => '<string>',
'originalLanguage' => '<string>',
'numberOfSpeakers' => '<string>',
'brandVocabulary' => '<string>',
'removeFillerWords' => true,
'includeSpeakerLabels' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.voicecheap.ai/v1/transcribe"
payload := strings.NewReader("{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.voicecheap.ai/v1/transcribe")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.voicecheap.ai/v1/transcribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}"
response = http.request(request)
puts response.read_body转录
转录媒体
将音频或视频文件转录为完整的 JSON、SRT 或 VTT
转录媒体
curl --request POST \
--url https://api.voicecheap.ai/v1/transcribe \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"outputFormat": "<string>",
"originalLanguage": "<string>",
"numberOfSpeakers": "<string>",
"brandVocabulary": "<string>",
"removeFillerWords": true,
"includeSpeakerLabels": true
}
'import requests
url = "https://api.voicecheap.ai/v1/transcribe"
payload = {
"outputFormat": "<string>",
"originalLanguage": "<string>",
"numberOfSpeakers": "<string>",
"brandVocabulary": "<string>",
"removeFillerWords": True,
"includeSpeakerLabels": True
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
outputFormat: '<string>',
originalLanguage: '<string>',
numberOfSpeakers: '<string>',
brandVocabulary: '<string>',
removeFillerWords: true,
includeSpeakerLabels: true
})
};
fetch('https://api.voicecheap.ai/v1/transcribe', 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/transcribe",
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([
'outputFormat' => '<string>',
'originalLanguage' => '<string>',
'numberOfSpeakers' => '<string>',
'brandVocabulary' => '<string>',
'removeFillerWords' => true,
'includeSpeakerLabels' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.voicecheap.ai/v1/transcribe"
payload := strings.NewReader("{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.voicecheap.ai/v1/transcribe")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.voicecheap.ai/v1/transcribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"outputFormat\": \"<string>\",\n \"originalLanguage\": \"<string>\",\n \"numberOfSpeakers\": \"<string>\",\n \"brandVocabulary\": \"<string>\",\n \"removeFillerWords\": true,\n \"includeSpeakerLabels\": true\n}"
response = http.request(request)
puts response.read_body转录媒体
上传音频或视频文件并直接获取其转录内容。此独立端点不会创建配音项目。 该端点接受最大 200 MB 和 2 小时 的文件。它使用与翻译 API 相同的 API 密钥访问规则。 成功的请求将返回 HTTP200。
请求
发送带有以下字段的multipart/form-data。
string
必填
您的 VoiceCheap API 密钥。
file
必填
要转录的音频或视频文件。支持的格式包括 MP4、MOV、MKV、WebM、MPEG、MP3、WAV、M4A、FLAC、OGG 和 AAC。
string
默认值:"json"
响应格式:
json、srt 或 vtt。string
默认值:"auto-detect"
支持的源语言 ISO 代码。除非您知道源语言,否则请将其保留为
auto-detect。不支持的明确语言会在处理开始前返回验证错误。string
默认值:"auto-detect"
auto-detect 或从 1 到 32 的整数。string
一个包含名称、品牌、首字母缩略词或领域术语的 JSON 字符串数组,用于识别。请求术语将与保存的帐户或团队术语表合并。
["VoiceCheap", "SmartSync", "ITC Global"]
boolean
默认值:"true"
从转录中删除常见的填充词。
boolean
默认值:"false"
为 SRT 提示添加
Speaker N: 前缀或添加 VTT 语音标签。JSON 始终在每个片段和单词上包含数字说话人。JSON 响应
JSON 是最完整的输出。它包含全文、语言置信度、媒体时长、说话人、带时间戳的片段以及带时间戳的单词。{
"source": "standalone",
"language": "en",
"languageConfidence": 0.99,
"duration": 12.4,
"text": "Welcome to VoiceCheap.",
"speakers": [{ "id": 0, "label": "Speaker 1" }],
"segments": [
{
"index": 0,
"text": "Welcome to VoiceCheap.",
"begin": 0.18,
"end": 1.74,
"duration": 1.56,
"speaker": 0,
"language": "en",
"confidence": 0.94,
"words": [
{
"index": 0,
"text": "Welcome",
"speaker": 0,
"confidence": 0.96,
"begin": 0.18,
"end": 0.62,
"duration": 0.44
}
]
}
],
"words": [
{
"index": 0,
"text": "Welcome",
"speaker": 0,
"confidence": 0.96,
"begin": 0.18,
"end": 0.62,
"duration": 0.44
}
]
}
示例
curl -X POST "https://api.voicecheap.ai/v1/transcribe" \
-H "x-api-key: vc_your-api-key" \
-F "file=@interview.mp4" \
-F "outputFormat=json" \
-F "numberOfSpeakers=2" \
-F 'brandVocabulary=["VoiceCheap","SmartSync"]'
curl -X POST "https://api.voicecheap.ai/v1/transcribe" \
-H "x-api-key: vc_your-api-key" \
-F "file=@interview.mp4" \
-F "outputFormat=srt" \
-F "includeSpeakerLabels=true" \
--output interview.srt
curl -X POST "https://api.voicecheap.ai/v1/transcribe" \
-H "x-api-key: vc_your-api-key" \
-F "file=@interview.mp4" \
-F "outputFormat=vtt" \
--output interview.vtt
错误
| 状态 | 代码 | 描述 |
|---|---|---|
| 400 | FILE_REQUIRED | 未上传文件 |
| 400 | INVALID_FILE_TYPE | 不支持的文件类型 |
| 400 | INVALID_MEDIA_STREAM | 文件没有音频流 |
| 400 | DURATION_DETECTION_FAILED | 无法读取媒体时长 |
| 400 | DURATION_TOO_LONG | 媒体时长超过两小时 |
| 400 | INVALID_BRAND_VOCABULARY | 一个或多个术语表条目无效 |
| 400 | INVALID_BOOLEAN_VALUE | 多部分布尔值不是 true 或 false |
| 400 | INVALID_JSON_FORMAT | JSON 编码的多部分字段格式错误 |
| 400 | INVALID_MULTIPART_REQUEST | 多部分表单数据格式错误或过大 |
| 413 | FILE_TOO_LARGE | 文件超过 200 MB |
| 502 | TRANSCRIPTION_EMPTY | 转录未返回可用的语音 |
| 502 | TRANSCRIPTION_FAILED | 转录引擎无法完成 |
此页面对您有帮助吗?

