ElevenLabs Voice AI

Lleisiau AI mwyaf naturiol gyda rheolaeth emosiynol a sawl iaith.

✓ Lleisiau naturiol

✓ Rheolaeth emosiynol

✓ 29 iaith

✓ Clonio llais

Dilysu

I gael mynediad i ElevenLabs drwy API Doitong, defnyddiwch eich allwedd API Doitong. Cynhwyswch hi ym mhennynnau'r mwtaniad GraphQL neu'r REST API.

Pwysig: Cadwch eich allwedd API Doitong yn ddiogel a pheidiwch byth â'i datgelu mewn cod ochr-cleient. Gwnewch alwadau API o'ch gweinydd cefn bob amser.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

// REST Header
"X-API-Key": "YOUR_API_KEY"

Cychwyn Cyflym

Dechreuwch ddefnyddio ElevenLabs TTS API mewn ychydig funudau yn unig. Dilynwch y camau syml hyn i gynhyrchu eich tts cyntaf.

Cam 1: Cael eich Allwedd API

Cofrestrwch am gyfrif Doitong ac ewch i'ch dangosfwrdd i gynhyrchu allwedd API.

Cam 2: Gwneud eich Cais Cyntaf

Defnyddiwch un o'r enghreifftiau cod isod i wneud eich galwad API gyntaf.

curl -X POST https://api.doitong.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
    "variables": {
      "input": {
        "type": "AUDIO",
        "provider": "elevenlabs",
        "input": {
          "text": "Hello world, this is a text to speech example.",
          "voice": "en-US-neural"
        },
        "options": {
          "speed": 1.0
        }
      }
    }
  }'
