Skip to content

Elevenlabs — Распознавание Речи

POST /sounds/elevenlabs-speech-to-text

Перевод аудио в текст ElevenLabs. Лимит: 20 запросов/мин.

Базовый URL: https://api.aihere.ru/api/v1
Авторизация: Authorization: Bearer <API-ключ>
Rate-limit: 20 запросов/мин

Параметры

ПолеТипОбяз.Описание
audio_urlstringда
tag_eventsbooleanпо умолчанию: true
diarizebooleanпо умолчанию: true

Примеры

cURL

bash
curl -X POST "https://api.aihere.ru/api/v1/sounds/elevenlabs-speech-to-text" \
  -H "Authorization: Bearer $AIHERE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Callback-Url: https://myapp.example.com/api/aihere-callback" \
  -d '{
  "audio_url": "https://example.com/audio.mp3",
  "tag_events": true,
  "diarize": true
}'

Python

python
import requests

payload = {
    "audio_url": "https://example.com/audio.mp3",
    "tag_events": True,
    "diarize": True
}

resp = requests.post(
    "https://api.aihere.ru/api/v1/sounds/elevenlabs-speech-to-text",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        # Опционально: вебхук о завершении задачи
        # "X-Callback-Url": "https://myapp.example.com/api/aihere-callback",
    },
    json=payload,
    timeout=60,
)
resp.raise_for_status()
task_id = resp.json()["task_id"]
print(f"Задача №{task_id} поставлена")

JavaScript

javascript
const resp = await fetch("https://api.aihere.ru/api/v1/sounds/elevenlabs-speech-to-text", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
    // Опционально: "X-Callback-Url": "https://myapp.example.com/api/aihere-callback",
  },
  body: JSON.stringify({
  "audio_url": "https://example.com/audio.mp3",
  "tag_events": true,
  "diarize": true
}),
});
if (!resp.ok) throw new Error(`HTTP ${resp.status}: ${await resp.text()}`);
const { task_id } = await resp.json();
console.log("Задача №" + task_id + " поставлена");

PHP

php
$payload = json_decode('{"audio_url": "https://example.com/audio.mp3", "tag_events": true, "diarize": true}', true);

$ch = curl_init('https://api.aihere.ru/api/v1/sounds/elevenlabs-speech-to-text');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer $apiKey",
        'Content-Type: application/json',
        // Опционально: 'X-Callback-Url: https://myapp.example.com/api/aihere-callback',
    ],
]);
$resp = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "Задача №{$resp['task_id']} поставлена";

Ответ 200

ID генерации

json
{
  "task_id": 123
}

Ошибки

КодПричина
429Превышен rate-limit
502Ошибка провайдера генерации
503Провайдер недоступен или сбой сервиса баланса (списанные средства возвращаются)
422Ошибка валидации тела запроса (detail содержит список полей)
401Нет или невалидный API-ключ