音頻
語音轉文本
將音頻文件轉錄為文本。
POST
/
api
/
v1
/
audio
/
stt
語音轉文本
curl --request POST \
--url https://api.example.com/api/v1/audio/stt \
--header 'Content-Type: application/json' \
--data '
{
"file": {},
"language": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/audio/stt"
payload = {
"file": {},
"language": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({file: {}, language: '<string>'})
};
fetch('https://api.example.com/api/v1/audio/stt', 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.example.com/api/v1/audio/stt",
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([
'file' => [
],
'language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/api/v1/audio/stt"
payload := strings.NewReader("{\n \"file\": {},\n \"language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/audio/stt")
.header("Content-Type", "application/json")
.body("{\n \"file\": {},\n \"language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/audio/stt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"file\": {},\n \"language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"text": "<string>",
"language": {},
"duration_seconds": {},
"usage": {
"cost_cents": 123
}
}將音頻文件轉錄為文本。使用 multipart 表單上傳(非 JSON)。最大文件大小:25 MB。
身份驗證
需要 Bearer 令牌。參見身份驗證。請求體(multipart/form-data)
Blob
必填
待轉錄的音頻文件。支持的格式:MP3、MP4、MPEG、MPGA、M4A、WAV、WEBM。
string
語言提示(ISO 639-1 代碼,例如
"en"、"es"、"fr")。如果省略,將自動檢測語言。請求示例
curl -X POST https://www.hitheo.ai/api/v1/audio/stt \
-H "Authorization: Bearer $THEO_API_KEY" \
-F "file=@recording.mp3" \
-F "language=en"
const file = new Blob([audioBytes], { type: "audio/mp3" });
const result = await theo.stt(file, "en");
console.log(result.text); // 轉錄文本
console.log(result.language); // 檢測到的語言
console.log(result.duration_seconds); // 音頻時長
響應
string
唯一的轉錄 ID(以
stt_ 為前綴)。string
ISO 8601 時間戳。
string
轉錄後的文本。
string | null
檢測到或指定的語言。
number | null
音頻文件的時長(秒)。
響應示例
{
"id": "stt_abc123",
"created": "2026-04-10T12:00:00Z",
"text": "Welcome to Theo. How can I help you today?",
"language": "en",
"duration_seconds": 3.2,
"usage": { "cost_cents": 0.01 }
}
錯誤
| 狀態碼 | 錯誤碼 | 描述 |
|---|---|---|
| 400 | missing_file | 缺少 file(multipart 表單上傳) |
| 401 | invalid_api_key | API 密鑰缺失或無效 |
| 502 | stt_provider_error | Theo 轉錄引擎返回錯誤 — 請重試 |
| 503 | stt_unavailable | 當前實例未配置語音轉文本功能 |
這個頁面有幫助嗎?
語音轉文本
curl --request POST \
--url https://api.example.com/api/v1/audio/stt \
--header 'Content-Type: application/json' \
--data '
{
"file": {},
"language": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/audio/stt"
payload = {
"file": {},
"language": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({file: {}, language: '<string>'})
};
fetch('https://api.example.com/api/v1/audio/stt', 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.example.com/api/v1/audio/stt",
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([
'file' => [
],
'language' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/api/v1/audio/stt"
payload := strings.NewReader("{\n \"file\": {},\n \"language\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/audio/stt")
.header("Content-Type", "application/json")
.body("{\n \"file\": {},\n \"language\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/audio/stt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"file\": {},\n \"language\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"text": "<string>",
"language": {},
"duration_seconds": {},
"usage": {
"cost_cents": 123
}
}