const response = await fetch('https://api.doitong.com/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    query: `
      mutation GenerateSpeech($input: TTSInput!) {
        generateSpeech(input: $input) {
          id
          audioUrl
          duration
        }
      }
    `,
    variables: {
      input: {
        service: 'elevenlabs',
        text: 'Hello world, this is a text to speech example.',
        voice: 'en-US-neural',
        speed: 1.0
      }
    }
  })
});

const data = await response.json();
console.log('Result:', data.data.generate);
import requests
import json

url = "https://api.doitong.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

query = """
mutation Generate($input: GenerateInput!) {
  generate(input: $input) {
    id
    status
    type
    provider
    url
    metadata
    creditCost
  }
}
"""

variables = {
    "input": {
        "type": "AUDIO",
        "provider": "elevenlabs",
        "input": {
            "text": "Hello world, this is a text to speech example.",
            "voice": "en-US-neural"
        },
        "options": {
            "speed": 1.0
        }
    }
}

response = requests.post(url, json={
    "query": query,
    "variables": variables
}, headers=headers)

data = response.json()
print("Result:", data["data"]["generate"])
mutation Generate($input: GenerateInput!) {
  generate(input: $input) {
    id
    status
    type
    provider
    url
    metadata
    creditCost
    createdAt
  }
}

# Variables
{
  "input": {
    "type": "AUDIO",
    "provider": "elevenlabs",
    "input": {
      "text": "Hello world, this is a text to speech example.",
      "voice": "en-US-neural"
    },
    "options": {
      "speed": 1.0,
      "pitch": 1.0,
      "language": "en",
      "version": "eleven-turbo-v2"
    }
  }
}

Prisio

Mae ElevenLabs TTS API yn defnyddio model prisio sy'n seiliedig ar gredydau. Defnyddir credydau yn ôl cymhlethdod a hyd y cynnwys a gynhyrchir.

Nodwedd Credydau Disgrifiad
Llais Safonol 1 credyd fesul 100 nod Lleisiau niwral sylfaenol
Llais Premiwm 2 gredyd fesul 100 nod Lleisiau niwral datblygedig gydag emosiwn

Pwyntiau Terfyn API

Mae ElevenLabs TTS API ar gael drwy ein pwynt terfyn GraphQL unedig.

Pwynt Terfyn GraphQL

POST https://api.doitong.com/graphql

Pwynt Terfyn REST

POST https://api.doitong.com/v1/tts

Paramedrau

Paramedrau sydd ar gael ar gyfer ceisiadau ElevenLabs TTS API:

Paramedr Math Gofynnol Disgrifiad
service Llinyn Yes Dynodwr gwasanaeth: "elevenlabs"
version Llinyn No Model version: "eleven-turbo-v2"
webhookUrl Llinyn No URL i dderbyn hysbysiadau cwblhau

Fformat yr Ymateb

Mae holl ymatebion yr API yn dilyn fformat cyson:

Ymateb Llwyddiannus

{
  "data": {
    "tts": {
      "id": "abc123xyz",
      "status": "processing",
      "url": null,
      "webhookUrl": "https://your-webhook.com/callback",
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Ymateb Wedi'i Gwblhau

{
  "data": {
    "tts": {
      "id": "abc123xyz",
      "status": "completed",
      "url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
      "duration": null,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Trin Gwallau

Mae'r API yn defnyddio codau statws HTTP safonol ac yn dychwelyd negeseuon gwall manwl.

Codau Gwall Cyffredin

Cod Statws Math o Wall Disgrifiad
400 Bad Request Invalid parameters or malformed request
401 Unauthorized Missing or invalid API key
402 Payment Required Insufficient credits
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error, please retry

Fformat Ymateb Gwall

{
  "errors": [
    {
      "message": "Insufficient credits for this operation",
      "extensions": {
        "code": "INSUFFICIENT_CREDITS",
        "creditsRequired": 100,
        "creditsAvailable": 50
      }
    }
  ]
}

Webhooks

Derbyniwch hysbysiadau amser-real pan fydd eich tts wedi'i gynhyrchu.

Ffurfweddu Webhooks

Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.

Llwyth Cyflog Webhook

{
  "id": "abc123xyz",
  "status": "completed",
  "url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
  "service": "elevenlabs",
  "createdAt": "2024-01-01T00:00:00Z",
  "completedAt": "2024-01-01T00:01:00Z",
  "metadata": {
    "duration": null,
    "width": null,
    "height": null
  }
}

Diogelwch Webhook

Mae pob cais webhook yn cynnwys pennyn llofnod ar gyfer dilysu:

X-Doitong-Signature: sha256=abc123...

Terfynau Cyfradd

Er mwyn sicrhau defnydd teg a sefydlogrwydd y system, mae'r terfynau cyfradd canlynol yn berthnasol:

Cynllun Ceisiadau/Munud Tasgau Cydredol Terfyn Dyddiol
Am Ddim 10 1 100
Dechreuwr 30 3 1,000
Pro 60 10 10,000
Menter Personol Personol Diderfyn
Pennynnau Terfyn Cyfradd: Gwiriwch bennynnau'r ymateb am statws y terfyn cyfredol:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Arferion Gorau

1. Optimeiddio eich Anogwyr

Ysgrifennwch anogwyr clir a disgrifiadol i gael y canlyniadau gorau:

  • Be specific about visual elements, style, and mood
  • Include details about lighting, camera angles, and composition
  • Avoid contradictory or impossible requests

2. Trin Prosesu Anghydamserol

Mae'r broses gynhyrchu yn anghydamserol. Gweithredwch brosesau 'polling' neu webhooks priodol:

// Polling example
async function pollStatus(jobId) {
  let status = 'processing';
  while (status === 'processing') {
    await sleep(2000); // Wait 2 seconds
    const result = await checkJobStatus(jobId);
    status = result.status;
  }
  return result;
}

3. Adfer o Wallau

Gweithredwch resymeg ailgeisio gydag egwyl esbonyddol (exponential backoff):

async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await sleep(Math.pow(2, i) * 1000);
    }
  }
}

4. Monitro Defnydd Credydau

Traciwch eich defnydd o gredydau er mwyn osgoi toriadau yn y gwasanaeth:

  • Check credit balance before large batch operations
  • Set up alerts for low credit thresholds
  • Implement credit-aware request queuing

Yn barod i ddechrau?

Ymunwch â miloedd o ddatblygwyr sy'n defnyddio ElevenLabs TTS API i greu cynnwys anhygoel

Cael Allwedd API Nawr Gweld y Prisiau