India API

Docs › Language and text

Speech API

Text to speech in Hindi, Telugu, Malayalam and English, and noise removal for recordings.

Turn text into natural speech with Piper voices, as MP3, Ogg Opus or WAV, or clean background noise from a recording with DeepFilterNet. Each voice keeps the licence of the recordings it learnt from: /v1/tts/voices lists them, and two Hindi voices are for non-commercial use only. There is no Tamil, Kannada, Bengali, Gujarati or Marathi voice yet. Nothing you send is kept or logged.

Base URL https://api.dharun.devNo API key600 requests a minuteThis page as Markdown

Text to speech

GET/v1/ttsPOST

Returns the audio itself; X-Voice and X-Voice-Licence headers name the voice and its licence. Up to 3,000 characters; split longer text. Write the text in its own script: Hindi in Devanagari, Telugu in Telugu, Malayalam in Malayalam.

Also takes POST: The text to speak. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.

The answer returns the audio itself; errors are JSON as everywhere else.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
textqueryWhat to say (or POST it).
voicequeryA voice ID from /v1/tts/voices, or a language (hi, te, ml, en, en-GB) for its first voice that may be used commercially. Default en.
formatqueryDefault mp3. One of: mp3, ogg, wav.
speedquery0.5 to 2. Default 1.

curl

curl -o speech.mp3 "https://api.dharun.dev/v1/tts?text=Namaste%2C%20welcome%20to%20India%20API.&voice=en_GB-cori-medium"

Python

import requests

response = requests.get("https://api.dharun.dev/v1/tts?text=Namaste%2C%20welcome%20to%20India%20API.&voice=en_GB-cori-medium", timeout=60)
response.raise_for_status()
open("speech.mp3", "wb").write(response.content)

HTML

<audio controls src="https://api.dharun.dev/v1/tts?text=Namaste%2C%20welcome%20to%20India%20API.&amp;voice=en_GB-cori-medium"></audio>

Voices

GET/v1/tts/voices

Every voice with its language, speaker, licence and the credit the licence asks for.

curl

curl "https://api.dharun.dev/v1/tts/voices"

JavaScript

const response = await fetch("https://api.dharun.dev/v1/tts/voices");
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
console.log(body.data);

Python

import requests

response = requests.get("https://api.dharun.dev/v1/tts/voices", timeout=10)
body = response.json()
if not response.ok:
    raise RuntimeError(body["error"]["message"])
print(body["data"])

Response, with lists and long text shortened

{
  "data": [
    {
      "id": "en_US-ljspeech-medium",
      "language": "en-US",
      "name": "English (US)",
      "speaker": "LJ",
      "licence": "Public domain (LJ Speech)",
      "licence_url": "https://keithito.com/LJ-Speech-Dataset/",
      "attribution": "Trained on the LJ Speech dataset by Keith Ito, in the public domain.",
      "non_commercial": false
    },
    {
      "id": "en_GB-cori-medium",
      "language": "en-GB",
      "name": "English (UK)",
      "speaker": "Cori",
      "licence": "Public domain (LibriVox)",
      "licence_url": "https://librivox.org/pages/public-domain/",
      "attribution": "Trained on public-domain LibriVox recordings read by Cori Samuel.",
      "non_commercial": false
    },
    {
      "id": "hi_IN-rohan-medium",
      "language": "hi-IN",
      "name": "Hindi",
      "speaker": "Rohan",
      "licence": "IIT Madras Indic TTS licence: royalty-free, may be redistributed, notice kept",
      "licence_url": "https://www.iitm.ac.in/donlab/indictts/downloads/license.pdf",
      "attribution": "Trained on the Indic TTS database of IIT Madras. COPYRIGHT 2016 TTS Consortium, TDIL, Meity represented by Hema A Murthy & S Umesh, DEPARTMENT OF Computer Scien…",
      "non_commercial": false
    }
  ],
  "meta": {
    "total": 10,
    "note": "Piper has no Tamil, Kannada, Bengali, Gujarati or working Marathi voice yet. Voices marked non_commercial may not be used for commercial work."
  }
}

Remove background noise

POST/v1/audio/denoise

Send a recording (MP3, WAV, Ogg, M4A, WebM, video files too) and get it back with fans, traffic and hum lowered, as mono 48 kHz. The first five minutes are cleaned. Options go in the query string, or as form fields when the file is sent as multipart/form-data.

Send: An audio or video file, up to 10 MB. Post the file as the request body, or as multipart/form-data. Try it with this sample.

The answer returns the audio itself; errors are JSON as everywhere else.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
formatqueryDefault mp3. One of: mp3, ogg, wav.
limitqueryThe most noise is lowered by, in decibels, 6 to 100. Lower values sound more natural. Default 100.

curl

# a sample to try: https://api.dharun.dev/samples/noisy.mp3
curl -F "[email protected]" -o clean.mp3 "https://api.dharun.dev/v1/audio/denoise"

JavaScript

// input is an <input type="file"> element
const form = new FormData();
form.append("file", input.files[0]);
const response = await fetch("https://api.dharun.dev/v1/audio/denoise", { method: "POST", body: form });
if (!response.ok) throw new Error((await response.json()).error.message);
const file = await response.blob();

Python

import requests

files = [("file", open("noisy.mp3", "rb"))]
response = requests.post("https://api.dharun.dev/v1/audio/denoise", files=files, timeout=90)
if not response.ok:
    raise RuntimeError(response.json()["error"]["message"])
open("clean.mp3", "wb").write(response.content)

Using an AI assistant? Connect the MCP server and it can call this API by itself.