Google टेक्स्ट-टू-स्पीच

WaveNet आवाज़ों के साथ Google का न्यूरल टेक्स्ट-टू-स्पीच। SSML सपोर्ट के साथ 50+ भाषाओं में 380 से अधिक आवाज़ें।

✓ 380+ आवाज़ें

✓ 50+ भाषाएं

✓ WaveNet क्वालिटी

✓ SSML सपोर्ट

प्रमाणीकरण

Doitong API के माध्यम से Google TTS को एक्सेस करने के लिए, अपनी Doitong API key का उपयोग करें। इसे GraphQL mutation या REST API headers में शामिल करें।

महत्वपूर्ण: अपनी Doitong API key को सुरक्षित रखें और इसे कभी भी क्लाइंट-साइड कोड में सार्वजनिक न करें। हमेशा अपने बैकएंड सर्वर से API कॉल करें।
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

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

क्विक स्टार्ट

बस कुछ ही मिनटों में Google TTS API के साथ शुरुआत करें। अपना पहला tts जेनरेट करने के लिए इन सरल चरणों का पालन करें।

चरण 1: अपनी API Key प्राप्त करें

Doitong अकाउंट के लिए साइन अप करें और API key जेनरेट करने के लिए अपने डैशबोर्ड पर जाएं।

चरण 2: अपनी पहली रिक्वेस्ट भेजें

अपनी पहली API कॉल करने के लिए नीचे दिए गए कोड उदाहरणों में से किसी एक का उपयोग करें।

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": "google-tts",
        "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: 'google-tts',
        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": "google-tts",
        "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": "google-tts",
    "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": "neural2"
    }
  }
}

प्राइसिंग

Google TTS API क्रेडिट-आधारित प्राइसिंग मॉडल का उपयोग करता है। जेनरेट किए गए कंटेंट की जटिलता और अवधि के आधार पर क्रेडिट खर्च होते हैं।

फीचर क्रेडिट विवरण
स्टैंडर्ड वॉइस 1 क्रेडिट प्रति 100 कैरेक्टर बेसिक न्यूरल वॉइस
प्रीमियम वॉइस 2 क्रेडिट प्रति 100 कैरेक्टर भावनाओं के साथ उन्नत न्यूरल वॉइस

API एंडपॉइंट्स

Google TTS API हमारे एकीकृत GraphQL एंडपॉइंट के माध्यम से उपलब्ध है।

GraphQL एंडपॉइंट

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

REST एंडपॉइंट

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

पैरामीटर्स

Google TTS API रिक्वेस्ट के लिए उपलब्ध पैरामीटर्स:

पैरामीटर प्रकार अनिवार्य विवरण
service String Yes सर्विस आइडेंटिफ़ायर: "google-tts"
version String No Model version: "wavenet", "neural2"
webhookUrl String No जनरेशन पूरा होने के नोटिफिकेशन प्राप्त करने के लिए URL

रिस्पॉन्स फॉर्मेट

सभी API रिस्पॉन्स एक सुसंगत फॉर्मेट का पालन करते हैं:

सफलता रिस्पॉन्स

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

पूर्ण रिस्पॉन्स

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

एरर हैंडलिंग

API मानक HTTP स्टेटस कोड का उपयोग करता है और विस्तृत एरर मैसेज देता है।

सामान्य एरर कोड

स्टेटस कोड एरर टाइप विवरण
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

एरर रिस्पॉन्स फॉर्मेट

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

वेबहुक्स

जब आपका tts जनरेशन पूरा हो जाए, तो रीयल-टाइम नोटिफिकेशन प्राप्त करें।

वेबहुक्स सेटअप करना

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

वेबहुक पेलोड

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

वेबहुक सुरक्षा

सभी वेबहुक रिक्वेस्ट में वेरिफिकेशन के लिए एक सिग्नेचर हेडर शामिल होता है:

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

रेट लिमिट्स

निष्पक्ष उपयोग और सिस्टम स्थिरता सुनिश्चित करने के लिए, निम्नलिखित रेट लिमिट्स लागू होती हैं:

प्लान रिक्वेस्ट/मिनट समवर्ती जॉब्स दैनिक सीमा
फ्री 10 1 100
स्टार्टर 30 3 1,000
प्रो 60 10 10,000
एंटरप्राइज कस्टम कस्टम असीमित
रेट लिमिट हेडर: वर्तमान लिमिट स्टेटस के लिए रिस्पॉन्स हेडर चेक करें:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

सर्वोत्तम अभ्यास

1. अपने प्रॉम्प्ट्स को ऑप्टिमाइज़ करें

सर्वोत्तम परिणामों के लिए स्पष्ट और वर्णनात्मक प्रॉम्प्ट लिखें:

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

2. एसिंक प्रोसेसिंग को हैंडल करें

जनरेशन एसिंक्रोनस है। उचित पोलिंग या वेबहुक लागू करें:

// 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. एरर रिकवरी

एक्सपोनेंशियल बैकऑफ़ के साथ रिट्राय लॉजिक लागू करें:

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. क्रेडिट उपयोग की निगरानी करें

रुकावटों से बचने के लिए अपने क्रेडिट खर्च को ट्रैक करें:

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

क्या आप शुरू करने के लिए तैयार हैं?

बेहतरीन कंटेंट बनाने के लिए Google TTS API का उपयोग करने वाले हज़ारों डेवलपर्स में शामिल हों

API Key प्राप्त करें प्राइसिंग देखें