Transcription Vocale (POST /v1/audio/transcriptions)
Transcrit l’audio en texte dans le format spécifié avec une compatibilité protocolaire complète avec l’API OpenAI.
Requête HTTP
http
POST /v1/audio/transcriptions
Authorization: Bearer sk-oneasr-...
Content-Type: multipart/form-dataCorps de la Requête (Multipart Form)
| Champ | Type | Requis | Description |
|---|---|---|---|
file | binary | Oui | L’objet binaire audio (mp3, mp4, wav, m4a, ogg, webm, flac, etc.). |
model | string | Oui | Nom du moteur/modèle cible (ex. faster-whisper, qwen, whisper-1). |
language | string | Non | Code langue ISO-639-1 (ex. fr, en, zh, ja, de, es). |
prompt | string | Non | Invite guide facultative pour orienter l’orthographe ou le vocabulaire technique. |
response_format | string | Non | Format de sortie : json (par défaut), text, srt, verbose_json, vtt. |
temperature | number | Non | Température d’échantillonnage (0.0 à 1.0, par défaut : 0.0). |
timestamp_granularities | array | Non | Granularités temporelles pour verbose_json : ["word"], ["segment"]. |
Exemples de Code
cURL
bash
curl -X POST http://localhost:8000/v1/audio/transcriptions -H "Authorization: Bearer sk-oneasr-v1-xxx" -F file="@podcast.mp3" -F model="faster-whisper" -F response_format="verbose_json"Python (SDK Officiel OpenAI)
python
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-oneasr-v1-xxx"
)
with open("speech.mp3", "rb") as f:
result = client.audio.transcriptions.create(
model="faster-whisper",
file=f,
response_format="verbose_json"
)
print(result.text)Réponse (verbose_json)
json
{
"task": "transcribe",
"language": "english",
"duration": 5.24,
"text": "Welcome to OneASR private voice gateway.",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 5.2,
"text": "Welcome to OneASR private voice gateway.",
"tokens": [50364, 4843, 284, 1530, 50589],
"temperature": 0.0,
"avg_logprob": -0.12,
"compression_ratio": 1.1,
"no_speech_prob": 0.001
}
]
}