DEV Community

Ronniee Arora
Ronniee Arora

Posted on

Getting Started with the TTSFree API: Generate Hindi Speech with cURL

Getting Started with the TTSFree API: Generate Hindi Speech with cURL

TTSFree.in provides an API for developers who want to integrate AI text-to-speech and other audio capabilities into their applications.

The API supports text-to-speech in Hindi, Tamil, Bengali and other Indian languages, along with 23 world languages. Speech-to-text, translation and sound effects are also available.

API access

API access requires a Starter, Creator or Pro plan, or a Business pack.

Pricing:
https://ttsfree.in/pricing

API documentation:
https://ttsfree.in/developers

Create an API key in your dashboard. Keep it on your server and never expose it in browser-side code.

Generate Hindi speech using cURL


bash
API=https://ttsfree.in
KEY=YOUR_API_KEY

JOB=$(curl -s -X POST "$API/v1/jobs" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"capability": "text_to_speech",
       "params": {"text": "नमस्ते! यह मेरा पहला एपीआई अनुरोध है।",
                  "speaker": "Rohit",
                  "language": "Hindi",
                  "emotion": "Narration"}}' | jq -r .job_id)

while true; do
  STATUS=$(curl -s "$API/v1/jobs/$JOB" \
    -H "Authorization: Bearer $KEY" | jq -r .status)

  [ "$STATUS" = queued ] || [ "$STATUS" = running ] || break
  sleep 1
done

URL=$(curl -s "$API/v1/jobs/$JOB" \
  -H "Authorization: Bearer $KEY" | jq -r .result.url)

curl -s -o hello.wav "$URL"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)