Audio
Speech Recognition & Translation
Speech-to-text (STT) and speech translation
POST
/
v1
/
audio
/
transcriptions
curl https://www.qingbo.dev/v1/audio/transcriptions \
-H "Authorization: Bearer YOUR_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
with open("audio.mp3", "rb") as f:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=f
)
print(transcript.text)
import OpenAI from 'openai';
import fs from 'fs';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const transcript = await client.audio.transcriptions.create({
model: 'whisper-1',
file: fs.createReadStream('audio.mp3')
});
console.log(transcript.text);
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("audio.mp3")
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "audio.mp3")
io.Copy(part, file)
writer.WriteField("model", "whisper-1")
writer.Close()
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/audio/transcriptions", body)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
String boundary = "----FormBoundary" + System.currentTimeMillis();
byte[] fileBytes = Files.readAllBytes(Path.of("audio.mp3"));
String body = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"file\"; filename=\"audio.mp3\"\r\n"
+ "Content-Type: audio/mpeg\r\n\r\n";
String fieldPart = "\r\n--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"model\"\r\n\r\nwhisper-1\r\n"
+ "--" + boundary + "--\r\n";
byte[] requestBody = new byte[body.getBytes().length + fileBytes.length + fieldPart.getBytes().length];
System.arraycopy(body.getBytes(), 0, requestBody, 0, body.getBytes().length);
System.arraycopy(fileBytes, 0, requestBody, body.getBytes().length, fileBytes.length);
System.arraycopy(fieldPart.getBytes(), 0, requestBody, body.getBytes().length + fileBytes.length, fieldPart.getBytes().length);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/audio/transcriptions"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"text": "欢迎使用 清波 API 语音识别服务。"
}
Synchronous endpoint — returns the recognition result directly when the request completes.
Transcribe audio into text in its original language.
Translate audio into English text. Parameters are the same as the transcription endpoint.
curl https://www.qingbo.dev/v1/audio/transcriptions \
-H "Authorization: Bearer YOUR_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
with open("audio.mp3", "rb") as f:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=f
)
print(transcript.text)
import OpenAI from 'openai';
import fs from 'fs';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const transcript = await client.audio.transcriptions.create({
model: 'whisper-1',
file: fs.createReadStream('audio.mp3')
});
console.log(transcript.text);
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("audio.mp3")
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "audio.mp3")
io.Copy(part, file)
writer.WriteField("model", "whisper-1")
writer.Close()
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/audio/transcriptions", body)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
String boundary = "----FormBoundary" + System.currentTimeMillis();
byte[] fileBytes = Files.readAllBytes(Path.of("audio.mp3"));
String body = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"file\"; filename=\"audio.mp3\"\r\n"
+ "Content-Type: audio/mpeg\r\n\r\n";
String fieldPart = "\r\n--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"model\"\r\n\r\nwhisper-1\r\n"
+ "--" + boundary + "--\r\n";
byte[] requestBody = new byte[body.getBytes().length + fileBytes.length + fieldPart.getBytes().length];
System.arraycopy(body.getBytes(), 0, requestBody, 0, body.getBytes().length);
System.arraycopy(fileBytes, 0, requestBody, body.getBytes().length, fileBytes.length);
System.arraycopy(fieldPart.getBytes(), 0, requestBody, body.getBytes().length + fileBytes.length, fieldPart.getBytes().length);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/audio/transcriptions"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"text": "欢迎使用 清波 API 语音识别服务。"
}
Available Models
| Model ID | Description |
|---|---|
whisper-1 | OpenAI Whisper, supports multilingual recognition |
Two Endpoints
Speech-to-text
POST /v1/audio/transcriptions
Speech translation
POST /v1/audio/translations
Request Parameters
Use themultipart/form-data format:
Audio file. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm.
Model ID:
whisper-1Response
The recognized or translated text.
⌘I
curl https://www.qingbo.dev/v1/audio/transcriptions \
-H "Authorization: Bearer YOUR_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
with open("audio.mp3", "rb") as f:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=f
)
print(transcript.text)
import OpenAI from 'openai';
import fs from 'fs';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const transcript = await client.audio.transcriptions.create({
model: 'whisper-1',
file: fs.createReadStream('audio.mp3')
});
console.log(transcript.text);
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("audio.mp3")
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "audio.mp3")
io.Copy(part, file)
writer.WriteField("model", "whisper-1")
writer.Close()
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/audio/transcriptions", body)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
String boundary = "----FormBoundary" + System.currentTimeMillis();
byte[] fileBytes = Files.readAllBytes(Path.of("audio.mp3"));
String body = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"file\"; filename=\"audio.mp3\"\r\n"
+ "Content-Type: audio/mpeg\r\n\r\n";
String fieldPart = "\r\n--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"model\"\r\n\r\nwhisper-1\r\n"
+ "--" + boundary + "--\r\n";
byte[] requestBody = new byte[body.getBytes().length + fileBytes.length + fieldPart.getBytes().length];
System.arraycopy(body.getBytes(), 0, requestBody, 0, body.getBytes().length);
System.arraycopy(fileBytes, 0, requestBody, body.getBytes().length, fileBytes.length);
System.arraycopy(fieldPart.getBytes(), 0, requestBody, body.getBytes().length + fileBytes.length, fieldPart.getBytes().length);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/audio/transcriptions"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"text": "欢迎使用 清波 API 语音识别服务。"
}